-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_curve_line.dart
63 lines (57 loc) · 1.7 KB
/
map_curve_line.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class MapLine extends CustomPainter {
MapLine({
required this.animation,
}) : mapLinePaint = Paint()
..color = Colors.white
..style = PaintingStyle.stroke
..strokeWidth = 4.0
..strokeCap = StrokeCap.round,
super(repaint: animation);
final Animation<double> animation;
final Paint mapLinePaint;
@override
void paint(Canvas canvas, Size size) {
Path path = Path();
path.moveTo(size.width / 2 + size.width * .05 * animation.value, 5);
path.cubicTo(
size.width / 2 + size.width * .2 * animation.value,
size.height / 6,
size.width / 2,
size.height / 6,
size.width / 2 + size.width * .16 * animation.value,
size.height / 3.3,
);
path.cubicTo(
size.width / 2 + size.width * .3 * animation.value,
size.height / 2,
size.width / 2 + size.width * .3 * animation.value,
size.height / 2,
size.width / 2 + size.width * .12 * animation.value,
size.height / 1.3,
);
path.cubicTo(
size.width / 2,
size.height / 1.3,
size.width / 2,
size.height / 1.3,
size.width / 2 - size.width * .01 * animation.value,
size.height / 1.2,
);
path.cubicTo(
size.width / 2 - size.width * .2 * animation.value,
size.height,
size.width / 2,
size.height,
size.width / 2 - size.width * .18 * animation.value,
size.height + 4,
);
if (animation.value > 0) {
canvas.drawPath(path, mapLinePaint);
}
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) =>
(oldDelegate as MapLine).animation != animation;
}