forked from Moddable-OpenSource/moddable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.js
67 lines (66 loc) · 4.47 KB
/
mod.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import {Outline} from "commodetto/outline";
export default class extends Behavior {
onCreate(shape) {
this.paths = [
Outline.SVGPath(`M10.1,11.1c0-4.4,3.3-7.8,7-7.3l75.4,10.7c4.5,0.7,5.9,7.5,5.9,10.8l0.3,4.8v-6.7c0-3.5-1.1-10.1-5.9-10.9
L16.4,1c-1.8-0.3-2.9,0.2-2.9,0.2c-2.8,1.2-6.4,2.7-6.4,2.7C4.6,5,2.6,7.3,2.6,10.2v83.3c0,3,2.1,5.3,4.5,6.3c0,0,3.6,1.5,6.4,2.7
c0,0,1.1,0.5,2.9,0.2l76.3-11.5c4.8-0.8,5.9-7.4,5.9-10.9v-6.7l-0.3,4.8c0,3.3-1.4,10.2-5.9,10.8L17.1,99.9c-3.7,0.5-7-2.9-7-7.3
V11.1z`),
Outline.SVGPath(`M78.8,65.5h-3.4V48c0-1.8-0.6-3.2-1.7-4.4s-2.6-1.8-4.4-1.8c-2.5,0-4.4,0.9-5.8,2.8c-1.2,1.6-1.8,3.7-1.8,6.2
v14.8h-3.4V48c0-1.8-0.5-3.2-1.6-4.3c-1.2-1.2-2.7-1.9-4.5-1.9c-2.5,0-4.5,0.9-5.8,2.8c-1.2,1.6-1.9,3.7-1.9,6.2v14.8h-3.3V39.7
h3.1l0.2,4c1.7-3.1,4.5-4.7,8.4-4.7c1.9,0,3.6,0.5,5.1,1.4c1.4,1,2.4,2.2,2.8,3.7c2-3.4,5.1-5.2,9.1-5.2c2.6,0,4.7,0.8,6.3,2.3
c1.6,1.5,2.5,3.5,2.5,5.9L78.8,65.5L78.8,65.5z`),
Outline.SV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9,5.6-2.6C220.1,58.9,220.8,56.2,220.8,52.6z`),
Outline.SVGPath(`M241.9,65.2c-1.3,0.4-2.5,0.7-3.7,0.7c-4.8,0-7.2-2.6-7.2-7.8V27.9h3.3v30.2c0,3.3,1.4,5,4.2,5
c0.9,0,1.9-0.2,2.9-0.6L241.9,65.2z`),
Outline.SVGPath(`M266,52.4h-19.4V53c0,3.3,0.8,5.9,2.5,7.8c1.5,1.7,3.6,2.6,6.1,2.6c1.9,0,3.5-0.5,5-1.6
c1.1-0.9,1.9-1.9,2.4-3l3.1,0.7c-0.6,1.7-1.7,3.2-3.4,4.5c-2,1.5-4.4,2.2-7.1,2.2c-3.7,0-6.6-1.2-8.8-3.6s-3.3-5.7-3.3-10
c0-4.1,1.1-7.4,3.2-9.9c2.1-2.5,5-3.7,8.6-3.7c3.3,0,6,1.1,8,3.2c2,2.1,3,5.1,3,8.9L266,52.4L266,52.4z M262.8,50.1
c-0.1-2.5-0.8-4.6-2.1-6.1c-1.4-1.6-3.3-2.4-5.8-2.4c-2.3,0-4.2,0.8-5.7,2.4c-1.5,1.6-2.3,3.6-2.5,6.1H262.8z`),
]
shape.bubble("onLabel", `SVGPath`);
shape.duration = 1000;
this.count = -1;
}
onFinished(shape) {
shape.time = 0;
shape.start();
}
onTimeChanged(shape) {
let count = Math.floor(10 * shape.fraction);
if (this.count != count) {
this.count = count;
let paths = this.paths;
let path = this.paths[0];
let index = 1;
count = Math.min(count, paths.length);
while (index < count) {
path = path.concat(paths[index]);
index++;
}
shape.strokeOutline = Outline.fill(path);
const bounds = shape.strokeOutline.bounds;
shape.strokeOutline.translate((application.width - bounds.width) / 2, (application.height - bounds.height) / 2);
}
}
}