canvas-recorder-lib 0.8.1 → 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 +20 -6
- package/dev/canvas-recorder.ts +389 -54
- package/dev/color-picker.ts +13 -0
- package/dev/component-picker.ts +60 -11
- package/dev/delay-files.ts +3 -1
- 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 +78 -33
- 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/transcribe-core.ts +7 -4
- package/dev/transcript-align.ts +24 -18
- 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 +20 -6
- package/dist/dev/canvas-recorder.js +314 -48
- 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/delay-files.d.ts.map +1 -1
- package/dist/dev/delay-files.js +3 -1
- package/dist/dev/delay-files.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 +78 -33
- 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/transcribe-core.d.ts.map +1 -1
- package/dist/dev/transcribe-core.js +7 -4
- package/dist/dev/transcribe-core.js.map +1 -1
- package/dist/dev/transcript-align.d.ts +6 -4
- package/dist/dev/transcript-align.d.ts.map +1 -1
- package/dist/dev/transcript-align.js +18 -13
- 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 +23 -0
- package/dist/src/glib/path-shape.d.ts.map +1 -1
- package/dist/src/glib/path-shape.js +66 -221
- package/dist/src/glib/path-shape.js.map +1 -1
- package/dist/src/glib/svg-arc.d.ts +41 -0
- package/dist/src/glib/svg-arc.d.ts.map +1 -0
- package/dist/src/glib/svg-arc.js +114 -0
- package/dist/src/glib/svg-arc.js.map +1 -0
- package/dist/src/glib/svg-path-parser.d.ts +60 -0
- package/dist/src/glib/svg-path-parser.d.ts.map +1 -0
- package/dist/src/glib/svg-path-parser.js +258 -0
- package/dist/src/glib/svg-path-parser.js.map +1 -0
- 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 +77 -16
- 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 +14 -10
- 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 +12 -4
- 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 +101 -245
- package/src/glib/svg-arc.ts +141 -0
- package/src/glib/svg-path-parser.ts +308 -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 +98 -29
- package/src/slide-components/function-graph.ts +7 -3
- package/src/slide-components/halftone-shadow.ts +21 -16
- 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 +13 -4
- 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,21 +83,52 @@ 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 };
|
|
126
|
+
/** Empty groups are common, to keep several Fouriers in step. One warning covers them all. */
|
|
127
|
+
const emptyGroups: number[] = [];
|
|
99
128
|
/** Where each term was first added, to report repeats. */
|
|
100
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 }[] = [];
|
|
101
132
|
const groups = text.split(",").map((piece, groupIndex) => {
|
|
102
133
|
const groupNumber = groupIndex + 1;
|
|
103
134
|
const group: number[] = [];
|
|
@@ -106,25 +137,28 @@ export function parseTermGroups(text: string): TermGroups {
|
|
|
106
137
|
if (earlier === undefined) {
|
|
107
138
|
firstGroup.set(term, groupNumber);
|
|
108
139
|
} else {
|
|
109
|
-
|
|
110
|
-
earlier === groupNumber
|
|
111
|
-
? `Term ${term} is in group ${groupNumber} twice.`
|
|
112
|
-
: `Term ${term} is in group ${earlier} and again in group ${groupNumber}. Terms are only ever added, so the second time does nothing.`,
|
|
113
|
-
);
|
|
140
|
+
repeats.push({ term, earlier, groupNumber });
|
|
114
141
|
}
|
|
115
142
|
group.push(term);
|
|
116
143
|
};
|
|
117
144
|
const tokens = piece.trim().split(/\s+/).filter(Boolean);
|
|
118
145
|
if (tokens.length === 0) {
|
|
119
|
-
|
|
120
|
-
`Group ${groupNumber} is empty, so that step adds nothing.`,
|
|
121
|
-
);
|
|
146
|
+
emptyGroups.push(groupNumber);
|
|
122
147
|
}
|
|
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,11 +170,33 @@ 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
|
+
}
|
|
193
|
+
if (emptyGroups.length) {
|
|
194
|
+
const list = listWithMore(emptyGroups);
|
|
195
|
+
const one = emptyGroups.length === 1;
|
|
196
|
+
warnings.push(
|
|
197
|
+
`${one ? "Group" : "Groups"} ${list} ${one ? "is" : "are"} empty, so ${one ? "that step adds" : "those steps add"} nothing.`,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
144
200
|
return { groups, errors, warnings };
|
|
145
201
|
}
|
|
146
202
|
|
|
@@ -161,11 +217,9 @@ export function checkTermGroups(
|
|
|
161
217
|
}
|
|
162
218
|
if (missing.size) {
|
|
163
219
|
const list = [...missing].sort((a, b) => a - b);
|
|
164
|
-
const shown =
|
|
165
|
-
list.length > 6 ? `${list.slice(0, 6).join(", ")}, …` : list.join(", ");
|
|
166
220
|
warnings.push(
|
|
167
221
|
`This source has ${terms.length} terms, numbered 0 to ${terms.length - 1}. ` +
|
|
168
|
-
`Left out: ${
|
|
222
|
+
`Left out: ${listWithMore(list)}.`,
|
|
169
223
|
);
|
|
170
224
|
}
|
|
171
225
|
// The frequency 0 term is the shape's center. samplesToFourier() leaves it
|
|
@@ -228,7 +282,7 @@ export function orderTerms(
|
|
|
228
282
|
* Pure.
|
|
229
283
|
*/
|
|
230
284
|
export function checkStepRange(
|
|
231
|
-
step: readonly
|
|
285
|
+
step: readonly TimedKeyframe<number>[],
|
|
232
286
|
groupCount: number,
|
|
233
287
|
): string[] {
|
|
234
288
|
const shown = step.map(({ value }) => value).filter((value) => value >= 0);
|
|
@@ -296,7 +350,7 @@ function boundsOf(samples: readonly Complex[]): ReadOnlyRect {
|
|
|
296
350
|
* away and starts over, which is fine as long as it's rare.
|
|
297
351
|
*/
|
|
298
352
|
export class FourierComponent extends DurationAgnosticComponent {
|
|
299
|
-
readonly registryKey
|
|
353
|
+
readonly registryKey: string;
|
|
300
354
|
|
|
301
355
|
/**
|
|
302
356
|
* The curves the Source field can choose from, by name.
|
|
@@ -344,18 +398,20 @@ export class FourierComponent extends DurationAgnosticComponent {
|
|
|
344
398
|
constructor(
|
|
345
399
|
initialValues: {
|
|
346
400
|
description?: string;
|
|
401
|
+
registryKey?: string;
|
|
347
402
|
source?: string;
|
|
348
|
-
termGroups?: string |
|
|
349
|
-
step?: number |
|
|
350
|
-
destRect?: ReadOnlyRect |
|
|
351
|
-
fillColor?: string |
|
|
352
|
-
strokeColor?: string |
|
|
353
|
-
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>[];
|
|
354
409
|
/** How long to ask the parent for. The default covers the default Step schedule. */
|
|
355
410
|
minDuration?: number;
|
|
356
411
|
} = {},
|
|
357
412
|
) {
|
|
358
413
|
super(initialValues.description ?? "Fourier");
|
|
414
|
+
this.registryKey = initialValues.registryKey ?? "Fourier";
|
|
359
415
|
const names = [...FourierComponent.sources.keys()];
|
|
360
416
|
this.sourceSchedule = new SelectScheduleInfo(
|
|
361
417
|
"Source",
|
|
@@ -453,7 +509,7 @@ export class FourierComponent extends DurationAgnosticComponent {
|
|
|
453
509
|
return cached;
|
|
454
510
|
const source = this.termsFor(name);
|
|
455
511
|
if (typeof source === "string") return source;
|
|
456
|
-
const { groups } = parseTermGroups(termGroups);
|
|
512
|
+
const { groups } = parseTermGroups(termGroups, source.terms.length);
|
|
457
513
|
const ordered = orderTerms(source.terms, groups);
|
|
458
514
|
const rules =
|
|
459
515
|
ordered.keyframes.length < 2
|
|
@@ -498,6 +554,7 @@ export class FourierComponent extends DurationAgnosticComponent {
|
|
|
498
554
|
/**
|
|
499
555
|
* Draw the curve: fill, then stroke. It's already in place, in canvas
|
|
500
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.
|
|
501
558
|
*
|
|
502
559
|
* Override this to draw it differently, e.g. stroked with strokeColors()
|
|
503
560
|
* like the Sierpiński video.
|
|
@@ -512,9 +569,13 @@ export class FourierComponent extends DurationAgnosticComponent {
|
|
|
512
569
|
// itself, the fill alternates instead of piling up.
|
|
513
570
|
context.fill(path, "evenodd");
|
|
514
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;
|
|
515
576
|
context.lineCap = "round";
|
|
516
577
|
context.lineJoin = "round";
|
|
517
|
-
context.lineWidth =
|
|
578
|
+
context.lineWidth = lineWidth;
|
|
518
579
|
context.strokeStyle = this.strokeColorSchedule.at(timeInMs);
|
|
519
580
|
context.stroke(path);
|
|
520
581
|
}
|
|
@@ -524,9 +585,17 @@ export class FourierComponent extends DurationAgnosticComponent {
|
|
|
524
585
|
|
|
525
586
|
// Cheap to create: nothing is computed until a component draws one.
|
|
526
587
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
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
|
+
}
|
|
530
599
|
FourierComponent.sources.set("Square", {
|
|
531
600
|
path: "M -1,-1 L 1,-1 L 1,1 L -1,1 Z",
|
|
532
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",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { canvasRecorder } from "../../lib/main-control.ts";
|
|
1
2
|
import { ColorScheduleInfo, NumberScheduleInfo } from "../schedule-helper.ts";
|
|
2
3
|
import { Showable, ShowOptions } from "../showable.ts";
|
|
3
4
|
import { InParallelComponent } from "./in-parallel.ts";
|
|
4
|
-
import {
|
|
5
|
+
import { TimedKeyframe } from "../interpolate.ts";
|
|
5
6
|
|
|
6
7
|
/** At 100% opacity the dot radius reaches this fraction of the half-cell width. */
|
|
7
8
|
const HALFTONE_MAX_RADIUS_FACTOR = 0.9;
|
|
@@ -19,7 +20,7 @@ const HALFTONE_MAX_RADIUS_FACTOR = 0.9;
|
|
|
19
20
|
* Showable in the constructor to add it as a fixed child.
|
|
20
21
|
*/
|
|
21
22
|
export class HalftoneShadowComponent extends InParallelComponent {
|
|
22
|
-
readonly registryKey
|
|
23
|
+
readonly registryKey: string;
|
|
23
24
|
readonly dotColorSchedule = new ColorScheduleInfo("Dot Color", "#ccc");
|
|
24
25
|
readonly backgroundColorSchedule = new ColorScheduleInfo(
|
|
25
26
|
"Background Color",
|
|
@@ -38,11 +39,12 @@ export class HalftoneShadowComponent extends InParallelComponent {
|
|
|
38
39
|
initialValues: {
|
|
39
40
|
base?: Showable;
|
|
40
41
|
description?: string;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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>[];
|
|
46
48
|
} = {},
|
|
47
49
|
) {
|
|
48
50
|
const { base } = initialValues;
|
|
@@ -50,6 +52,7 @@ export class HalftoneShadowComponent extends InParallelComponent {
|
|
|
50
52
|
initialValues.description ??
|
|
51
53
|
(base ? `${base.description} » shadow` : "Halftone Shadow"),
|
|
52
54
|
);
|
|
55
|
+
this.registryKey = initialValues.registryKey ?? "Halftone Shadow";
|
|
53
56
|
this.schedules.push(
|
|
54
57
|
this.dotColorSchedule,
|
|
55
58
|
this.backgroundColorSchedule,
|
|
@@ -75,18 +78,21 @@ export class HalftoneShadowComponent extends InParallelComponent {
|
|
|
75
78
|
const dx = this.dxSchedule.at(timeInMs);
|
|
76
79
|
const dy = this.dySchedule.at(timeInMs);
|
|
77
80
|
const period = this.periodSchedule.at(timeInMs);
|
|
78
|
-
|
|
79
|
-
const
|
|
81
|
+
// Read the size every frame: it can change at any time.
|
|
82
|
+
const { width, height } = canvasRecorder;
|
|
83
|
+
// One small pixel per dot. The last row and column can hang past the edge.
|
|
84
|
+
const cols = Math.ceil(width / period);
|
|
85
|
+
const rows = Math.ceil(height / period);
|
|
80
86
|
|
|
81
87
|
// Low-power mode or CLI context: skip the halftone pass.
|
|
82
88
|
if (options.quality === "Low Power" || typeof document === "undefined") {
|
|
83
89
|
context.fillStyle = backgroundColor;
|
|
84
|
-
context.fillRect(0, 0,
|
|
90
|
+
context.fillRect(0, 0, width, height);
|
|
85
91
|
super.show(options);
|
|
86
92
|
return;
|
|
87
93
|
}
|
|
88
94
|
|
|
89
|
-
// Resize the small canvas when period changes.
|
|
95
|
+
// Resize the small canvas when the period or the canvas size changes.
|
|
90
96
|
if (
|
|
91
97
|
!this.#smallCanvas ||
|
|
92
98
|
this.#smallCols !== cols ||
|
|
@@ -98,23 +104,22 @@ export class HalftoneShadowComponent extends InParallelComponent {
|
|
|
98
104
|
this.#smallCtx = this.#smallCanvas.getContext("2d", {
|
|
99
105
|
willReadFrequently: true,
|
|
100
106
|
})!;
|
|
101
|
-
// Apply the 16×9 root transform once — it stays until the canvas is replaced.
|
|
102
|
-
this.#smallCtx.scale(cols / 16, rows / 9);
|
|
103
107
|
this.#smallCols = cols;
|
|
104
108
|
this.#smallRows = rows;
|
|
105
109
|
}
|
|
106
110
|
const smallCtx = this.#smallCtx!;
|
|
107
111
|
|
|
108
112
|
// Render children into the small canvas for alpha sampling.
|
|
109
|
-
smallCtx.save();
|
|
110
113
|
smallCtx.resetTransform();
|
|
111
114
|
smallCtx.clearRect(0, 0, cols, rows);
|
|
112
|
-
|
|
115
|
+
// Each small pixel is exactly one cell, so it samples where its dot is drawn.
|
|
116
|
+
// Set every frame: the period can change without changing cols or rows.
|
|
117
|
+
smallCtx.scale(1 / period, 1 / period);
|
|
113
118
|
super.show({ ...options, context: smallCtx, registerTransform: undefined });
|
|
114
119
|
|
|
115
120
|
// Draw background.
|
|
116
121
|
context.fillStyle = backgroundColor;
|
|
117
|
-
context.fillRect(0, 0,
|
|
122
|
+
context.fillRect(0, 0, width, height);
|
|
118
123
|
|
|
119
124
|
// Build halftone dot path from the alpha channel and draw as the shadow.
|
|
120
125
|
const { data } = smallCtx.getImageData(0, 0, cols, rows);
|
|
@@ -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
|
}
|