forked from Moddable-OpenSource/moddable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.js
36 lines (34 loc) · 733 Bytes
/
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
import {Outline} from "commodetto/outline";
export default class extends Behavior {
onCreate(shape) {
const path = Outline.PolygonPath(
160,70,
131,160,
208,105,
112,105,
189,160);
this.outlines = [
Outline.fill(path, Outline.NON_ZERO_RULE),
Outline.fill(path, Outline.EVEN_ODD_RULE),
];
this.labels = [
"NON_ZERO_RULE",
"EVEN_ODD_RULE",
];
this.index = -1;
shape.duration = 2000;
}
onFinished(shape) {
shape.time = 0;
shape.start();
}
onTimeChanged(shape) {
const c = this.outlines.length;
let i = Math.floor(c * shape.fraction);
if (i == c) i = c - 1;
if (this.index != i) {
shape.strokeOutline = this.outlines[i];
shape.bubble("onLabel", this.labels[i]);
}
}
}