-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditAnimationKeyframed.ts
50 lines (43 loc) · 1.36 KB
/
EditAnimationKeyframed.ts
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
import {
AnimationBits,
AnimationPreset,
AnimationKeyframed,
} from "@systemic-games/pixels-core-animation";
import { safeAssign } from "@systemic-games/pixels-core-utils";
import EditAnimation, { EditAnimationParams } from "./EditAnimation";
import EditDataSet from "./EditDataSet";
import EditPattern from "./EditPattern";
import { name, observable, widget } from "./decorators";
export default class EditAnimationKeyframed extends EditAnimation {
readonly type = "keyframed";
@widget("rgbPattern")
@name("Color Design")
@observable
pattern?: EditPattern;
constructor(
opt?: EditAnimationParams & {
pattern?: EditPattern;
}
) {
super(opt);
this.pattern = opt?.pattern;
}
toAnimation(editSet: EditDataSet, _bits: AnimationBits): AnimationPreset {
return safeAssign(new AnimationKeyframed(), {
animFlags: this.animFlags ? 1 : 0,
duration: this.duration * 1000, // stored in milliseconds
tracksOffset: editSet.getPatternRGBTrackOffset(this.pattern),
trackCount: this.pattern?.gradients.length ?? 0,
});
}
duplicate(uuid?: string): EditAnimation {
return new EditAnimationKeyframed({
...this,
uuid,
pattern: this.pattern?.duplicate(),
});
}
collectPatterns(): { rgb?: EditPattern[]; grayscale?: EditPattern[] } {
return this.pattern ? { rgb: [this.pattern] } : {};
}
}