canvas-recorder-lib 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/dev/canvas-recorder.css +14 -0
- package/dev/canvas-recorder.ts +379 -45
- package/dev/color-picker.ts +13 -0
- package/dev/component-picker.ts +60 -11
- package/dev/font-widgets.ts +2 -2
- package/dev/format-editor.ts +3 -1
- package/dev/fourier-panel.ts +7 -3
- package/dev/handwriting-panel.ts +7 -7
- package/dev/multi-text-dialog.ts +28 -15
- package/dev/player-body.ts +75 -30
- package/dev/schedule-helpers.ts +10 -3
- package/dev/static-image-panel.ts +4 -4
- package/dev/subtitles.ts +170 -0
- package/dev/synced-file.ts +34 -0
- package/dev/timeline-display.ts +1 -1
- package/dev/transcript-align.ts +4 -1
- package/dev/transcript-editor.ts +1187 -0
- package/dev/transcript-export.ts +90 -0
- package/dev/transcript-view.ts +8 -5
- package/dev/transcripts.ts +140 -15
- package/dev/video-clip-panel.ts +4 -4
- package/dist/dev/canvas-recorder.css +14 -0
- package/dist/dev/canvas-recorder.js +304 -39
- package/dist/dev/canvas-recorder.js.map +1 -1
- package/dist/dev/color-picker.d.ts.map +1 -1
- package/dist/dev/color-picker.js +15 -0
- package/dist/dev/color-picker.js.map +1 -1
- package/dist/dev/component-picker.d.ts +2 -1
- package/dist/dev/component-picker.d.ts.map +1 -1
- package/dist/dev/component-picker.js +56 -11
- package/dist/dev/component-picker.js.map +1 -1
- package/dist/dev/font-widgets.d.ts +2 -2
- package/dist/dev/font-widgets.d.ts.map +1 -1
- package/dist/dev/font-widgets.js.map +1 -1
- package/dist/dev/format-editor.d.ts.map +1 -1
- package/dist/dev/format-editor.js +3 -1
- package/dist/dev/format-editor.js.map +1 -1
- package/dist/dev/fourier-panel.d.ts.map +1 -1
- package/dist/dev/fourier-panel.js +4 -3
- package/dist/dev/fourier-panel.js.map +1 -1
- package/dist/dev/handwriting-panel.d.ts +4 -4
- package/dist/dev/handwriting-panel.d.ts.map +1 -1
- package/dist/dev/handwriting-panel.js.map +1 -1
- package/dist/dev/multi-text-dialog.d.ts.map +1 -1
- package/dist/dev/multi-text-dialog.js +23 -12
- package/dist/dev/multi-text-dialog.js.map +1 -1
- package/dist/dev/player-body.d.ts +1 -1
- package/dist/dev/player-body.d.ts.map +1 -1
- package/dist/dev/player-body.js +75 -30
- package/dist/dev/player-body.js.map +1 -1
- package/dist/dev/schedule-helpers.d.ts.map +1 -1
- package/dist/dev/schedule-helpers.js +4 -2
- package/dist/dev/schedule-helpers.js.map +1 -1
- package/dist/dev/static-image-panel.d.ts +3 -3
- package/dist/dev/static-image-panel.d.ts.map +1 -1
- package/dist/dev/subtitles.d.ts +36 -0
- package/dist/dev/subtitles.d.ts.map +1 -0
- package/dist/dev/subtitles.js +135 -0
- package/dist/dev/subtitles.js.map +1 -0
- package/dist/dev/synced-file.d.ts +14 -0
- package/dist/dev/synced-file.d.ts.map +1 -1
- package/dist/dev/synced-file.js +22 -0
- package/dist/dev/synced-file.js.map +1 -1
- package/dist/dev/timeline-display.d.ts +5 -0
- package/dist/dev/timeline-display.d.ts.map +1 -1
- package/dist/dev/timeline-display.js +1 -1
- package/dist/dev/timeline-display.js.map +1 -1
- package/dist/dev/transcript-align.d.ts +3 -1
- package/dist/dev/transcript-align.d.ts.map +1 -1
- package/dist/dev/transcript-align.js +2 -0
- package/dist/dev/transcript-align.js.map +1 -1
- package/dist/dev/transcript-editor.d.ts +36 -0
- package/dist/dev/transcript-editor.d.ts.map +1 -0
- package/dist/dev/transcript-editor.js +948 -0
- package/dist/dev/transcript-editor.js.map +1 -0
- package/dist/dev/transcript-export.d.ts +21 -0
- package/dist/dev/transcript-export.d.ts.map +1 -1
- package/dist/dev/transcript-export.js +65 -0
- package/dist/dev/transcript-export.js.map +1 -1
- package/dist/dev/transcript-view.d.ts +2 -0
- package/dist/dev/transcript-view.d.ts.map +1 -1
- package/dist/dev/transcript-view.js +1 -1
- package/dist/dev/transcript-view.js.map +1 -1
- package/dist/dev/transcripts.d.ts +18 -1
- package/dist/dev/transcripts.d.ts.map +1 -1
- package/dist/dev/transcripts.js +102 -12
- package/dist/dev/transcripts.js.map +1 -1
- package/dist/dev/video-clip-panel.d.ts +3 -3
- package/dist/dev/video-clip-panel.d.ts.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/src/glib/line-font.d.ts +6 -0
- package/dist/src/glib/line-font.d.ts.map +1 -1
- package/dist/src/glib/line-font.js +9 -0
- package/dist/src/glib/line-font.js.map +1 -1
- package/dist/src/glib/path-shape.d.ts +16 -0
- package/dist/src/glib/path-shape.d.ts.map +1 -1
- package/dist/src/glib/path-shape.js +23 -0
- package/dist/src/glib/path-shape.js.map +1 -1
- package/dist/src/glib/transforms.d.ts +9 -0
- package/dist/src/glib/transforms.d.ts.map +1 -1
- package/dist/src/glib/transforms.js +7 -4
- package/dist/src/glib/transforms.js.map +1 -1
- package/dist/src/interpolate.d.ts +17 -10
- package/dist/src/interpolate.d.ts.map +1 -1
- package/dist/src/interpolate.js +1 -17
- package/dist/src/interpolate.js.map +1 -1
- package/dist/src/morph-animation.js +1 -1
- package/dist/src/morph-animation.js.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.d.ts.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.js +4 -2
- package/dist/src/peano-fourier/fourier-shared.js.map +1 -1
- package/dist/src/schedule-helper.d.ts +50 -28
- package/dist/src/schedule-helper.d.ts.map +1 -1
- package/dist/src/schedule-helper.js +22 -0
- package/dist/src/schedule-helper.js.map +1 -1
- package/dist/src/showable.d.ts +57 -10
- package/dist/src/showable.d.ts.map +1 -1
- package/dist/src/showable.js +19 -0
- package/dist/src/showable.js.map +1 -1
- package/dist/src/slide-components/arrow.d.ts +4 -4
- package/dist/src/slide-components/arrow.d.ts.map +1 -1
- package/dist/src/slide-components/cross-fade-transition.d.ts +2 -1
- package/dist/src/slide-components/cross-fade-transition.d.ts.map +1 -1
- package/dist/src/slide-components/cross-fade-transition.js +2 -1
- package/dist/src/slide-components/cross-fade-transition.js.map +1 -1
- package/dist/src/slide-components/duration-agnostic.d.ts +3 -2
- package/dist/src/slide-components/duration-agnostic.d.ts.map +1 -1
- package/dist/src/slide-components/duration-agnostic.js +4 -2
- package/dist/src/slide-components/duration-agnostic.js.map +1 -1
- package/dist/src/slide-components/fixed-duration.d.ts +3 -1
- package/dist/src/slide-components/fixed-duration.d.ts.map +1 -1
- package/dist/src/slide-components/fixed-duration.js +4 -2
- package/dist/src/slide-components/fixed-duration.js.map +1 -1
- package/dist/src/slide-components/fourier.d.ts +19 -12
- package/dist/src/slide-components/fourier.d.ts.map +1 -1
- package/dist/src/slide-components/fourier.js +70 -22
- package/dist/src/slide-components/fourier.js.map +1 -1
- package/dist/src/slide-components/function-graph.d.ts +4 -3
- package/dist/src/slide-components/function-graph.d.ts.map +1 -1
- package/dist/src/slide-components/function-graph.js +6 -2
- package/dist/src/slide-components/function-graph.js.map +1 -1
- package/dist/src/slide-components/halftone-shadow.d.ts +8 -7
- package/dist/src/slide-components/halftone-shadow.d.ts.map +1 -1
- package/dist/src/slide-components/halftone-shadow.js +2 -1
- package/dist/src/slide-components/halftone-shadow.js.map +1 -1
- package/dist/src/slide-components/handwriting-effect.d.ts +8 -6
- package/dist/src/slide-components/handwriting-effect.d.ts.map +1 -1
- package/dist/src/slide-components/handwriting-effect.js +4 -2
- package/dist/src/slide-components/handwriting-effect.js.map +1 -1
- package/dist/src/slide-components/hold.d.ts +4 -2
- package/dist/src/slide-components/hold.d.ts.map +1 -1
- package/dist/src/slide-components/hold.js +4 -2
- package/dist/src/slide-components/hold.js.map +1 -1
- package/dist/src/slide-components/image.d.ts +7 -7
- package/dist/src/slide-components/image.d.ts.map +1 -1
- package/dist/src/slide-components/image.js +4 -2
- package/dist/src/slide-components/image.js.map +1 -1
- package/dist/src/slide-components/in-parallel.d.ts +6 -3
- package/dist/src/slide-components/in-parallel.d.ts.map +1 -1
- package/dist/src/slide-components/in-parallel.js +12 -2
- package/dist/src/slide-components/in-parallel.js.map +1 -1
- package/dist/src/slide-components/in-series.d.ts +2 -1
- package/dist/src/slide-components/in-series.d.ts.map +1 -1
- package/dist/src/slide-components/in-series.js +2 -1
- package/dist/src/slide-components/in-series.js.map +1 -1
- package/dist/src/slide-components/live-duration.d.ts +3 -1
- package/dist/src/slide-components/live-duration.d.ts.map +1 -1
- package/dist/src/slide-components/live-duration.js +4 -2
- package/dist/src/slide-components/live-duration.js.map +1 -1
- package/dist/src/slide-components/multi-text.d.ts +39 -26
- package/dist/src/slide-components/multi-text.d.ts.map +1 -1
- package/dist/src/slide-components/multi-text.js +44 -29
- package/dist/src/slide-components/multi-text.js.map +1 -1
- package/dist/src/slide-components/rectangle.d.ts +5 -4
- package/dist/src/slide-components/rectangle.d.ts.map +1 -1
- package/dist/src/slide-components/rectangle.js +2 -1
- package/dist/src/slide-components/rectangle.js.map +1 -1
- package/dist/src/slide-components/registry.d.ts +5 -0
- package/dist/src/slide-components/registry.d.ts.map +1 -1
- package/dist/src/slide-components/registry.js +28 -27
- package/dist/src/slide-components/registry.js.map +1 -1
- package/dist/src/slide-components/show-error.d.ts.map +1 -1
- package/dist/src/slide-components/show-error.js +3 -2
- package/dist/src/slide-components/show-error.js.map +1 -1
- package/dist/src/slide-components/simple-text.d.ts +11 -10
- package/dist/src/slide-components/simple-text.d.ts.map +1 -1
- package/dist/src/slide-components/simple-text.js +5 -3
- package/dist/src/slide-components/simple-text.js.map +1 -1
- package/dist/src/slide-components/slide-component.d.ts +14 -13
- package/dist/src/slide-components/slide-component.d.ts.map +1 -1
- package/dist/src/slide-components/slide-component.js +2 -1
- package/dist/src/slide-components/slide-component.js.map +1 -1
- package/dist/src/slide-components/slide-left.d.ts +2 -1
- package/dist/src/slide-components/slide-left.d.ts.map +1 -1
- package/dist/src/slide-components/slide-left.js +2 -1
- package/dist/src/slide-components/slide-left.js.map +1 -1
- package/dist/src/slide-components/text-effect.d.ts +9 -1
- package/dist/src/slide-components/text-effect.d.ts.map +1 -1
- package/dist/src/slide-components/text-effect.js.map +1 -1
- package/dist/src/slide-components/traditional-text.d.ts +8 -8
- package/dist/src/slide-components/traditional-text.d.ts.map +1 -1
- package/dist/src/slide-components/video-clip.d.ts +4 -3
- package/dist/src/slide-components/video-clip.d.ts.map +1 -1
- package/dist/src/slide-components/video-clip.js +2 -1
- package/dist/src/slide-components/video-clip.js.map +1 -1
- package/lib/index.ts +1 -0
- package/package.json +2 -2
- package/src/glib/line-font.ts +9 -0
- package/src/glib/path-shape.ts +35 -0
- package/src/glib/transforms.ts +7 -4
- package/src/interpolate.ts +18 -27
- package/src/morph-animation.ts +1 -1
- package/src/peano-fourier/fourier-shared.ts +4 -2
- package/src/schedule-helper.ts +50 -28
- package/src/showable.ts +79 -10
- package/src/slide-components/arrow.ts +4 -4
- package/src/slide-components/cross-fade-transition.ts +9 -2
- package/src/slide-components/duration-agnostic.ts +4 -3
- package/src/slide-components/fixed-duration.ts +4 -2
- package/src/slide-components/fourier.ts +89 -32
- package/src/slide-components/function-graph.ts +7 -3
- package/src/slide-components/halftone-shadow.ts +9 -7
- package/src/slide-components/handwriting-effect.ts +8 -6
- package/src/slide-components/hold.ts +18 -4
- package/src/slide-components/image.ts +9 -7
- package/src/slide-components/in-parallel.ts +16 -1
- package/src/slide-components/in-series.ts +3 -1
- package/src/slide-components/live-duration.ts +4 -2
- package/src/slide-components/multi-text.ts +71 -44
- package/src/slide-components/rectangle.ts +6 -4
- package/src/slide-components/registry.ts +33 -27
- package/src/slide-components/show-error.ts +4 -2
- package/src/slide-components/simple-text.ts +22 -12
- package/src/slide-components/slide-component.ts +15 -13
- package/src/slide-components/slide-left.ts +9 -2
- package/src/slide-components/text-effect.ts +9 -0
- package/src/slide-components/traditional-text.ts +8 -8
- package/src/slide-components/video-clip.ts +5 -3
package/src/schedule-helper.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
interpolateNumbers,
|
|
8
8
|
interpolatePoints,
|
|
9
9
|
interpolateRects,
|
|
10
|
-
|
|
10
|
+
TimedKeyframe,
|
|
11
11
|
} from "./interpolate.ts";
|
|
12
12
|
import { ReadOnlyRect } from "phil-lib/misc";
|
|
13
13
|
import { Point } from "./glib/path-shape.ts";
|
|
@@ -18,7 +18,9 @@ import { Lattice, LatticeValue } from "./lattice.ts";
|
|
|
18
18
|
|
|
19
19
|
export class StringScheduleInfo {
|
|
20
20
|
readonly type = "string";
|
|
21
|
-
|
|
21
|
+
/** The name the Visual Editor shows, if not `description`. See `ScheduleInfo.label`. */
|
|
22
|
+
label?: string;
|
|
23
|
+
readonly schedule: TimedKeyframe<string>[];
|
|
22
24
|
/**
|
|
23
25
|
* When set, the Visual Editor renders each keyframe value as a combo box
|
|
24
26
|
* (`<input list="…">`) instead of a plain textarea, offering these strings as
|
|
@@ -37,7 +39,7 @@ export class StringScheduleInfo {
|
|
|
37
39
|
at(timeInMs: number): string {
|
|
38
40
|
return discreteKeyframes(timeInMs, this.schedule);
|
|
39
41
|
}
|
|
40
|
-
set(overwriteWith: string | readonly
|
|
42
|
+
set(overwriteWith: string | readonly TimedKeyframe<string>[]) {
|
|
41
43
|
this.schedule.length = 0;
|
|
42
44
|
if (typeof overwriteWith === "string") {
|
|
43
45
|
this.schedule.push({ time: 0, value: overwriteWith });
|
|
@@ -54,7 +56,7 @@ export class StringScheduleInfo {
|
|
|
54
56
|
*/
|
|
55
57
|
constructor(
|
|
56
58
|
readonly description: string,
|
|
57
|
-
schedule:
|
|
59
|
+
schedule: TimedKeyframe<string>[] | string,
|
|
58
60
|
) {
|
|
59
61
|
if (typeof schedule == "string") {
|
|
60
62
|
this.schedule = [{ time: 0, value: schedule }];
|
|
@@ -81,9 +83,13 @@ export class StringScheduleInfo {
|
|
|
81
83
|
*/
|
|
82
84
|
export class SelectScheduleInfo<T extends string, U extends T> {
|
|
83
85
|
readonly type = "select";
|
|
86
|
+
/** What the menu shows for each choice, if not the choice. See `choiceLabel()`. */
|
|
87
|
+
choiceLabels?: Readonly<Record<string, string>>;
|
|
88
|
+
/** The name the Visual Editor shows, if not `description`. See `ScheduleInfo.label`. */
|
|
89
|
+
label?: string;
|
|
84
90
|
readonly choices: readonly T[];
|
|
85
|
-
readonly schedule:
|
|
86
|
-
set(overwriteWith: T | readonly
|
|
91
|
+
readonly schedule: TimedKeyframe<T>[];
|
|
92
|
+
set(overwriteWith: T | readonly TimedKeyframe<T>[]) {
|
|
87
93
|
this.schedule.length = 0;
|
|
88
94
|
if (typeof overwriteWith === "string") {
|
|
89
95
|
this.schedule.push({ time: 0, value: overwriteWith });
|
|
@@ -100,7 +106,7 @@ export class SelectScheduleInfo<T extends string, U extends T> {
|
|
|
100
106
|
*/
|
|
101
107
|
constructor(
|
|
102
108
|
readonly description: string,
|
|
103
|
-
schedule:
|
|
109
|
+
schedule: TimedKeyframe<U>[] | U,
|
|
104
110
|
choices: readonly T[],
|
|
105
111
|
) {
|
|
106
112
|
this.choices = choices.slice();
|
|
@@ -138,11 +144,13 @@ export class SelectScheduleInfo<T extends string, U extends T> {
|
|
|
138
144
|
|
|
139
145
|
export class ColorScheduleInfo {
|
|
140
146
|
readonly type = "color";
|
|
141
|
-
|
|
147
|
+
/** The name the Visual Editor shows, if not `description`. See `ScheduleInfo.label`. */
|
|
148
|
+
label?: string;
|
|
149
|
+
readonly schedule: TimedKeyframe<string>[];
|
|
142
150
|
at(timeInMs: number): string {
|
|
143
151
|
return interpolateColors(timeInMs, this.schedule);
|
|
144
152
|
}
|
|
145
|
-
set(overwriteWith: string | readonly
|
|
153
|
+
set(overwriteWith: string | readonly TimedKeyframe<string>[]) {
|
|
146
154
|
this.schedule.length = 0;
|
|
147
155
|
if (typeof overwriteWith === "string") {
|
|
148
156
|
this.schedule.push({ time: 0, value: overwriteWith });
|
|
@@ -171,7 +179,7 @@ export class ColorScheduleInfo {
|
|
|
171
179
|
*/
|
|
172
180
|
constructor(
|
|
173
181
|
public description: string,
|
|
174
|
-
schedule: readonly
|
|
182
|
+
schedule: readonly TimedKeyframe<string>[] | string | ColorScheduleInfo,
|
|
175
183
|
) {
|
|
176
184
|
if (typeof schedule === "string") {
|
|
177
185
|
this.schedule = [{ time: 0, value: schedule }];
|
|
@@ -185,11 +193,13 @@ export class ColorScheduleInfo {
|
|
|
185
193
|
|
|
186
194
|
export class NumberScheduleInfo {
|
|
187
195
|
readonly type = "number";
|
|
188
|
-
|
|
196
|
+
/** The name the Visual Editor shows, if not `description`. See `ScheduleInfo.label`. */
|
|
197
|
+
label?: string;
|
|
198
|
+
readonly schedule: TimedKeyframe<number>[];
|
|
189
199
|
at(timeInMs: number): number {
|
|
190
200
|
return interpolateNumbers(timeInMs, this.schedule);
|
|
191
201
|
}
|
|
192
|
-
set(overwriteWith: number | readonly
|
|
202
|
+
set(overwriteWith: number | readonly TimedKeyframe<number>[]) {
|
|
193
203
|
this.schedule.length = 0;
|
|
194
204
|
if (typeof overwriteWith === "number") {
|
|
195
205
|
this.schedule.push({ time: 0, value: overwriteWith });
|
|
@@ -208,7 +218,7 @@ export class NumberScheduleInfo {
|
|
|
208
218
|
*/
|
|
209
219
|
constructor(
|
|
210
220
|
readonly description: string,
|
|
211
|
-
schedule:
|
|
221
|
+
schedule: TimedKeyframe<number>[] | number,
|
|
212
222
|
readonly timeAxisLabel?: string,
|
|
213
223
|
) {
|
|
214
224
|
if (typeof schedule === "number") {
|
|
@@ -221,8 +231,10 @@ export class NumberScheduleInfo {
|
|
|
221
231
|
|
|
222
232
|
export class NumberDurationScheduleInfo {
|
|
223
233
|
readonly type = "number";
|
|
234
|
+
/** The name the Visual Editor shows, if not `description`. See `ScheduleInfo.label`. */
|
|
235
|
+
label?: string;
|
|
224
236
|
readonly editDurations = true;
|
|
225
|
-
readonly schedule:
|
|
237
|
+
readonly schedule: TimedKeyframe<number>[];
|
|
226
238
|
at(timeInMs: number) {
|
|
227
239
|
return durationKeyframes(timeInMs, this.schedule);
|
|
228
240
|
}
|
|
@@ -235,7 +247,7 @@ export class NumberDurationScheduleInfo {
|
|
|
235
247
|
*/
|
|
236
248
|
constructor(
|
|
237
249
|
readonly description: string,
|
|
238
|
-
schedule:
|
|
250
|
+
schedule: TimedKeyframe<number>[] | number,
|
|
239
251
|
) {
|
|
240
252
|
if (typeof schedule === "number") {
|
|
241
253
|
this.schedule = [{ time: 0, value: schedule }];
|
|
@@ -246,7 +258,7 @@ export class NumberDurationScheduleInfo {
|
|
|
246
258
|
}
|
|
247
259
|
|
|
248
260
|
export class RectangleScheduleInfo {
|
|
249
|
-
set(overwriteWith: ReadOnlyRect | readonly
|
|
261
|
+
set(overwriteWith: ReadOnlyRect | readonly TimedKeyframe<ReadOnlyRect>[]) {
|
|
250
262
|
this.schedule.length = 0;
|
|
251
263
|
if (overwriteWith instanceof Array) {
|
|
252
264
|
this.schedule.push(...overwriteWith);
|
|
@@ -255,7 +267,9 @@ export class RectangleScheduleInfo {
|
|
|
255
267
|
}
|
|
256
268
|
}
|
|
257
269
|
readonly type = "rectangle";
|
|
258
|
-
|
|
270
|
+
/** The name the Visual Editor shows, if not `description`. See `ScheduleInfo.label`. */
|
|
271
|
+
label?: string;
|
|
272
|
+
readonly schedule: TimedKeyframe<ReadOnlyRect>[];
|
|
259
273
|
at(timeInMs: number): ReadOnlyRect {
|
|
260
274
|
return interpolateRects(timeInMs, this.schedule);
|
|
261
275
|
}
|
|
@@ -268,7 +282,7 @@ export class RectangleScheduleInfo {
|
|
|
268
282
|
*/
|
|
269
283
|
constructor(
|
|
270
284
|
readonly description: string,
|
|
271
|
-
schedule: readonly
|
|
285
|
+
schedule: readonly TimedKeyframe<ReadOnlyRect>[] | ReadOnlyRect,
|
|
272
286
|
) {
|
|
273
287
|
if (schedule instanceof Array) {
|
|
274
288
|
this.schedule = schedule.slice();
|
|
@@ -281,7 +295,7 @@ export class RectangleScheduleInfo {
|
|
|
281
295
|
// MARK: Lattice schedule
|
|
282
296
|
|
|
283
297
|
export class LatticeScheduleInfo {
|
|
284
|
-
set(overwriteWith: LatticeValue | readonly
|
|
298
|
+
set(overwriteWith: LatticeValue | readonly TimedKeyframe<LatticeValue>[]) {
|
|
285
299
|
this.schedule.length = 0;
|
|
286
300
|
if (overwriteWith instanceof Array) {
|
|
287
301
|
this.schedule.push(...overwriteWith);
|
|
@@ -290,7 +304,9 @@ export class LatticeScheduleInfo {
|
|
|
290
304
|
}
|
|
291
305
|
}
|
|
292
306
|
readonly type = "lattice";
|
|
293
|
-
|
|
307
|
+
/** The name the Visual Editor shows, if not `description`. See `ScheduleInfo.label`. */
|
|
308
|
+
label?: string;
|
|
309
|
+
readonly schedule: TimedKeyframe<LatticeValue>[];
|
|
294
310
|
at(timeInMs: number): LatticeValue {
|
|
295
311
|
return interpolateLattices(timeInMs, this.schedule);
|
|
296
312
|
}
|
|
@@ -310,7 +326,7 @@ export class LatticeScheduleInfo {
|
|
|
310
326
|
*/
|
|
311
327
|
constructor(
|
|
312
328
|
readonly description: string,
|
|
313
|
-
schedule: readonly
|
|
329
|
+
schedule: readonly TimedKeyframe<LatticeValue>[] | LatticeValue,
|
|
314
330
|
) {
|
|
315
331
|
if (schedule instanceof Array) {
|
|
316
332
|
this.schedule = schedule.slice();
|
|
@@ -326,7 +342,7 @@ export type ArrowValue = { flat: Point; pointy: Point };
|
|
|
326
342
|
|
|
327
343
|
export function interpolateArrow(
|
|
328
344
|
timeInMs: number,
|
|
329
|
-
schedule: readonly
|
|
345
|
+
schedule: readonly TimedKeyframe<ArrowValue>[],
|
|
330
346
|
): ArrowValue {
|
|
331
347
|
return {
|
|
332
348
|
flat: interpolatePoints(
|
|
@@ -342,11 +358,13 @@ export function interpolateArrow(
|
|
|
342
358
|
|
|
343
359
|
export class ArrowScheduleInfo {
|
|
344
360
|
readonly type = "arrow" as const;
|
|
345
|
-
|
|
361
|
+
/** The name the Visual Editor shows, if not `description`. See `ScheduleInfo.label`. */
|
|
362
|
+
label?: string;
|
|
363
|
+
readonly schedule: TimedKeyframe<ArrowValue>[];
|
|
346
364
|
at(timeInMs: number): ArrowValue {
|
|
347
365
|
return interpolateArrow(timeInMs, this.schedule);
|
|
348
366
|
}
|
|
349
|
-
set(overwriteWith: ArrowValue | readonly
|
|
367
|
+
set(overwriteWith: ArrowValue | readonly TimedKeyframe<ArrowValue>[]) {
|
|
350
368
|
this.schedule.length = 0;
|
|
351
369
|
if (overwriteWith instanceof Array) {
|
|
352
370
|
this.schedule.push(...overwriteWith);
|
|
@@ -356,7 +374,7 @@ export class ArrowScheduleInfo {
|
|
|
356
374
|
}
|
|
357
375
|
constructor(
|
|
358
376
|
readonly description: string,
|
|
359
|
-
schedule: readonly
|
|
377
|
+
schedule: readonly TimedKeyframe<ArrowValue>[] | ArrowValue,
|
|
360
378
|
) {
|
|
361
379
|
if (schedule instanceof Array) {
|
|
362
380
|
this.schedule = schedule.slice();
|
|
@@ -368,11 +386,13 @@ export class ArrowScheduleInfo {
|
|
|
368
386
|
|
|
369
387
|
export class PointScheduleInfo {
|
|
370
388
|
readonly type = "point";
|
|
371
|
-
|
|
389
|
+
/** The name the Visual Editor shows, if not `description`. See `ScheduleInfo.label`. */
|
|
390
|
+
label?: string;
|
|
391
|
+
readonly schedule: TimedKeyframe<Point>[];
|
|
372
392
|
at(timeInMs: number): Point {
|
|
373
393
|
return interpolatePoints(timeInMs, this.schedule);
|
|
374
394
|
}
|
|
375
|
-
set(overwriteWith: Point | readonly
|
|
395
|
+
set(overwriteWith: Point | readonly TimedKeyframe<Point>[]) {
|
|
376
396
|
this.schedule.length = 0;
|
|
377
397
|
if (overwriteWith instanceof Array) {
|
|
378
398
|
this.schedule.push(...overwriteWith);
|
|
@@ -391,7 +411,7 @@ export class PointScheduleInfo {
|
|
|
391
411
|
*/
|
|
392
412
|
constructor(
|
|
393
413
|
readonly description: string,
|
|
394
|
-
schedule: readonly
|
|
414
|
+
schedule: readonly TimedKeyframe<Point>[] | Point,
|
|
395
415
|
) {
|
|
396
416
|
if (schedule instanceof Array) {
|
|
397
417
|
this.schedule = schedule.slice();
|
|
@@ -420,6 +440,8 @@ export class StringScalarInfo implements Scalar<"string"> {
|
|
|
420
440
|
this.#value = newValue;
|
|
421
441
|
}
|
|
422
442
|
readonly type = "string" as const;
|
|
443
|
+
/** The name the Visual Editor shows, if not `description`. See `ScheduleInfo.label`. */
|
|
444
|
+
label?: string;
|
|
423
445
|
constructor(
|
|
424
446
|
readonly description: string,
|
|
425
447
|
initialValue: string,
|
package/src/showable.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { positiveModulo, ReadOnlyRect } from "phil-lib/misc";
|
|
2
|
-
import { ease, easeIn, easeOut,
|
|
2
|
+
import { ease, easeIn, easeOut, TimedKeyframe } from "./interpolate.ts";
|
|
3
3
|
import { Point } from "./glib/path-shape.ts";
|
|
4
4
|
import { LatticeValue } from "./lattice.ts";
|
|
5
5
|
// Type-only, so it is erased at runtime: registry.ts imports this module.
|
|
@@ -199,6 +199,37 @@ export type SoundClip = {
|
|
|
199
199
|
notes?: string;
|
|
200
200
|
};
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* What every component's constructor takes, besides its own properties. The library's
|
|
204
|
+
* components take these in their options object. The base classes, like
|
|
205
|
+
* `InParallelComponent`, take them in place of a name.
|
|
206
|
+
*/
|
|
207
|
+
export type ComponentOptions = {
|
|
208
|
+
/** Its name. Each kind of component has its own default, like "Fourier". */
|
|
209
|
+
readonly description?: string;
|
|
210
|
+
/**
|
|
211
|
+
* The name it's saved under, and its key in `componentRegistry`. Each kind of component
|
|
212
|
+
* has its own default. Give one for a subclass with its own entry in the registry.
|
|
213
|
+
*/
|
|
214
|
+
readonly registryKey?: string;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* `options` with `description` filled in. A string is the description, the way the base
|
|
219
|
+
* classes have always taken it.
|
|
220
|
+
*/
|
|
221
|
+
export function readComponentOptions(
|
|
222
|
+
options: string | ComponentOptions | undefined,
|
|
223
|
+
defaultDescription: string,
|
|
224
|
+
): { description: string; registryKey: string | undefined } {
|
|
225
|
+
const given =
|
|
226
|
+
typeof options === "string" ? { description: options } : options;
|
|
227
|
+
return {
|
|
228
|
+
description: given?.description ?? defaultDescription,
|
|
229
|
+
registryKey: given?.registryKey,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
202
233
|
/**
|
|
203
234
|
* This represents an animation.
|
|
204
235
|
* This might be the entire animation we intend to display or record.
|
|
@@ -519,11 +550,33 @@ export type Showable = {
|
|
|
519
550
|
*/
|
|
520
551
|
export const progressAxisLabel = "Progress (0 - 1)";
|
|
521
552
|
|
|
553
|
+
/** A property's name in the Visual Editor: its {@link ScheduleInfo.label}, or else its description. */
|
|
554
|
+
export function propertyLabel(info: {
|
|
555
|
+
readonly description: string;
|
|
556
|
+
readonly label?: string;
|
|
557
|
+
}): string {
|
|
558
|
+
return info.label ?? info.description;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/** What a menu shows for one of its choices: its label, if it has one, or else the choice. */
|
|
562
|
+
export function choiceLabel(
|
|
563
|
+
info: { readonly choiceLabels?: Readonly<Record<string, string>> },
|
|
564
|
+
choice: string,
|
|
565
|
+
): string {
|
|
566
|
+
return info.choiceLabels?.[choice] ?? choice;
|
|
567
|
+
}
|
|
568
|
+
|
|
522
569
|
export type ScheduleInfo = {
|
|
523
570
|
/**
|
|
524
|
-
*
|
|
571
|
+
* The name it's saved under, and matched by when a save loads. So it (almost) never
|
|
572
|
+
* changes. The Visual Editor shows {@link label} instead, when there is one.
|
|
525
573
|
*/
|
|
526
574
|
readonly description: string;
|
|
575
|
+
/**
|
|
576
|
+
* The name the Visual Editor shows, if it isn't {@link description}. A better name for the
|
|
577
|
+
* screen that doesn't change the save files. See {@link propertyLabel}.
|
|
578
|
+
*/
|
|
579
|
+
label?: string;
|
|
527
580
|
/**
|
|
528
581
|
* If true, the user edits the durations of the schedules.
|
|
529
582
|
* If false, the default, the user edits the start times of the schedule.
|
|
@@ -542,7 +595,7 @@ export type ScheduleInfo = {
|
|
|
542
595
|
// Maybe schedule should actually be a BinaryInserter!!!
|
|
543
596
|
// That might be helpful here and it might help in other places.
|
|
544
597
|
// BinaryInserter isn't necessary here, but it might be useful.
|
|
545
|
-
readonly schedule:
|
|
598
|
+
readonly schedule: TimedKeyframe<string>[];
|
|
546
599
|
/**
|
|
547
600
|
* When set, the Visual Editor renders each keyframe value as a combo box
|
|
548
601
|
* (`<input list="…">`) instead of a plain textarea, offering these strings
|
|
@@ -563,19 +616,30 @@ export type ScheduleInfo = {
|
|
|
563
616
|
| {
|
|
564
617
|
readonly type: "select";
|
|
565
618
|
readonly choices: readonly string[];
|
|
566
|
-
|
|
619
|
+
/**
|
|
620
|
+
* What the menu shows for each choice, if not the choice itself. The choice is what's
|
|
621
|
+
* saved, so it (almost) never changes. See {@link choiceLabel}.
|
|
622
|
+
*/
|
|
623
|
+
choiceLabels?: Readonly<Record<string, string>>;
|
|
624
|
+
readonly schedule: TimedKeyframe<string>[];
|
|
567
625
|
}
|
|
568
626
|
| {
|
|
569
627
|
readonly type: "color";
|
|
570
|
-
readonly schedule:
|
|
628
|
+
readonly schedule: TimedKeyframe<string>[];
|
|
629
|
+
}
|
|
630
|
+
| { readonly type: "number"; readonly schedule: TimedKeyframe<number>[] }
|
|
631
|
+
| {
|
|
632
|
+
readonly type: "rectangle";
|
|
633
|
+
readonly schedule: TimedKeyframe<ReadOnlyRect>[];
|
|
634
|
+
}
|
|
635
|
+
| {
|
|
636
|
+
readonly type: "lattice";
|
|
637
|
+
readonly schedule: TimedKeyframe<LatticeValue>[];
|
|
571
638
|
}
|
|
572
|
-
| { readonly type: "
|
|
573
|
-
| { readonly type: "rectangle"; readonly schedule: Keyframe<ReadOnlyRect>[] }
|
|
574
|
-
| { readonly type: "lattice"; readonly schedule: Keyframe<LatticeValue>[] }
|
|
575
|
-
| { readonly type: "point"; readonly schedule: Keyframe<Point>[] }
|
|
639
|
+
| { readonly type: "point"; readonly schedule: TimedKeyframe<Point>[] }
|
|
576
640
|
| {
|
|
577
641
|
readonly type: "arrow";
|
|
578
|
-
readonly schedule:
|
|
642
|
+
readonly schedule: TimedKeyframe<{ flat: Point; pointy: Point }>[];
|
|
579
643
|
}
|
|
580
644
|
);
|
|
581
645
|
|
|
@@ -587,12 +651,17 @@ export type ScheduleInfo = {
|
|
|
587
651
|
* `value` is intentionally mutable so the Visual Editor can write to it.
|
|
588
652
|
*/
|
|
589
653
|
export type ScalarInfo = {
|
|
654
|
+
/** The name it's saved under. See {@link ScheduleInfo.description}. */
|
|
590
655
|
readonly description: string;
|
|
656
|
+
/** The name the Visual Editor shows. See {@link ScheduleInfo.label}. */
|
|
657
|
+
label?: string;
|
|
591
658
|
} & (
|
|
592
659
|
| { readonly type: "string"; value: string }
|
|
593
660
|
| {
|
|
594
661
|
readonly type: "select";
|
|
595
662
|
readonly choices: readonly string[];
|
|
663
|
+
/** What the menu shows for each choice. See {@link choiceLabel}. */
|
|
664
|
+
choiceLabels?: Readonly<Record<string, string>>;
|
|
596
665
|
value: string;
|
|
597
666
|
}
|
|
598
667
|
| { readonly type: "color"; value: string }
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "../schedule-helper.ts";
|
|
8
8
|
import { ShowOptions } from "../showable.ts";
|
|
9
9
|
import { DurationAgnosticComponent } from "./duration-agnostic.ts";
|
|
10
|
-
import {
|
|
10
|
+
import { TimedKeyframe } from "../interpolate.ts";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Standard registry component: a directed arrow with a rectangular shaft and
|
|
@@ -31,9 +31,9 @@ export class ArrowComponent extends DurationAgnosticComponent {
|
|
|
31
31
|
initialValues: {
|
|
32
32
|
registryKey?: string;
|
|
33
33
|
description?: string;
|
|
34
|
-
arrow?: ArrowValue | readonly
|
|
35
|
-
width?: number | readonly
|
|
36
|
-
color?: string | readonly
|
|
34
|
+
arrow?: ArrowValue | readonly TimedKeyframe<ArrowValue>[];
|
|
35
|
+
width?: number | readonly TimedKeyframe<number>[];
|
|
36
|
+
color?: string | readonly TimedKeyframe<string>[];
|
|
37
37
|
} = {},
|
|
38
38
|
) {
|
|
39
39
|
super(initialValues.description ?? "Arrow");
|
|
@@ -19,9 +19,16 @@ export class CrossFadeTransition
|
|
|
19
19
|
extends ComponentWithLiveDuration
|
|
20
20
|
implements Transition
|
|
21
21
|
{
|
|
22
|
-
readonly registryKey
|
|
23
|
-
constructor(
|
|
22
|
+
readonly registryKey: string;
|
|
23
|
+
constructor(
|
|
24
|
+
options: {
|
|
25
|
+
description?: string;
|
|
26
|
+
registryKey?: string;
|
|
27
|
+
duration?: number;
|
|
28
|
+
} = {},
|
|
29
|
+
) {
|
|
24
30
|
super(options.description ?? "Cross Fade", options.duration ?? 1000);
|
|
31
|
+
this.registryKey = options.registryKey ?? "Cross Fade Transition";
|
|
25
32
|
}
|
|
26
33
|
override show(options: ShowOptions): void {
|
|
27
34
|
showError(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Scalar } from "../showable.ts";
|
|
1
|
+
import { ComponentOptions, readComponentOptions, Scalar } from "../showable.ts";
|
|
2
2
|
import { Mutable } from "../utility.ts";
|
|
3
3
|
import { InParallelComponent, ParallelChildInfo } from "./in-parallel.ts";
|
|
4
4
|
|
|
@@ -24,8 +24,9 @@ export class DurationAgnosticComponent extends InParallelComponent {
|
|
|
24
24
|
this.minDurationScalar.value,
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
/** @param options Its name, or {@link ComponentOptions}. */
|
|
28
|
+
constructor(options: string | ComponentOptions) {
|
|
29
|
+
super(readComponentOptions(options, "Duration Agnostic"));
|
|
29
30
|
this.minDurationScalar = this.makeNotifyingScalar(
|
|
30
31
|
"number",
|
|
31
32
|
"Min Duration",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ComponentOptions, readComponentOptions } from "../showable.ts";
|
|
1
2
|
import { InParallelComponent, ParallelChildInfo } from "./in-parallel.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -17,8 +18,9 @@ export class ComponentWithFixedDuration extends InParallelComponent {
|
|
|
17
18
|
protected override recomputeDuration(children: readonly ParallelChildInfo[]) {
|
|
18
19
|
return this.#requestedDuration;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
/** @param options Its name, or {@link ComponentOptions}. */
|
|
22
|
+
constructor(options: string | ComponentOptions, duration: number) {
|
|
23
|
+
super(readComponentOptions(options, "Fixed Duration"));
|
|
22
24
|
this.#requestedDuration = duration;
|
|
23
25
|
}
|
|
24
26
|
}
|