This repository was archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpose_painter.dart
145 lines (135 loc) ยท 3.2 KB
/
pose_painter.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import 'dart:ui';
import 'package:flutter/cupertino.dart';
class PosePainter extends CustomPainter {
final List<Offset> points;
final double ratio;
PosePainter({
required this.points,
required this.ratio,
});
@override
void paint(Canvas canvas, Size size) {
if (points.isNotEmpty) {
var pointPaint = Paint()
..color = CupertinoColors.systemPink
..strokeWidth = 8;
var headPaint = Paint()
..color = CupertinoColors.systemPink
..strokeWidth = 2;
var leftPaint = Paint()
..color = CupertinoColors.systemPink
..strokeWidth = 2;
var rightPaint = Paint()
..color = CupertinoColors.systemPink
..strokeWidth = 2;
var bodyPaint = Paint()
..color = CupertinoColors.systemPink
..strokeWidth = 2;
canvas.drawPoints(
PointMode.points,
points.sublist(0, 33).map((point) => point * ratio).toList(),
pointPaint,
);
canvas.drawPoints(
PointMode.polygon,
[
points[8],
points[6],
points[5],
points[4],
points[0],
points[1],
points[2],
points[3],
points[7],
].map((point) => point * ratio).toList(),
headPaint,
);
canvas.drawPoints(
PointMode.polygon,
[
points[10],
points[9],
].map((point) => point * ratio).toList(),
headPaint,
);
canvas.drawPoints(
PointMode.polygon,
[
points[12],
points[14],
points[16],
points[18],
points[20],
points[16],
].map((point) => point * ratio).toList(),
leftPaint,
);
canvas.drawPoints(
PointMode.polygon,
[
points[16],
points[22],
].map((point) => point * ratio).toList(),
leftPaint,
);
canvas.drawPoints(
PointMode.polygon,
[
points[24],
points[26],
points[28],
points[32],
points[30],
points[28],
].map((point) => point * ratio).toList(),
leftPaint,
);
canvas.drawPoints(
PointMode.polygon,
[
points[11],
points[13],
points[15],
points[17],
points[19],
points[15],
].map((point) => point * ratio).toList(),
rightPaint,
);
canvas.drawPoints(
PointMode.polygon,
[
points[15],
points[21],
].map((point) => point * ratio).toList(),
rightPaint,
);
canvas.drawPoints(
PointMode.polygon,
[
points[23],
points[25],
points[27],
points[29],
points[31],
points[27],
].map((point) => point * ratio).toList(),
rightPaint,
);
canvas.drawPoints(
PointMode.polygon,
[
points[11],
points[12],
points[24],
points[23],
points[11],
].map((point) => point * ratio).toList(),
bodyPaint,
);
}
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => true;
}