Метод arcToPoint
Метод arcToPoint класса Path строит дугу с заданным radius до end.
Дуга идёт от текущей точки к конечной.
Радиус задаёт, насколько дуга крутая.
Синтаксис
Path.arcToPoint()
Пример
Давайте построим контур через arcToPoint:
import 'package:flutter/material.dart';
void main()
{
runApp(
MaterialApp(
home: Scaffold(
body: Center(
child: CustomPaint(
size: const Size(220, 100),
painter: _PathArctopointPainter(),
),
),
),
),
);
}
class _PathArctopointPainter extends CustomPainter
{
@override
void paint(Canvas canvas, Size size)
{
final path = Path();
path.moveTo(30, 70);
path.arcToPoint(Offset(190, 70), radius: Radius.circular(40));
final paint = Paint()
..color = Colors.deepPurple
..strokeWidth = 3
..style = PaintingStyle.stroke;
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}
На экране линия или контур, построенный через Path.
Пример
Давайте утолщим линию:
import 'package:flutter/material.dart';
void main()
{
runApp(
MaterialApp(
home: Scaffold(
body: Center(
child: CustomPaint(
size: const Size(220, 100),
painter: _PathArctopointPainter2(),
),
),
),
),
);
}
class _PathArctopointPainter2 extends CustomPainter
{
@override
void paint(Canvas canvas, Size size)
{
final path = Path();
path.moveTo(30, 70);
path.arcToPoint(Offset(190, 70), radius: Radius.circular(40));
paint.strokeWidth = 6;
final paint = Paint()
..color = Colors.deepPurple
..strokeWidth = 3
..style = PaintingStyle.stroke;
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}
На экране тот же контур с более толстой линией.
Смотрите также
-
класс
Paint,
кисть холста -
класс
Canvas,
холст внутриCustomPainter -
перечисление
BoxShape,
прямоугольник или круг -
перечисление
BorderStyle,
есть линия или нет