-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvgPath.js
43 lines (36 loc) · 842 Bytes
/
svgPath.js
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
export default class SvgPath {
instructions = [];
add(...values) {
this.instructions.push(values);
}
result() {
return this.instructions.map((arr) => arr.join(" ")).join(",");
}
clone() {
const newPath = new SvgPath();
newPath.instructions = this.instructions.concat([]);
return newPath;
}
move(x, y) {
this.add("M", x, y);
// addDot(x, y);
}
line(x, y) {
this.add("L", x, y);
// addDot(x, y);
}
curve(cp1x, cp1y, cp2x, cp2y, x, y) {
this.add("C", cp1x, cp1y, cp2x, cp2y, x, y);
// addDot(cp1x, cp1y, { color: "green" });
// addDot(cp2x, cp2y, { color: "green" });
// addDot(x, y);
}
scurve(cp2x, cp2y, x, y) {
this.add("S", cp2x, cp2y, x, y);
// addDot(cp2x, cp2y, { color: "green" });
// addDot(x, y);
}
end() {
this.add("Z");
}
}