-
Notifications
You must be signed in to change notification settings - Fork 239
/
Copy pathmod.js
38 lines (37 loc) · 991 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
37
38
import {Outline} from "commodetto/outline";
export default class extends Behavior {
onCreate(shape) {
const path = new Outline.FreeTypePath();
path.beginSubpath(80, 110, false);
path.lineTo(160, 30);
path.lineTo(240, 110);
path.lineTo(160, 190);
path.lineTo(80, 110);
path.endSubpath();
this.outlines = [
Outline.stroke(path, 20, Outline.LINECAP_BUTT, Outline.LINEJOIN_ROUND),
Outline.stroke(path, 20, Outline.LINECAP_BUTT, Outline.LINEJOIN_BEVEL),
Outline.stroke(path, 20, Outline.LINECAP_BUTT, Outline.LINEJOIN_MITER),
];
this.labels = [
"LINEJOIN_ROUND",
"LINEJOIN_BEVEL",
"LINEJOIN_MITER",
];
this.index = -1;
shape.duration = 3000;
}
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]);
}
}
}