47 lines
965 B
Dart
47 lines
965 B
Dart
import 'package:flutter/material.dart' hide TextStyle;
|
|
import 'package:segmentation_douglas_peucker_flutter/dali_point.dart';
|
|
|
|
class SketcherPoints extends CustomPainter {
|
|
SketcherPoints({
|
|
required this.points,
|
|
});
|
|
|
|
final List<DaliPoint> points;
|
|
|
|
@override
|
|
void paint(Canvas canvas, Size size) {
|
|
final Paint paint = Paint();
|
|
|
|
paint.color = Colors.red;
|
|
|
|
final path = Path();
|
|
|
|
if (points.isEmpty) {
|
|
return;
|
|
}
|
|
|
|
// Otherwise, draw a line that connects each point with a curve.
|
|
path.moveTo(
|
|
points[0].x.toDouble(),
|
|
points[0].y.toDouble(),
|
|
);
|
|
|
|
for (int i = 0; i < points.length; i++) {
|
|
path.addOval(
|
|
Rect.fromCircle(
|
|
center: Offset(
|
|
points[i].x.toDouble(),
|
|
points[i].y.toDouble(),
|
|
),
|
|
radius: 5,
|
|
),
|
|
);
|
|
|
|
canvas.drawPath(path, paint);
|
|
}
|
|
}
|
|
|
|
@override
|
|
bool shouldRepaint(SketcherPoints oldDelegate) => true;
|
|
}
|