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
|
@@ -2,7 +2,7 @@ import { ReadOnlyRect, sum } from "phil-lib/misc";
|
|
|
2
2
|
import { myRainbow } from "../glib/my-rainbow.ts";
|
|
3
3
|
import { ParametricFunction, PathShape } from "../glib/path-shape.ts";
|
|
4
4
|
import { panAndZoom } from "../glib/transforms.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { TimedKeyframe } from "../interpolate.ts";
|
|
6
6
|
import {
|
|
7
7
|
Complex,
|
|
8
8
|
FourierTerm,
|
|
@@ -83,16 +83,43 @@ export type TermGroups = {
|
|
|
83
83
|
/** A range like 0-99999 is a typo, not a request. */
|
|
84
84
|
const MAX_RANGE = 10_000;
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* "2", "2 and 3", "3, 5 and 7", "2, 3, 4, 5, 6, 7 and 4 more".
|
|
88
|
+
* Long lists are common here, from pasting over a selection instead of the
|
|
89
|
+
* whole field, so a warning names the first few and counts the rest.
|
|
90
|
+
*/
|
|
91
|
+
function listWithMore(items: readonly number[], shownMax = 6): string {
|
|
92
|
+
const shown = items.slice(0, shownMax).map(String);
|
|
93
|
+
const more = items.length - shown.length;
|
|
94
|
+
if (more > 0) shown.push(`${more} more`);
|
|
95
|
+
const last = shown.pop()!;
|
|
96
|
+
return shown.length ? `${shown.join(", ")} and ${last}` : last;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Where `8-` ends when the source isn't known: the last term of a source made
|
|
101
|
+
* from the default 1024 samples. Terms past a source's end are skipped.
|
|
102
|
+
*/
|
|
103
|
+
const OPEN_RANGE_DEFAULT_TERM_COUNT = 1024;
|
|
104
|
+
|
|
86
105
|
/**
|
|
87
106
|
* Read the Term Groups format: numbers separated by spaces, a comma between
|
|
88
107
|
* groups. `5-9` is short for `5 6 7 8 9`. Each group is one step.
|
|
108
|
+
* `8-` is every term from 8 to the end of the source, so one Term Groups can
|
|
109
|
+
* serve sources with different numbers of terms.
|
|
89
110
|
*
|
|
90
|
-
* For example, `0, 1, 2 3, 4-9
|
|
91
|
-
* terms 2 and 3 together, then terms 4 through 9 together.
|
|
111
|
+
* For example, `0, 1, 2 3, 4-9, 10-` is five steps: add term 0, then term 1,
|
|
112
|
+
* then terms 2 and 3 together, then terms 4 through 9 together, then the rest.
|
|
92
113
|
*
|
|
93
114
|
* Pure.
|
|
115
|
+
* @param termCount How many terms the source has, which is where `8-` ends.
|
|
116
|
+
* Without it, `8-` ends at 1023, and terms past the source's end are skipped
|
|
117
|
+
* later.
|
|
94
118
|
*/
|
|
95
|
-
export function parseTermGroups(
|
|
119
|
+
export function parseTermGroups(
|
|
120
|
+
text: string,
|
|
121
|
+
termCount = OPEN_RANGE_DEFAULT_TERM_COUNT,
|
|
122
|
+
): TermGroups {
|
|
96
123
|
const errors: string[] = [];
|
|
97
124
|
const warnings: string[] = [];
|
|
98
125
|
if (text.trim() === "") return { groups: [], errors, warnings };
|
|
@@ -100,6 +127,8 @@ export function parseTermGroups(text: string): TermGroups {
|
|
|
100
127
|
const emptyGroups: number[] = [];
|
|
101
128
|
/** Where each term was first added, to report repeats. */
|
|
102
129
|
const firstGroup = new Map<number, number>();
|
|
130
|
+
/** Every term listed a second time, in order. One warning covers them all. */
|
|
131
|
+
const repeats: { term: number; earlier: number; groupNumber: number }[] = [];
|
|
103
132
|
const groups = text.split(",").map((piece, groupIndex) => {
|
|
104
133
|
const groupNumber = groupIndex + 1;
|
|
105
134
|
const group: number[] = [];
|
|
@@ -108,11 +137,7 @@ export function parseTermGroups(text: string): TermGroups {
|
|
|
108
137
|
if (earlier === undefined) {
|
|
109
138
|
firstGroup.set(term, groupNumber);
|
|
110
139
|
} else {
|
|
111
|
-
|
|
112
|
-
earlier === groupNumber
|
|
113
|
-
? `Term ${term} is in group ${groupNumber} twice.`
|
|
114
|
-
: `Term ${term} is in group ${earlier} and again in group ${groupNumber}. Terms are only ever added, so the second time does nothing.`,
|
|
115
|
-
);
|
|
140
|
+
repeats.push({ term, earlier, groupNumber });
|
|
116
141
|
}
|
|
117
142
|
group.push(term);
|
|
118
143
|
};
|
|
@@ -123,8 +148,17 @@ export function parseTermGroups(text: string): TermGroups {
|
|
|
123
148
|
for (const token of tokens) {
|
|
124
149
|
const single = /^\d+$/.exec(token);
|
|
125
150
|
const range = /^(\d+)-(\d+)$/.exec(token);
|
|
151
|
+
const openRange = /^(\d+)-$/.exec(token);
|
|
126
152
|
if (single) {
|
|
127
153
|
add(Number(token));
|
|
154
|
+
} else if (openRange) {
|
|
155
|
+
const from = Number(openRange[1]);
|
|
156
|
+
if (from >= termCount) {
|
|
157
|
+
warnings.push(
|
|
158
|
+
`"${token}" adds nothing: this source's last term is ${termCount - 1}.`,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
for (let term = from; term < termCount; term++) add(term);
|
|
128
162
|
} else if (range) {
|
|
129
163
|
const from = Number(range[1]);
|
|
130
164
|
const to = Number(range[2]);
|
|
@@ -136,18 +170,28 @@ export function parseTermGroups(text: string): TermGroups {
|
|
|
136
170
|
for (let term = from; term <= to; term++) add(term);
|
|
137
171
|
}
|
|
138
172
|
} else {
|
|
139
|
-
errors.push(
|
|
173
|
+
errors.push(
|
|
174
|
+
`"${token}" isn't a term number or a range like 5-9 or 8-.`,
|
|
175
|
+
);
|
|
140
176
|
}
|
|
141
177
|
}
|
|
142
178
|
return group;
|
|
143
179
|
});
|
|
180
|
+
if (repeats.length) {
|
|
181
|
+
const [{ term, earlier, groupNumber }] = repeats;
|
|
182
|
+
const where =
|
|
183
|
+
earlier === groupNumber
|
|
184
|
+
? `is in group ${groupNumber} twice`
|
|
185
|
+
: `is in group ${earlier} and again in group ${groupNumber}`;
|
|
186
|
+
warnings.push(
|
|
187
|
+
repeats.length === 1
|
|
188
|
+
? `Term ${term} ${where}. Terms are only ever added, so the second time does nothing.`
|
|
189
|
+
: `Terms ${listWithMore(repeats.map((repeat) => repeat.term))} are each listed twice. ` +
|
|
190
|
+
`Terms are only ever added, so the second time does nothing. The first, ${term}, ${where}.`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
144
193
|
if (emptyGroups.length) {
|
|
145
|
-
|
|
146
|
-
const shown = emptyGroups.slice(0, 6).map(String);
|
|
147
|
-
const more = emptyGroups.length - shown.length;
|
|
148
|
-
if (more > 0) shown.push(`${more} more`);
|
|
149
|
-
const last = shown.pop()!;
|
|
150
|
-
const list = shown.length ? `${shown.join(", ")} and ${last}` : last;
|
|
194
|
+
const list = listWithMore(emptyGroups);
|
|
151
195
|
const one = emptyGroups.length === 1;
|
|
152
196
|
warnings.push(
|
|
153
197
|
`${one ? "Group" : "Groups"} ${list} ${one ? "is" : "are"} empty, so ${one ? "that step adds" : "those steps add"} nothing.`,
|
|
@@ -173,11 +217,9 @@ export function checkTermGroups(
|
|
|
173
217
|
}
|
|
174
218
|
if (missing.size) {
|
|
175
219
|
const list = [...missing].sort((a, b) => a - b);
|
|
176
|
-
const shown =
|
|
177
|
-
list.length > 6 ? `${list.slice(0, 6).join(", ")}, …` : list.join(", ");
|
|
178
220
|
warnings.push(
|
|
179
221
|
`This source has ${terms.length} terms, numbered 0 to ${terms.length - 1}. ` +
|
|
180
|
-
`Left out: ${
|
|
222
|
+
`Left out: ${listWithMore(list)}.`,
|
|
181
223
|
);
|
|
182
224
|
}
|
|
183
225
|
// The frequency 0 term is the shape's center. samplesToFourier() leaves it
|
|
@@ -240,7 +282,7 @@ export function orderTerms(
|
|
|
240
282
|
* Pure.
|
|
241
283
|
*/
|
|
242
284
|
export function checkStepRange(
|
|
243
|
-
step: readonly
|
|
285
|
+
step: readonly TimedKeyframe<number>[],
|
|
244
286
|
groupCount: number,
|
|
245
287
|
): string[] {
|
|
246
288
|
const shown = step.map(({ value }) => value).filter((value) => value >= 0);
|
|
@@ -308,7 +350,7 @@ function boundsOf(samples: readonly Complex[]): ReadOnlyRect {
|
|
|
308
350
|
* away and starts over, which is fine as long as it's rare.
|
|
309
351
|
*/
|
|
310
352
|
export class FourierComponent extends DurationAgnosticComponent {
|
|
311
|
-
readonly registryKey
|
|
353
|
+
readonly registryKey: string;
|
|
312
354
|
|
|
313
355
|
/**
|
|
314
356
|
* The curves the Source field can choose from, by name.
|
|
@@ -356,18 +398,20 @@ export class FourierComponent extends DurationAgnosticComponent {
|
|
|
356
398
|
constructor(
|
|
357
399
|
initialValues: {
|
|
358
400
|
description?: string;
|
|
401
|
+
registryKey?: string;
|
|
359
402
|
source?: string;
|
|
360
|
-
termGroups?: string |
|
|
361
|
-
step?: number |
|
|
362
|
-
destRect?: ReadOnlyRect |
|
|
363
|
-
fillColor?: string |
|
|
364
|
-
strokeColor?: string |
|
|
365
|
-
lineWidth?: number |
|
|
403
|
+
termGroups?: string | TimedKeyframe<string>[];
|
|
404
|
+
step?: number | TimedKeyframe<number>[];
|
|
405
|
+
destRect?: ReadOnlyRect | TimedKeyframe<ReadOnlyRect>[];
|
|
406
|
+
fillColor?: string | TimedKeyframe<string>[];
|
|
407
|
+
strokeColor?: string | TimedKeyframe<string>[];
|
|
408
|
+
lineWidth?: number | TimedKeyframe<number>[];
|
|
366
409
|
/** How long to ask the parent for. The default covers the default Step schedule. */
|
|
367
410
|
minDuration?: number;
|
|
368
411
|
} = {},
|
|
369
412
|
) {
|
|
370
413
|
super(initialValues.description ?? "Fourier");
|
|
414
|
+
this.registryKey = initialValues.registryKey ?? "Fourier";
|
|
371
415
|
const names = [...FourierComponent.sources.keys()];
|
|
372
416
|
this.sourceSchedule = new SelectScheduleInfo(
|
|
373
417
|
"Source",
|
|
@@ -465,7 +509,7 @@ export class FourierComponent extends DurationAgnosticComponent {
|
|
|
465
509
|
return cached;
|
|
466
510
|
const source = this.termsFor(name);
|
|
467
511
|
if (typeof source === "string") return source;
|
|
468
|
-
const { groups } = parseTermGroups(termGroups);
|
|
512
|
+
const { groups } = parseTermGroups(termGroups, source.terms.length);
|
|
469
513
|
const ordered = orderTerms(source.terms, groups);
|
|
470
514
|
const rules =
|
|
471
515
|
ordered.keyframes.length < 2
|
|
@@ -510,6 +554,7 @@ export class FourierComponent extends DurationAgnosticComponent {
|
|
|
510
554
|
/**
|
|
511
555
|
* Draw the curve: fill, then stroke. It's already in place, in canvas
|
|
512
556
|
* coordinates, so the line width isn't affected by the curve's scale.
|
|
557
|
+
* A Line Width of 0 draws no line, and a transparent Fill Color no fill.
|
|
513
558
|
*
|
|
514
559
|
* Override this to draw it differently, e.g. stroked with strokeColors()
|
|
515
560
|
* like the Sierpiński video.
|
|
@@ -524,9 +569,13 @@ export class FourierComponent extends DurationAgnosticComponent {
|
|
|
524
569
|
// itself, the fill alternates instead of piling up.
|
|
525
570
|
context.fill(path, "evenodd");
|
|
526
571
|
}
|
|
572
|
+
const lineWidth = this.lineWidthSchedule.at(timeInMs);
|
|
573
|
+
// The canvas ignores a width of 0 or less, and would stroke at whatever
|
|
574
|
+
// width came before. 0 means no line.
|
|
575
|
+
if (!(lineWidth > 0)) return;
|
|
527
576
|
context.lineCap = "round";
|
|
528
577
|
context.lineJoin = "round";
|
|
529
|
-
context.lineWidth =
|
|
578
|
+
context.lineWidth = lineWidth;
|
|
530
579
|
context.strokeStyle = this.strokeColorSchedule.at(timeInMs);
|
|
531
580
|
context.stroke(path);
|
|
532
581
|
}
|
|
@@ -536,9 +585,17 @@ export class FourierComponent extends DurationAgnosticComponent {
|
|
|
536
585
|
|
|
537
586
|
// Cheap to create: nothing is computed until a component draws one.
|
|
538
587
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
588
|
+
{
|
|
589
|
+
let star: PathShape | undefined;
|
|
590
|
+
FourierComponent.sources.set("Star", {
|
|
591
|
+
// A getter, so it's made on first use. DOMMatrix doesn't exist in Node.
|
|
592
|
+
get path() {
|
|
593
|
+
return (star ??= makePolygon(5, 1, undefined, 0).transform(
|
|
594
|
+
new DOMMatrix().rotate(-90),
|
|
595
|
+
));
|
|
596
|
+
},
|
|
597
|
+
});
|
|
598
|
+
}
|
|
542
599
|
FourierComponent.sources.set("Square", {
|
|
543
600
|
path: "M -1,-1 L 1,-1 L 1,1 L -1,1 Z",
|
|
544
601
|
});
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
NumberScheduleInfo,
|
|
7
7
|
ColorScheduleInfo,
|
|
8
8
|
} from "../schedule-helper.ts";
|
|
9
|
-
import { Showable, ShowOptions } from "../showable.ts";
|
|
9
|
+
import { ComponentOptions, Showable, ShowOptions } from "../showable.ts";
|
|
10
10
|
import { showError } from "./show-error.ts";
|
|
11
11
|
|
|
12
12
|
export class FunctionGraphComponent implements Showable {
|
|
@@ -21,9 +21,13 @@ export class FunctionGraphComponent implements Showable {
|
|
|
21
21
|
*/
|
|
22
22
|
static readonly functions = new Map<string, (x: number) => number>();
|
|
23
23
|
|
|
24
|
-
readonly registryKey
|
|
25
|
-
readonly description
|
|
24
|
+
readonly registryKey: string;
|
|
25
|
+
readonly description: string;
|
|
26
26
|
readonly duration = 0;
|
|
27
|
+
constructor(options: ComponentOptions = {}) {
|
|
28
|
+
this.description = options.description ?? "Function Graph";
|
|
29
|
+
this.registryKey = options.registryKey ?? "Function Graph";
|
|
30
|
+
}
|
|
27
31
|
|
|
28
32
|
readonly functionNameSchedule = new StringScheduleInfo(
|
|
29
33
|
"Function Name",
|
|
@@ -2,7 +2,7 @@ import { canvasRecorder } from "../../lib/main-control.ts";
|
|
|
2
2
|
import { ColorScheduleInfo, NumberScheduleInfo } from "../schedule-helper.ts";
|
|
3
3
|
import { Showable, ShowOptions } from "../showable.ts";
|
|
4
4
|
import { InParallelComponent } from "./in-parallel.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { TimedKeyframe } from "../interpolate.ts";
|
|
6
6
|
|
|
7
7
|
/** At 100% opacity the dot radius reaches this fraction of the half-cell width. */
|
|
8
8
|
const HALFTONE_MAX_RADIUS_FACTOR = 0.9;
|
|
@@ -20,7 +20,7 @@ const HALFTONE_MAX_RADIUS_FACTOR = 0.9;
|
|
|
20
20
|
* Showable in the constructor to add it as a fixed child.
|
|
21
21
|
*/
|
|
22
22
|
export class HalftoneShadowComponent extends InParallelComponent {
|
|
23
|
-
readonly registryKey
|
|
23
|
+
readonly registryKey: string;
|
|
24
24
|
readonly dotColorSchedule = new ColorScheduleInfo("Dot Color", "#ccc");
|
|
25
25
|
readonly backgroundColorSchedule = new ColorScheduleInfo(
|
|
26
26
|
"Background Color",
|
|
@@ -39,11 +39,12 @@ export class HalftoneShadowComponent extends InParallelComponent {
|
|
|
39
39
|
initialValues: {
|
|
40
40
|
base?: Showable;
|
|
41
41
|
description?: string;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
registryKey?: string;
|
|
43
|
+
dotColor?: string | readonly TimedKeyframe<string>[];
|
|
44
|
+
backgroundColor?: string | readonly TimedKeyframe<string>[];
|
|
45
|
+
dx?: number | readonly TimedKeyframe<number>[];
|
|
46
|
+
dy?: number | readonly TimedKeyframe<number>[];
|
|
47
|
+
period?: number | readonly TimedKeyframe<number>[];
|
|
47
48
|
} = {},
|
|
48
49
|
) {
|
|
49
50
|
const { base } = initialValues;
|
|
@@ -51,6 +52,7 @@ export class HalftoneShadowComponent extends InParallelComponent {
|
|
|
51
52
|
initialValues.description ??
|
|
52
53
|
(base ? `${base.description} » shadow` : "Halftone Shadow"),
|
|
53
54
|
);
|
|
55
|
+
this.registryKey = initialValues.registryKey ?? "Halftone Shadow";
|
|
54
56
|
this.schedules.push(
|
|
55
57
|
this.dotColorSchedule,
|
|
56
58
|
this.backgroundColorSchedule,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { Command, PathShape } from "../glib/path-shape.ts";
|
|
4
4
|
import { PathShapeSplitter } from "../glib/path-shape-splitter.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { TimedKeyframe } from "../interpolate.ts";
|
|
6
6
|
import { NumberScheduleInfo } from "../schedule-helper.ts";
|
|
7
|
-
import { Scalar, ShowOptions } from "../showable.ts";
|
|
7
|
+
import { ComponentOptions, Scalar, ShowOptions } from "../showable.ts";
|
|
8
8
|
import { showError } from "./show-error.ts";
|
|
9
9
|
import { EffectLetter, TEXT_EFFECT, TextEffect } from "./text-effect.ts";
|
|
10
10
|
|
|
@@ -172,7 +172,7 @@ export function handwritingPaths(
|
|
|
172
172
|
* resize as it's written.
|
|
173
173
|
*/
|
|
174
174
|
export class HandwritingEffectComponent implements TextEffect {
|
|
175
|
-
readonly registryKey
|
|
175
|
+
readonly registryKey: string;
|
|
176
176
|
/** What one step of Progress means. See {@link HANDWRITING_DIVISIONS}. */
|
|
177
177
|
readonly divisionsScalar: Scalar<"select"> = {
|
|
178
178
|
description: "Divisions",
|
|
@@ -190,14 +190,16 @@ export class HandwritingEffectComponent implements TextEffect {
|
|
|
190
190
|
{ time: 3000, value: 1 },
|
|
191
191
|
]);
|
|
192
192
|
readonly schedules = [this.progressSchedule] as const;
|
|
193
|
-
readonly description
|
|
193
|
+
readonly description: string;
|
|
194
194
|
readonly duration = 0;
|
|
195
195
|
constructor(
|
|
196
196
|
initialValues: {
|
|
197
197
|
divisions?: HandwritingDivision;
|
|
198
|
-
progress?: number | readonly
|
|
199
|
-
} = {},
|
|
198
|
+
progress?: number | readonly TimedKeyframe<number>[];
|
|
199
|
+
} & ComponentOptions = {},
|
|
200
200
|
) {
|
|
201
|
+
this.description = initialValues.description ?? "Handwriting Effect";
|
|
202
|
+
this.registryKey = initialValues.registryKey ?? "Handwriting Effect";
|
|
201
203
|
if (initialValues.divisions !== undefined)
|
|
202
204
|
this.divisionsScalar.value = initialValues.divisions;
|
|
203
205
|
if (initialValues.progress !== undefined)
|
|
@@ -15,10 +15,17 @@ export class HoldPreviousTransition
|
|
|
15
15
|
extends ComponentWithLiveDuration
|
|
16
16
|
implements Transition
|
|
17
17
|
{
|
|
18
|
-
readonly registryKey
|
|
18
|
+
readonly registryKey: string;
|
|
19
19
|
override readonly replaceableComponents = undefined;
|
|
20
|
-
constructor(
|
|
20
|
+
constructor(
|
|
21
|
+
options: {
|
|
22
|
+
description?: string;
|
|
23
|
+
registryKey?: string;
|
|
24
|
+
duration?: number;
|
|
25
|
+
} = {},
|
|
26
|
+
) {
|
|
21
27
|
super(options.description ?? "Hold Previous", options.duration ?? 1000);
|
|
28
|
+
this.registryKey = options.registryKey ?? "Hold Previous";
|
|
22
29
|
}
|
|
23
30
|
override show(options: ShowOptions): void {
|
|
24
31
|
showError(
|
|
@@ -49,10 +56,17 @@ export class HoldNextTransition
|
|
|
49
56
|
extends ComponentWithLiveDuration
|
|
50
57
|
implements Transition
|
|
51
58
|
{
|
|
52
|
-
readonly registryKey
|
|
59
|
+
readonly registryKey: string;
|
|
53
60
|
override readonly replaceableComponents = undefined;
|
|
54
|
-
constructor(
|
|
61
|
+
constructor(
|
|
62
|
+
options: {
|
|
63
|
+
description?: string;
|
|
64
|
+
registryKey?: string;
|
|
65
|
+
duration?: number;
|
|
66
|
+
} = {},
|
|
67
|
+
) {
|
|
55
68
|
super(options.description ?? "Hold Next", options.duration ?? 1000);
|
|
69
|
+
this.registryKey = options.registryKey ?? "Hold Next";
|
|
56
70
|
}
|
|
57
71
|
override show(options: ShowOptions): void {
|
|
58
72
|
showError(
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
StringScheduleInfo,
|
|
4
4
|
RectangleScheduleInfo,
|
|
5
5
|
} from "../schedule-helper.ts";
|
|
6
|
-
import { Showable, ShowOptions } from "../showable.ts";
|
|
6
|
+
import { ComponentOptions, Showable, ShowOptions } from "../showable.ts";
|
|
7
7
|
import { SingleImage, SlowImage } from "../slow-image-sources.ts";
|
|
8
|
-
import {
|
|
8
|
+
import { TimedKeyframe } from "../interpolate.ts";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Standard registry component: draws a single image loaded from a URL.
|
|
@@ -18,7 +18,7 @@ import { Keyframe } from "../interpolate.ts";
|
|
|
18
18
|
* load. The dest-rect schedule is interpolated so you can animate placement.
|
|
19
19
|
*/
|
|
20
20
|
export class SingleImageComponent implements Showable {
|
|
21
|
-
readonly registryKey
|
|
21
|
+
readonly registryKey: string;
|
|
22
22
|
readonly urlSchedule = new StringScheduleInfo("URL", "");
|
|
23
23
|
readonly destRectSchedule = new RectangleScheduleInfo("Dest Rect", {
|
|
24
24
|
x: 1,
|
|
@@ -27,15 +27,17 @@ export class SingleImageComponent implements Showable {
|
|
|
27
27
|
height: 7,
|
|
28
28
|
});
|
|
29
29
|
readonly schedules = [this.urlSchedule, this.destRectSchedule] as const;
|
|
30
|
-
readonly description
|
|
30
|
+
readonly description: string;
|
|
31
31
|
readonly duration = 0;
|
|
32
32
|
#image: SingleImage | undefined;
|
|
33
33
|
constructor(
|
|
34
34
|
initialValues: {
|
|
35
|
-
url?: string | readonly
|
|
36
|
-
destRect?: ReadOnlyRect | readonly
|
|
37
|
-
} = {},
|
|
35
|
+
url?: string | readonly TimedKeyframe<string>[];
|
|
36
|
+
destRect?: ReadOnlyRect | readonly TimedKeyframe<ReadOnlyRect>[];
|
|
37
|
+
} & ComponentOptions = {},
|
|
38
38
|
) {
|
|
39
|
+
this.description = initialValues.description ?? "Static Image";
|
|
40
|
+
this.registryKey = initialValues.registryKey ?? "Static Image";
|
|
39
41
|
if (initialValues.url !== undefined) {
|
|
40
42
|
this.urlSchedule.set(initialValues.url);
|
|
41
43
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BinaryInserter } from "../binary-search.ts";
|
|
2
2
|
import {
|
|
3
|
+
ComponentOptions,
|
|
4
|
+
readComponentOptions,
|
|
3
5
|
Scalar,
|
|
4
6
|
ScalarInfo,
|
|
5
7
|
ScheduleInfo,
|
|
@@ -151,7 +153,20 @@ export class InParallelComponent implements Showable, ShowableParent {
|
|
|
151
153
|
* TextComponent and ArrowComponent both set this to `undefined` to make show() simpler.
|
|
152
154
|
*/
|
|
153
155
|
readonly replaceableComponents: Showable["replaceableComponents"];
|
|
154
|
-
|
|
156
|
+
readonly description: string;
|
|
157
|
+
/**
|
|
158
|
+
* @param options Its name, or {@link ComponentOptions}: its name and its registry key.
|
|
159
|
+
*/
|
|
160
|
+
constructor(options: string | ComponentOptions) {
|
|
161
|
+
const { description, registryKey } = readComponentOptions(
|
|
162
|
+
options,
|
|
163
|
+
"In Parallel",
|
|
164
|
+
);
|
|
165
|
+
this.description = description;
|
|
166
|
+
// Not a declared member: then every subclass that has its own registryKey, in this library
|
|
167
|
+
// and in projects, would need `override` (noImplicitOverride). A subclass's own field
|
|
168
|
+
// still wins, since fields are set after this constructor runs.
|
|
169
|
+
if (registryKey !== undefined) (this as Showable).registryKey = registryKey;
|
|
155
170
|
const get = (): Showable[] => [...this.#replaceableChildren];
|
|
156
171
|
const replace = (newItems: readonly Showable[]) => {
|
|
157
172
|
this.#replaceableChildren.forEach((child) => {
|
|
@@ -38,13 +38,15 @@ import type { ComponentRegistryEntry } from "./registry.ts";
|
|
|
38
38
|
*/
|
|
39
39
|
export class InSeriesComponent extends InParallelComponent {
|
|
40
40
|
static readonly TRANSITION = Symbol("Transition");
|
|
41
|
-
readonly registryKey
|
|
41
|
+
readonly registryKey: string;
|
|
42
42
|
constructor(
|
|
43
43
|
initialValues: {
|
|
44
44
|
description?: string;
|
|
45
|
+
registryKey?: string;
|
|
45
46
|
} = {},
|
|
46
47
|
) {
|
|
47
48
|
super(initialValues.description ?? "In Series");
|
|
49
|
+
this.registryKey = initialValues.registryKey ?? "In Series";
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* Display the children one after another, sorted by zIndex.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ComponentOptions, readComponentOptions } from "../showable.ts";
|
|
1
2
|
import { InParallelComponent, ParallelChildInfo } from "./in-parallel.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -24,8 +25,9 @@ export class ComponentWithLiveDuration extends InParallelComponent {
|
|
|
24
25
|
protected override recomputeDuration(children: readonly ParallelChildInfo[]) {
|
|
25
26
|
return this.#requestedDuration;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
/** @param options Its name, or {@link ComponentOptions}. */
|
|
29
|
+
constructor(options: string | ComponentOptions, duration: number) {
|
|
30
|
+
super(readComponentOptions(options, "Live Duration"));
|
|
29
31
|
this.#requestedDuration = duration;
|
|
30
32
|
}
|
|
31
33
|
}
|