canvas-recorder-lib 0.7.0 → 0.7.2
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 +38 -8
- package/dev/audio-builder.ts +5 -1
- package/dev/canvas-recorder.css +15 -4
- package/dev/canvas-recorder.ts +276 -88
- package/dev/delay-files.ts +1 -1
- package/dev/format-editor.ts +7 -2
- package/dev/fourier-panel.ts +11 -3
- package/dev/handwriting-panel.ts +14 -9
- package/dev/local-file-row.ts +12 -5
- package/dev/multi-text-dialog.ts +15 -6
- package/dev/multi-text-panel.ts +6 -2
- package/dev/player-body.ts +4 -0
- package/dev/schedule-helpers.ts +11 -4
- package/dev/sound-clips.ts +4 -1
- package/dev/soundtrack.ts +52 -13
- package/dev/split-dialog.ts +49 -19
- package/dev/static-image-panel.ts +17 -5
- package/dev/synced-file.ts +4 -5
- package/dev/timeline-display.ts +152 -50
- package/dev/transcribe-core.ts +48 -17
- package/dev/transcribe-worker.ts +20 -9
- package/dev/transcript-align.ts +95 -20
- package/dev/transcript-export.ts +18 -7
- package/dev/transcript-view.ts +78 -22
- package/dev/transcripts.ts +97 -26
- package/dev/video-clip-panel.ts +64 -18
- package/dev/voice/chirp.ts +21 -5
- package/dev/voice/folder.ts +22 -7
- package/dev/voice/voice-panel.ts +61 -27
- package/dev/voice/voice-recorder.ts +74 -18
- package/dist/dev/audio-builder.js.map +1 -1
- package/dist/dev/canvas-recorder.css +15 -4
- package/dist/dev/canvas-recorder.js +185 -48
- package/dist/dev/canvas-recorder.js.map +1 -1
- package/dist/dev/format-editor.d.ts.map +1 -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.map +1 -1
- package/dist/dev/handwriting-panel.d.ts.map +1 -1
- package/dist/dev/handwriting-panel.js +10 -8
- package/dist/dev/handwriting-panel.js.map +1 -1
- package/dist/dev/local-file-row.d.ts.map +1 -1
- package/dist/dev/local-file-row.js +12 -4
- package/dist/dev/local-file-row.js.map +1 -1
- package/dist/dev/multi-text-dialog.d.ts.map +1 -1
- package/dist/dev/multi-text-dialog.js +4 -2
- package/dist/dev/multi-text-dialog.js.map +1 -1
- package/dist/dev/multi-text-panel.d.ts.map +1 -1
- package/dist/dev/multi-text-panel.js +2 -1
- package/dist/dev/multi-text-panel.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 +4 -0
- 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 -1
- package/dist/dev/schedule-helpers.js.map +1 -1
- package/dist/dev/sound-clips.d.ts.map +1 -1
- package/dist/dev/sound-clips.js.map +1 -1
- package/dist/dev/soundtrack.d.ts +12 -0
- package/dist/dev/soundtrack.d.ts.map +1 -1
- package/dist/dev/soundtrack.js +42 -9
- package/dist/dev/soundtrack.js.map +1 -1
- package/dist/dev/split-dialog.d.ts.map +1 -1
- package/dist/dev/split-dialog.js +17 -10
- package/dist/dev/split-dialog.js.map +1 -1
- package/dist/dev/static-image-panel.d.ts.map +1 -1
- package/dist/dev/static-image-panel.js +7 -3
- package/dist/dev/static-image-panel.js.map +1 -1
- package/dist/dev/synced-file.d.ts.map +1 -1
- package/dist/dev/synced-file.js.map +1 -1
- package/dist/dev/timeline-display.d.ts.map +1 -1
- package/dist/dev/timeline-display.js +62 -17
- 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 +13 -3
- package/dist/dev/transcribe-core.js.map +1 -1
- package/dist/dev/transcribe-worker.d.ts.map +1 -1
- package/dist/dev/transcribe-worker.js +9 -3
- package/dist/dev/transcribe-worker.js.map +1 -1
- package/dist/dev/transcript-align.d.ts.map +1 -1
- package/dist/dev/transcript-align.js +52 -9
- package/dist/dev/transcript-align.js.map +1 -1
- package/dist/dev/transcript-export.d.ts.map +1 -1
- package/dist/dev/transcript-export.js +10 -4
- 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 +32 -11
- package/dist/dev/transcript-view.js.map +1 -1
- package/dist/dev/transcripts.d.ts +5 -0
- package/dist/dev/transcripts.d.ts.map +1 -1
- package/dist/dev/transcripts.js +54 -6
- package/dist/dev/transcripts.js.map +1 -1
- package/dist/dev/video-clip-panel.d.ts.map +1 -1
- package/dist/dev/video-clip-panel.js +25 -8
- package/dist/dev/video-clip-panel.js.map +1 -1
- package/dist/dev/voice/chirp.d.ts.map +1 -1
- package/dist/dev/voice/chirp.js +5 -1
- package/dist/dev/voice/chirp.js.map +1 -1
- package/dist/dev/voice/folder.d.ts.map +1 -1
- package/dist/dev/voice/folder.js +1 -1
- package/dist/dev/voice/folder.js.map +1 -1
- package/dist/dev/voice/voice-panel.d.ts.map +1 -1
- package/dist/dev/voice/voice-panel.js +42 -23
- package/dist/dev/voice/voice-panel.js.map +1 -1
- package/dist/dev/voice/voice-recorder.d.ts.map +1 -1
- package/dist/dev/voice/voice-recorder.js +34 -9
- package/dist/dev/voice/voice-recorder.js.map +1 -1
- package/dist/lib/main-control.d.ts.map +1 -1
- package/dist/lib/main-control.js.map +1 -1
- package/dist/src/corner-rounder.d.ts.map +1 -1
- package/dist/src/corner-rounder.js +1 -1
- package/dist/src/corner-rounder.js.map +1 -1
- package/dist/src/local-files.d.ts.map +1 -1
- package/dist/src/local-files.js +5 -2
- package/dist/src/local-files.js.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.d.ts +7 -0
- package/dist/src/peano-fourier/fourier-shared.d.ts.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.js +8 -1
- package/dist/src/peano-fourier/fourier-shared.js.map +1 -1
- package/dist/src/slide-components/fourier.d.ts.map +1 -1
- package/dist/src/slide-components/fourier.js +12 -4
- package/dist/src/slide-components/fourier.js.map +1 -1
- package/dist/src/slide-components/image.d.ts.map +1 -1
- package/dist/src/slide-components/image.js +1 -1
- package/dist/src/slide-components/image.js.map +1 -1
- package/dist/src/slide-components/in-parallel.d.ts.map +1 -1
- package/dist/src/slide-components/in-parallel.js.map +1 -1
- package/dist/src/slide-components/multi-text.d.ts.map +1 -1
- package/dist/src/slide-components/multi-text.js +1 -1
- package/dist/src/slide-components/multi-text.js.map +1 -1
- package/dist/src/slide-components/rectangle.d.ts.map +1 -1
- package/dist/src/slide-components/rectangle.js +1 -1
- package/dist/src/slide-components/rectangle.js.map +1 -1
- package/dist/src/slide-components/registry.js.map +1 -1
- package/dist/src/slide-components/serialize.d.ts.map +1 -1
- package/dist/src/slide-components/serialize.js +2 -1
- package/dist/src/slide-components/serialize.js.map +1 -1
- package/dist/src/slide-components/split-video-clip.d.ts.map +1 -1
- package/dist/src/slide-components/split-video-clip.js +4 -1
- package/dist/src/slide-components/split-video-clip.js.map +1 -1
- package/dist/src/slide-components/video-clip.d.ts.map +1 -1
- package/dist/src/slide-components/video-clip.js +7 -4
- package/dist/src/slide-components/video-clip.js.map +1 -1
- package/dist/src/slide-components/video-info.d.ts.map +1 -1
- package/dist/src/slide-components/video-info.js.map +1 -1
- package/dist/src/slow-image-sources.d.ts.map +1 -1
- package/dist/src/slow-image-sources.js +1 -1
- package/dist/src/slow-image-sources.js.map +1 -1
- package/dist/src/snapshot.d.ts.map +1 -1
- package/dist/src/snapshot.js +1 -1
- package/dist/src/snapshot.js.map +1 -1
- package/dist/src/utility.d.ts.map +1 -1
- package/dist/src/utility.js +1 -3
- package/dist/src/utility.js.map +1 -1
- package/lib/main-control.ts +3 -1
- package/package.json +4 -1
- package/src/corner-rounder.ts +5 -12
- package/src/glib/letters-base.ts +1 -1
- package/src/local-files.ts +19 -6
- package/src/peano-fourier/fourier-shared.ts +8 -1
- package/src/slide-components/fourier.ts +32 -10
- package/src/slide-components/image.ts +4 -1
- package/src/slide-components/in-parallel.ts +1 -2
- package/src/slide-components/multi-text.ts +17 -4
- package/src/slide-components/rectangle.ts +4 -1
- package/src/slide-components/registry.ts +1 -1
- package/src/slide-components/serialize.ts +4 -1
- package/src/slide-components/split-video-clip.ts +4 -1
- package/src/slide-components/video-clip.ts +21 -8
- package/src/slide-components/video-info.ts +4 -1
- package/src/slow-image-sources.ts +5 -1
- package/src/snapshot.ts +13 -4
- package/src/utility.ts +70 -33
package/dev/delay-files.ts
CHANGED
|
@@ -136,4 +136,4 @@ philDebug.unloadServiceWorker = unloadServiceWorker;
|
|
|
136
136
|
// JavaScript are loaded, and the service worker could actually monitor or change
|
|
137
137
|
// those pages.
|
|
138
138
|
// Reloading the service worker is also very fast,
|
|
139
|
-
// faster than I could manually start the next step of my testing.
|
|
139
|
+
// faster than I could manually start the next step of my testing.
|
package/dev/format-editor.ts
CHANGED
|
@@ -139,7 +139,11 @@ export class FormatEditor {
|
|
|
139
139
|
return serialize(this.#units());
|
|
140
140
|
}
|
|
141
141
|
set value(newValue: string) {
|
|
142
|
-
this.#replace(
|
|
142
|
+
this.#replace(
|
|
143
|
+
{ start: 0, end: this.#units().length },
|
|
144
|
+
parse(newValue),
|
|
145
|
+
"set",
|
|
146
|
+
);
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
get knownNames(): readonly string[] {
|
|
@@ -174,7 +178,8 @@ export class FormatEditor {
|
|
|
174
178
|
this.#replace(selection, [{ format: name }], "insert format");
|
|
175
179
|
// The new chip is immediately before the cursor.
|
|
176
180
|
const cursor = this.#getSelection();
|
|
177
|
-
const chip =
|
|
181
|
+
const chip =
|
|
182
|
+
cursor && this.#chipElements()[this.#chipIndexBefore(cursor.start)];
|
|
178
183
|
const select = chip?.querySelector("select");
|
|
179
184
|
if (select) {
|
|
180
185
|
select.focus();
|
package/dev/fourier-panel.ts
CHANGED
|
@@ -116,8 +116,13 @@ export function buildFourierPanel(component: FourierComponent): FourierPanel {
|
|
|
116
116
|
const prefix = keyframes.length > 1 ? `At ${keyframe.time} ms: ` : "";
|
|
117
117
|
const parsed = parseTermGroups(keyframe.value);
|
|
118
118
|
groupCounts.add(parsed.groups.length);
|
|
119
|
-
const source = component.termsFor(
|
|
120
|
-
|
|
119
|
+
const source = component.termsFor(
|
|
120
|
+
component.sourceSchedule.at(keyframe.time),
|
|
121
|
+
);
|
|
122
|
+
const termCount = parsed.groups.reduce(
|
|
123
|
+
(sum, group) => sum + group.length,
|
|
124
|
+
0,
|
|
125
|
+
);
|
|
121
126
|
const problems = [...parsed.warnings];
|
|
122
127
|
let summary = `${parsed.groups.length} group${parsed.groups.length === 1 ? "" : "s"}, ${termCount} term${termCount === 1 ? "" : "s"}`;
|
|
123
128
|
if (typeof source === "string") {
|
|
@@ -133,7 +138,10 @@ export function buildFourierPanel(component: FourierComponent): FourierPanel {
|
|
|
133
138
|
}
|
|
134
139
|
if (groupCounts.size === 1) {
|
|
135
140
|
const [groupCount] = groupCounts;
|
|
136
|
-
const stepProblems = checkStepRange(
|
|
141
|
+
const stepProblems = checkStepRange(
|
|
142
|
+
component.stepSchedule.schedule,
|
|
143
|
+
groupCount,
|
|
144
|
+
);
|
|
137
145
|
if (stepProblems.length === 0) {
|
|
138
146
|
line(`Step runs from 0 to ${groupCount} ✓`, "#070");
|
|
139
147
|
}
|
package/dev/handwriting-panel.ts
CHANGED
|
@@ -30,7 +30,7 @@ const HELP =
|
|
|
30
30
|
"in between, the pen moves through the next unit at a steady speed. " +
|
|
31
31
|
"Letters are visible characters only: spaces take no time. " +
|
|
32
32
|
"Words are split as the layout splits them, and each Text Span starts a new word. " +
|
|
33
|
-
|
|
33
|
+
'Lines end at a "\\n", not at word wrap. Total: 1 is the whole text.';
|
|
34
34
|
|
|
35
35
|
/** Singular, for "line 3"; plural, for "4 lines". */
|
|
36
36
|
const UNIT_NAMES: Record<HandwritingDivision, [string, string]> = {
|
|
@@ -146,9 +146,7 @@ export function buildHandwritingPanel(
|
|
|
146
146
|
);
|
|
147
147
|
if (peak < count) {
|
|
148
148
|
const goal =
|
|
149
|
-
division === "Total"
|
|
150
|
-
? "1"
|
|
151
|
-
: `${count}, the number of ${plural}`;
|
|
149
|
+
division === "Total" ? "1" : `${count}, the number of ${plural}`;
|
|
152
150
|
line(
|
|
153
151
|
`⚠ Progress never reaches ${goal}, so the text is never finished. ` +
|
|
154
152
|
`It peaks at ${formatNumber(peak)}, ${whereThePenIs(units, peak, division, words)}.`,
|
|
@@ -168,7 +166,10 @@ export function buildHandwritingPanel(
|
|
|
168
166
|
});
|
|
169
167
|
status.append(fillBtn);
|
|
170
168
|
} else {
|
|
171
|
-
line(
|
|
169
|
+
line(
|
|
170
|
+
`Progress reaches ${formatNumber(count)}, the end of the text ✓`,
|
|
171
|
+
"#070",
|
|
172
|
+
);
|
|
172
173
|
if (peak > count) {
|
|
173
174
|
line(
|
|
174
175
|
`It goes up to ${formatNumber(peak)}. Anything from ${count} up shows the finished text.`,
|
|
@@ -257,7 +258,9 @@ export function fillInKeyframes(
|
|
|
257
258
|
value: number,
|
|
258
259
|
startsTransition: boolean,
|
|
259
260
|
): Keyframe<number> =>
|
|
260
|
-
startsTransition && ease
|
|
261
|
+
startsTransition && ease
|
|
262
|
+
? { time, value, easeAfter: ease }
|
|
263
|
+
: { time, value };
|
|
261
264
|
const added: Keyframe<number>[] = [];
|
|
262
265
|
let time = last.time;
|
|
263
266
|
let lastEase = ease;
|
|
@@ -295,8 +298,9 @@ function askToFillIn(
|
|
|
295
298
|
): Promise<boolean> {
|
|
296
299
|
const schedule = component.progressSchedule.schedule;
|
|
297
300
|
const [singular] = UNIT_NAMES[division];
|
|
298
|
-
const startValue = [...schedule]
|
|
299
|
-
.
|
|
301
|
+
const startValue = [...schedule]
|
|
302
|
+
.sort((a, b) => a.time - b.time)
|
|
303
|
+
.at(-1)!.value;
|
|
300
304
|
|
|
301
305
|
const dialog = document.createElement("dialog");
|
|
302
306
|
dialog.style.cssText = "min-width:26em;max-width:36em;padding:1em";
|
|
@@ -304,7 +308,8 @@ function askToFillIn(
|
|
|
304
308
|
heading.style.margin = "0 0 0.4em 0";
|
|
305
309
|
heading.textContent = "Fill in the rest";
|
|
306
310
|
const hint = document.createElement("div");
|
|
307
|
-
hint.style.cssText =
|
|
311
|
+
hint.style.cssText =
|
|
312
|
+
"margin-bottom:0.8em;font-size:0.85em;color:#555;font-style:italic";
|
|
308
313
|
hint.textContent =
|
|
309
314
|
`Progress ends at ${formatNumber(startValue)}. ` +
|
|
310
315
|
(division === "Total"
|
package/dev/local-file-row.ts
CHANGED
|
@@ -28,7 +28,8 @@ export type LocalFileRowOptions = {
|
|
|
28
28
|
*/
|
|
29
29
|
export function buildLocalFileRow(options: LocalFileRowOptions): HTMLElement {
|
|
30
30
|
const row = document.createElement("div");
|
|
31
|
-
row.style.cssText =
|
|
31
|
+
row.style.cssText =
|
|
32
|
+
"margin-bottom:0.3em;display:flex;gap:0.3em;align-items:center;flex-wrap:wrap";
|
|
32
33
|
|
|
33
34
|
const pickButton = document.createElement("button");
|
|
34
35
|
pickButton.type = "button";
|
|
@@ -51,7 +52,11 @@ export function buildLocalFileRow(options: LocalFileRowOptions): HTMLElement {
|
|
|
51
52
|
async function redraw() {
|
|
52
53
|
const myGeneration = ++generation;
|
|
53
54
|
const url = options.currentUrl();
|
|
54
|
-
where.textContent = isLocalFileUrl(url)
|
|
55
|
+
where.textContent = isLocalFileUrl(url)
|
|
56
|
+
? "On this computer"
|
|
57
|
+
: url
|
|
58
|
+
? "On the web server"
|
|
59
|
+
: "";
|
|
55
60
|
let files: Awaited<ReturnType<typeof listLocalFiles>>;
|
|
56
61
|
try {
|
|
57
62
|
files = await listLocalFiles();
|
|
@@ -60,7 +65,9 @@ export function buildLocalFileRow(options: LocalFileRowOptions): HTMLElement {
|
|
|
60
65
|
}
|
|
61
66
|
if (myGeneration !== generation) return;
|
|
62
67
|
const placeholder = document.createElement("option");
|
|
63
|
-
placeholder.textContent = files.length
|
|
68
|
+
placeholder.textContent = files.length
|
|
69
|
+
? "Recent files…"
|
|
70
|
+
: "No recent files";
|
|
64
71
|
placeholder.value = "";
|
|
65
72
|
placeholder.disabled = true;
|
|
66
73
|
const choices = files.map((file) => {
|
|
@@ -70,7 +77,8 @@ export function buildLocalFileRow(options: LocalFileRowOptions): HTMLElement {
|
|
|
70
77
|
return option;
|
|
71
78
|
});
|
|
72
79
|
recentSelect.replaceChildren(placeholder, ...choices);
|
|
73
|
-
recentSelect.value =
|
|
80
|
+
recentSelect.value =
|
|
81
|
+
isLocalFileUrl(url) && files.some((f) => f.url === url) ? url : "";
|
|
74
82
|
recentSelect.disabled = files.length === 0;
|
|
75
83
|
}
|
|
76
84
|
|
|
@@ -104,4 +112,3 @@ export function buildLocalFileRow(options: LocalFileRowOptions): HTMLElement {
|
|
|
104
112
|
void redraw();
|
|
105
113
|
return row;
|
|
106
114
|
}
|
|
107
|
-
|
package/dev/multi-text-dialog.ts
CHANGED
|
@@ -124,7 +124,8 @@ export async function openMultiTextDialog(
|
|
|
124
124
|
const revertBtn = document.createElement("button");
|
|
125
125
|
revertBtn.type = "button";
|
|
126
126
|
revertBtn.textContent = "Revert";
|
|
127
|
-
revertBtn.title =
|
|
127
|
+
revertBtn.title =
|
|
128
|
+
"Put the text and the formats back the way they were when this opened.";
|
|
128
129
|
revertBtn.disabled = true;
|
|
129
130
|
const doneBtn = document.createElement("button");
|
|
130
131
|
doneBtn.type = "button";
|
|
@@ -150,10 +151,13 @@ export async function openMultiTextDialog(
|
|
|
150
151
|
}
|
|
151
152
|
if (
|
|
152
153
|
text.children.some(
|
|
153
|
-
({ replaceable, child }) =>
|
|
154
|
+
({ replaceable, child }) =>
|
|
155
|
+
!replaceable && child instanceof TextSpanComponent,
|
|
154
156
|
)
|
|
155
157
|
) {
|
|
156
|
-
note(
|
|
158
|
+
note(
|
|
159
|
+
"This Multi Text also has Text Spans built in TypeScript. They can't be edited here.",
|
|
160
|
+
);
|
|
157
161
|
}
|
|
158
162
|
for (const { span } of originalSpans) {
|
|
159
163
|
if (isAnimated(span)) {
|
|
@@ -227,7 +231,9 @@ export async function openMultiTextDialog(
|
|
|
227
231
|
}
|
|
228
232
|
|
|
229
233
|
// Keep the focus, and so the cursor, in the editor.
|
|
230
|
-
insertFormatBtn.addEventListener("mousedown", (event) =>
|
|
234
|
+
insertFormatBtn.addEventListener("mousedown", (event) =>
|
|
235
|
+
event.preventDefault(),
|
|
236
|
+
);
|
|
231
237
|
insertFormatBtn.addEventListener("click", () => editor.insertFormat());
|
|
232
238
|
|
|
233
239
|
revertBtn.addEventListener("click", () => {
|
|
@@ -286,7 +292,9 @@ export async function openMultiTextDialog(
|
|
|
286
292
|
* @param existing The names already in use. Picking one of these is allowed: it uses that format.
|
|
287
293
|
* @returns The name, or undefined if the user cancelled.
|
|
288
294
|
*/
|
|
289
|
-
function askFormatName(
|
|
295
|
+
function askFormatName(
|
|
296
|
+
existing: readonly string[],
|
|
297
|
+
): Promise<string | undefined> {
|
|
290
298
|
const dialog = document.createElement("dialog");
|
|
291
299
|
dialog.style.cssText = "min-width:26em;max-width:36em;padding:1em";
|
|
292
300
|
|
|
@@ -307,7 +315,8 @@ function askFormatName(existing: readonly string[]): Promise<string | undefined>
|
|
|
307
315
|
label.append(input);
|
|
308
316
|
|
|
309
317
|
const message = document.createElement("div");
|
|
310
|
-
message.style.cssText =
|
|
318
|
+
message.style.cssText =
|
|
319
|
+
"font-size:0.85em;min-height:1.3em;margin:0.3em 0 0.8em 0";
|
|
311
320
|
|
|
312
321
|
const buttons = document.createElement("div");
|
|
313
322
|
buttons.style.cssText = "display:flex;gap:0.5em;justify-content:flex-end";
|
package/dev/multi-text-panel.ts
CHANGED
|
@@ -14,7 +14,10 @@ import {
|
|
|
14
14
|
import { buildNumericInput } from "./schedule-helpers.ts";
|
|
15
15
|
|
|
16
16
|
/** Whether the frame is drawn on the canvas (👁), and whether it has handles to drag (✎). */
|
|
17
|
-
export type CanvasState = {
|
|
17
|
+
export type CanvasState = {
|
|
18
|
+
readonly viewing: boolean;
|
|
19
|
+
readonly editing: boolean;
|
|
20
|
+
};
|
|
18
21
|
|
|
19
22
|
/** What the panel needs from the Visual Editor. It never reaches into canvas-recorder.ts directly. */
|
|
20
23
|
export type TextFramePanelHooks = {
|
|
@@ -158,7 +161,8 @@ export function buildTextFramePanel(
|
|
|
158
161
|
|
|
159
162
|
function turnBy(quarterTurns: 1 | 3): void {
|
|
160
163
|
const before = text.frameIsEditable ? text.frameAt(0) : undefined;
|
|
161
|
-
text.rotationScalar.value =
|
|
164
|
+
text.rotationScalar.value =
|
|
165
|
+
ROTATIONS[(text.quarterTurns + quarterTurns) % 4];
|
|
162
166
|
if (before) {
|
|
163
167
|
// Turn in place, about the frame's center, the way PowerPoint does. A
|
|
164
168
|
// quarter turn swaps the frame's width and height on screen.
|
package/dev/player-body.ts
CHANGED
|
@@ -129,6 +129,10 @@ export const playerBodyHtml = `
|
|
|
129
129
|
value="0"
|
|
130
130
|
title="The play position, in seconds. Option-← and Option-→ step one frame."
|
|
131
131
|
/>
|
|
132
|
+
<label
|
|
133
|
+
title="Checked: the time is measured from the start of the component you're editing. Unchecked: from the start of the video."
|
|
134
|
+
><input type="checkbox" id="playPositionLocal" checked />local</label
|
|
135
|
+
>
|
|
132
136
|
<input type="range" id="playPositionRange" value="0" step="any" />
|
|
133
137
|
</div>
|
|
134
138
|
</fieldset>
|
package/dev/schedule-helpers.ts
CHANGED
|
@@ -97,7 +97,12 @@ export function scheduleToTypeScript(
|
|
|
97
97
|
`cellWidth: ${v.cellWidth}, cellHeight: ${v.cellHeight} }`
|
|
98
98
|
);
|
|
99
99
|
} else {
|
|
100
|
-
const v = value as {
|
|
100
|
+
const v = value as {
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
width: number;
|
|
104
|
+
height: number;
|
|
105
|
+
};
|
|
101
106
|
return `{ x: ${v.x}, y: ${v.y}, width: ${v.width}, height: ${v.height} }`;
|
|
102
107
|
}
|
|
103
108
|
}
|
|
@@ -165,7 +170,10 @@ export function validateKfValue(
|
|
|
165
170
|
if (typeof value !== "object" || value === null) return false;
|
|
166
171
|
const v = value as Record<string, unknown>;
|
|
167
172
|
const isPoint = (p: unknown): boolean =>
|
|
168
|
-
typeof p === "object" &&
|
|
173
|
+
typeof p === "object" &&
|
|
174
|
+
p !== null &&
|
|
175
|
+
typeof (p as Record<string, unknown>).x === "number" &&
|
|
176
|
+
typeof (p as Record<string, unknown>).y === "number";
|
|
169
177
|
return isPoint(v.flat) && isPoint(v.pointy);
|
|
170
178
|
}
|
|
171
179
|
}
|
|
@@ -176,8 +184,7 @@ export function parseScheduleFromClipboard(
|
|
|
176
184
|
text: string,
|
|
177
185
|
type: ScheduleInfo["type"],
|
|
178
186
|
):
|
|
179
|
-
|
|
180
|
-
| null {
|
|
187
|
+
{ time: number; value: unknown; easeAfter?: (t: number) => number }[] | null {
|
|
181
188
|
try {
|
|
182
189
|
let cleaned = text
|
|
183
190
|
.split("\n")
|
package/dev/sound-clips.ts
CHANGED
|
@@ -55,7 +55,10 @@ export function soundOwners(root: Showable): SoundOwner[] {
|
|
|
55
55
|
* When `target` starts, relative to `root`. `undefined` if it isn't in the tree.
|
|
56
56
|
* Uses the same walk as {@link soundOwners}.
|
|
57
57
|
*/
|
|
58
|
-
export function startWithin(
|
|
58
|
+
export function startWithin(
|
|
59
|
+
root: Showable,
|
|
60
|
+
target: Showable,
|
|
61
|
+
): number | undefined {
|
|
59
62
|
function walk(item: Showable, startMs: number): number | undefined {
|
|
60
63
|
if (item === target) return startMs;
|
|
61
64
|
for (const { child, start } of item.children ?? []) {
|
package/dev/soundtrack.ts
CHANGED
|
@@ -102,6 +102,8 @@ export type SoundtrackOptions = {
|
|
|
102
102
|
readonly root: () => Showable;
|
|
103
103
|
/** A file finished decoding: its waveform and length are known now. */
|
|
104
104
|
readonly onDecoded?: () => void;
|
|
105
|
+
/** A file couldn't be read or decoded. See {@link Soundtrack.failure}. */
|
|
106
|
+
readonly onFailed?: () => void;
|
|
105
107
|
/** A clip names a file that wasn't in the list before. */
|
|
106
108
|
readonly onNewSource?: () => void;
|
|
107
109
|
};
|
|
@@ -122,8 +124,8 @@ export class Soundtrack {
|
|
|
122
124
|
});
|
|
123
125
|
readonly #decoding = new Map<string, Promise<AudioBuffer>>();
|
|
124
126
|
readonly #decoded = new Map<string, AudioBuffer>();
|
|
125
|
-
/** Files that couldn't be read. Not tried again until {@link forgetFailures}. */
|
|
126
|
-
readonly #failed = new
|
|
127
|
+
/** Files that couldn't be read, and why. Not tried again until {@link forgetFailures}. */
|
|
128
|
+
readonly #failed = new Map<string, unknown>();
|
|
127
129
|
|
|
128
130
|
/**
|
|
129
131
|
* The decoded file, mono, or null if it hasn't been decoded yet (or can't be).
|
|
@@ -133,13 +135,30 @@ export class Soundtrack {
|
|
|
133
135
|
return this.#decoded.get(url) ?? null;
|
|
134
136
|
}
|
|
135
137
|
|
|
138
|
+
/** Why the file couldn't be read or decoded, or undefined if it hasn't failed (yet). */
|
|
139
|
+
failure(url: string): unknown {
|
|
140
|
+
return this.#failed.get(url);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Every file the clips name that couldn't be read or decoded, and why.
|
|
145
|
+
* Call {@link ready} first, or the files still loading aren't known yet.
|
|
146
|
+
*/
|
|
147
|
+
failures(): { url: string; reason: unknown }[] {
|
|
148
|
+
if (this.#requested) this.#update();
|
|
149
|
+
const urls = new Set(this.#clips.map(({ source }) => source));
|
|
150
|
+
return [...urls]
|
|
151
|
+
.filter((url) => this.#failed.has(url))
|
|
152
|
+
.map((url) => ({ url, reason: this.#failed.get(url) }));
|
|
153
|
+
}
|
|
154
|
+
|
|
136
155
|
/** Read and decode every file again, e.g. one re-recorded under the same name. */
|
|
137
156
|
forget(): void {
|
|
138
157
|
this.#decoding.clear();
|
|
139
158
|
this.#decoded.clear();
|
|
140
159
|
this.#failed.clear();
|
|
141
160
|
this.#knownSources.clear();
|
|
142
|
-
this
|
|
161
|
+
this.#loadAgain();
|
|
143
162
|
}
|
|
144
163
|
|
|
145
164
|
/**
|
|
@@ -158,8 +177,14 @@ export class Soundtrack {
|
|
|
158
177
|
|
|
159
178
|
/** Try the files that couldn't be read again, e.g. after 🔓 Allow local files. */
|
|
160
179
|
forgetFailures(): void {
|
|
161
|
-
for (const url of this.#failed) this.#decoding.delete(url);
|
|
180
|
+
for (const url of this.#failed.keys()) this.#decoding.delete(url);
|
|
162
181
|
this.#failed.clear();
|
|
182
|
+
this.#loadAgain();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Load every clip's file that isn't loaded or loading. {@link request} skips that when no clip moved. */
|
|
186
|
+
#loadAgain(): void {
|
|
187
|
+
this.#clipsJson = "";
|
|
163
188
|
this.request();
|
|
164
189
|
}
|
|
165
190
|
|
|
@@ -176,7 +201,10 @@ export class Soundtrack {
|
|
|
176
201
|
return buffer;
|
|
177
202
|
},
|
|
178
203
|
(reason) => {
|
|
179
|
-
if (this.#decoding.get(url) === promise)
|
|
204
|
+
if (this.#decoding.get(url) === promise) {
|
|
205
|
+
this.#failed.set(url, reason);
|
|
206
|
+
this.#options.onFailed?.();
|
|
207
|
+
}
|
|
180
208
|
debugLog("audio", `Skipped "${url}": ${reason}`);
|
|
181
209
|
throw reason;
|
|
182
210
|
},
|
|
@@ -190,14 +218,19 @@ export class Soundtrack {
|
|
|
190
218
|
async #decode(url: string): Promise<AudioBuffer> {
|
|
191
219
|
const time1 = performance.now();
|
|
192
220
|
const response = await fetchMedia(url);
|
|
221
|
+
// Or the error page would be decoded, and fail with a message that doesn't say why.
|
|
222
|
+
if (!response.ok)
|
|
223
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
193
224
|
const encoded = await response.arrayBuffer();
|
|
225
|
+
// Before decoding: decodeAudioData() detaches the buffer, so it reads as 0 bytes after.
|
|
226
|
+
const bytes = encoded.byteLength;
|
|
194
227
|
const time2 = performance.now();
|
|
195
228
|
// decodeAudioData() takes about ⅜ - ¾ of a second to decode 4 minutes and 18 seconds of audio.
|
|
196
229
|
const decoded = await this.#decoder.decodeAudioData(encoded);
|
|
197
230
|
const time3 = performance.now();
|
|
198
231
|
debugLog(
|
|
199
232
|
"audio",
|
|
200
|
-
`Decoded "${url}": ${(
|
|
233
|
+
`Decoded "${url}": ${(bytes / 1024).toFixed(0)} KB, ` +
|
|
201
234
|
`read ${(time2 - time1).toFixed(0)} ms, decode ${(time3 - time2).toFixed(0)} ms`,
|
|
202
235
|
);
|
|
203
236
|
if (decoded.numberOfChannels === 1) return decoded;
|
|
@@ -270,7 +303,9 @@ export class Soundtrack {
|
|
|
270
303
|
for (;;) {
|
|
271
304
|
if (this.#requested) this.#update();
|
|
272
305
|
const json = this.#clipsJson;
|
|
273
|
-
await Promise.allSettled(
|
|
306
|
+
await Promise.allSettled(
|
|
307
|
+
this.#clips.map(({ source }) => this.#load(source)),
|
|
308
|
+
);
|
|
274
309
|
if (!this.#requested && json === this.#clipsJson) return;
|
|
275
310
|
}
|
|
276
311
|
}
|
|
@@ -281,10 +316,7 @@ export class Soundtrack {
|
|
|
281
316
|
*/
|
|
282
317
|
mix(fromMs: number, toMs: number): AudioBuilder {
|
|
283
318
|
if (this.#requested) this.#update();
|
|
284
|
-
const builder = new AudioBuilder(
|
|
285
|
-
Math.max(0, toMs - fromMs),
|
|
286
|
-
SAMPLE_RATE,
|
|
287
|
-
);
|
|
319
|
+
const builder = new AudioBuilder(Math.max(0, toMs - fromMs), SAMPLE_RATE);
|
|
288
320
|
for (const clip of this.#clips) {
|
|
289
321
|
const buffer = this.#decoded.get(clip.source);
|
|
290
322
|
if (buffer) {
|
|
@@ -346,7 +378,9 @@ export class Soundtrack {
|
|
|
346
378
|
/** The video's time at `contextTime`, by the current anchor. */
|
|
347
379
|
#mediaMsAt(contextTime: number): number {
|
|
348
380
|
const anchor = this.#anchor!;
|
|
349
|
-
return
|
|
381
|
+
return (
|
|
382
|
+
anchor.mediaMs + (contextTime - anchor.contextTime) * anchor.rate * 1000
|
|
383
|
+
);
|
|
350
384
|
}
|
|
351
385
|
|
|
352
386
|
/**
|
|
@@ -354,7 +388,12 @@ export class Soundtrack {
|
|
|
354
388
|
* same time, so a node can be kept.
|
|
355
389
|
*/
|
|
356
390
|
#keyOf(clip: PlacedSoundClip): string {
|
|
357
|
-
return JSON.stringify([
|
|
391
|
+
return JSON.stringify([
|
|
392
|
+
clip.source,
|
|
393
|
+
clip.startMs,
|
|
394
|
+
clip.trimMs,
|
|
395
|
+
clip.lengthMs,
|
|
396
|
+
]);
|
|
358
397
|
}
|
|
359
398
|
|
|
360
399
|
/**
|
package/dev/split-dialog.ts
CHANGED
|
@@ -111,7 +111,8 @@ export function askHowToSplit(options: {
|
|
|
111
111
|
const note = document.createElement("div");
|
|
112
112
|
note.style.cssText = "font-size:0.85em;color:#555;margin-top:0.3em";
|
|
113
113
|
fieldset.append(note);
|
|
114
|
-
const value = () =>
|
|
114
|
+
const value = () =>
|
|
115
|
+
(inputs.find((input) => input.checked)?.value ?? initial) as T;
|
|
115
116
|
return { fieldset, inputs, note, value };
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -127,12 +128,14 @@ export function askHowToSplit(options: {
|
|
|
127
128
|
{
|
|
128
129
|
value: "first",
|
|
129
130
|
label: "Attach to first",
|
|
130
|
-
title:
|
|
131
|
+
title:
|
|
132
|
+
"Keep each one whole, on the first piece. It plays past that piece's end.",
|
|
131
133
|
},
|
|
132
134
|
{
|
|
133
135
|
value: "second",
|
|
134
136
|
label: "Attach to second",
|
|
135
|
-
title:
|
|
137
|
+
title:
|
|
138
|
+
"Keep each one whole, on the second piece. It starts before that piece does.",
|
|
136
139
|
},
|
|
137
140
|
],
|
|
138
141
|
readCrossing(),
|
|
@@ -142,16 +145,18 @@ export function askHowToSplit(options: {
|
|
|
142
145
|
"Keep",
|
|
143
146
|
"splitKeep",
|
|
144
147
|
[
|
|
145
|
-
{ value: "both", label: "Both
|
|
148
|
+
{ value: "both", label: "Both ■■", title: "An ordinary split." },
|
|
146
149
|
{
|
|
147
150
|
value: "first",
|
|
148
|
-
label: "First
|
|
149
|
-
title:
|
|
151
|
+
label: "First ■□",
|
|
152
|
+
title:
|
|
153
|
+
"Trim the end of the clip at the split. The second piece and its sounds are removed.",
|
|
150
154
|
},
|
|
151
155
|
{
|
|
152
156
|
value: "second",
|
|
153
|
-
label: "Second
|
|
154
|
-
title:
|
|
157
|
+
label: "Second □■",
|
|
158
|
+
title:
|
|
159
|
+
"Trim the start of the clip at the split. The first piece and its sounds are removed.",
|
|
155
160
|
},
|
|
156
161
|
],
|
|
157
162
|
"both",
|
|
@@ -192,7 +197,8 @@ export function askHowToSplit(options: {
|
|
|
192
197
|
whereNote.style.color = valid ? "#555" : "#a06000";
|
|
193
198
|
|
|
194
199
|
const crossingCount = valid
|
|
195
|
-
? clip.soundClips.filter((sound) => crossesSplit(sound, atMs, lengthOf))
|
|
200
|
+
? clip.soundClips.filter((sound) => crossesSplit(sound, atMs, lengthOf))
|
|
201
|
+
.length
|
|
196
202
|
: 0;
|
|
197
203
|
for (const input of crossing.inputs) input.disabled = crossingCount === 0;
|
|
198
204
|
crossing.note.textContent =
|
|
@@ -210,7 +216,13 @@ export function askHowToSplit(options: {
|
|
|
210
216
|
const endFile = Math.max(startFile, clip.endMsIntoClipScalar.value);
|
|
211
217
|
const atFile = clip.locationInClip(atMs);
|
|
212
218
|
const kept = keep.value();
|
|
213
|
-
const line = (
|
|
219
|
+
const line = (
|
|
220
|
+
name: string,
|
|
221
|
+
from: number,
|
|
222
|
+
to: number,
|
|
223
|
+
length: number,
|
|
224
|
+
gone: boolean,
|
|
225
|
+
) => {
|
|
214
226
|
const div = document.createElement("div");
|
|
215
227
|
div.textContent = `${name}: ${seconds(length)} long, showing ${seconds(from)}–${seconds(to)} of the file${gone ? " (removed)" : ""}`;
|
|
216
228
|
if (gone) div.style.cssText = "color:#999;text-decoration:line-through";
|
|
@@ -349,15 +361,15 @@ export function askHowToSplitSound(options: {
|
|
|
349
361
|
keepFieldset.append(keepLegend);
|
|
350
362
|
const keepInputs = (
|
|
351
363
|
[
|
|
352
|
-
{ value: "both", label: "Both
|
|
364
|
+
{ value: "both", label: "Both ■■", title: "An ordinary split." },
|
|
353
365
|
{
|
|
354
366
|
value: "first",
|
|
355
|
-
label: "First
|
|
367
|
+
label: "First ■□",
|
|
356
368
|
title: "Trim the end of the clip at the split.",
|
|
357
369
|
},
|
|
358
370
|
{
|
|
359
371
|
value: "second",
|
|
360
|
-
label: "Second
|
|
372
|
+
label: "Second □■",
|
|
361
373
|
title: "Trim the start of the clip at the split.",
|
|
362
374
|
},
|
|
363
375
|
] as const
|
|
@@ -390,7 +402,16 @@ export function askHowToSplitSound(options: {
|
|
|
390
402
|
okBtn.textContent = "Split";
|
|
391
403
|
buttons.append(cancelBtn, okBtn);
|
|
392
404
|
|
|
393
|
-
dialog.append(
|
|
405
|
+
dialog.append(
|
|
406
|
+
heading,
|
|
407
|
+
hint,
|
|
408
|
+
whereRow,
|
|
409
|
+
snapRow,
|
|
410
|
+
whereNote,
|
|
411
|
+
keepFieldset,
|
|
412
|
+
preview,
|
|
413
|
+
buttons,
|
|
414
|
+
);
|
|
394
415
|
|
|
395
416
|
// MARK: Behavior
|
|
396
417
|
const inside = (atMs: number) => atMs > 0 && atMs < lengthMs;
|
|
@@ -404,7 +425,9 @@ export function askHowToSplitSound(options: {
|
|
|
404
425
|
function snapped(atMs: number): number {
|
|
405
426
|
if (!snapInput.checked || !words?.length) return atMs;
|
|
406
427
|
const fileMs = startMsIntoClip + atMs;
|
|
407
|
-
const inWord = words.some(
|
|
428
|
+
const inWord = words.some(
|
|
429
|
+
(w) => w.cutBeforeMs < fileMs && fileMs < w.cutAfterMs,
|
|
430
|
+
);
|
|
408
431
|
if (!inWord) return atMs;
|
|
409
432
|
let best = atMs;
|
|
410
433
|
let bestDistance = Infinity;
|
|
@@ -437,7 +460,8 @@ export function askHowToSplitSound(options: {
|
|
|
437
460
|
if (within) return ` ⚠ That's in the middle of ${quoted(within)}.`;
|
|
438
461
|
const before = words.findLast((w) => w.endMs <= fileMs);
|
|
439
462
|
const after = words.find((w) => w.startMs >= fileMs);
|
|
440
|
-
if (before && after)
|
|
463
|
+
if (before && after)
|
|
464
|
+
return ` Between ${quoted(before)} and ${quoted(after)}.`;
|
|
441
465
|
if (after) return ` Before ${quoted(after)}.`;
|
|
442
466
|
if (before) return ` After ${quoted(before)}.`;
|
|
443
467
|
return "";
|
|
@@ -461,13 +485,19 @@ export function askHowToSplitSound(options: {
|
|
|
461
485
|
(moved
|
|
462
486
|
? `Snapped to ${Math.round(atMs)} ms, ${Math.round(Math.abs(atMs - typed))} ms ${direction}.`
|
|
463
487
|
: "") + aroundWords(atMs);
|
|
464
|
-
whereNote.style.color = whereNote.textContent.includes("⚠")
|
|
488
|
+
whereNote.style.color = whereNote.textContent.includes("⚠")
|
|
489
|
+
? "#a06000"
|
|
490
|
+
: "#555";
|
|
465
491
|
|
|
466
492
|
const kept = keep();
|
|
467
493
|
const line = (name: string, from: number, to: number, gone: boolean) => {
|
|
468
494
|
const div = document.createElement("div");
|
|
469
|
-
const length = Number.isFinite(to - from)
|
|
470
|
-
|
|
495
|
+
const length = Number.isFinite(to - from)
|
|
496
|
+
? `${seconds(to - from)} long`
|
|
497
|
+
: "to the end of the file";
|
|
498
|
+
const fileTo = Number.isFinite(to)
|
|
499
|
+
? seconds(startMsIntoClip + to)
|
|
500
|
+
: "the end";
|
|
471
501
|
div.textContent = `${name}: ${length}, playing ${seconds(startMsIntoClip + from)}–${fileTo} of the file${gone ? " (removed)" : ""}`;
|
|
472
502
|
if (gone) div.style.cssText = "color:#999;text-decoration:line-through";
|
|
473
503
|
return div;
|
|
@@ -11,7 +11,11 @@ import {
|
|
|
11
11
|
shrinkToAspect,
|
|
12
12
|
} from "../src/slide-components/video-info.ts";
|
|
13
13
|
import { SingleImage } from "../src/slow-image-sources.ts";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
ALIGN_HORIZONTALLY,
|
|
16
|
+
ALIGN_VERTICALLY,
|
|
17
|
+
buildSnapRow,
|
|
18
|
+
} from "./rect-snap.ts";
|
|
15
19
|
import { buildLocalFileRow } from "./local-file-row.ts";
|
|
16
20
|
import { IMAGE_FILE_TYPES, onLocalFilesChange } from "../src/local-files.ts";
|
|
17
21
|
|
|
@@ -63,7 +67,10 @@ export function buildStaticImagePanel(
|
|
|
63
67
|
currentUrl: () => component.urlSchedule.at(0),
|
|
64
68
|
choose(url) {
|
|
65
69
|
if (component.urlSchedule.schedule.length > 1) {
|
|
66
|
-
alert(
|
|
70
|
+
alert(
|
|
71
|
+
"URL has several keyframes. Type the file's URL into the one you want.\n\n" +
|
|
72
|
+
url,
|
|
73
|
+
);
|
|
67
74
|
return;
|
|
68
75
|
}
|
|
69
76
|
component.urlSchedule.set(url);
|
|
@@ -96,12 +103,14 @@ export function buildStaticImagePanel(
|
|
|
96
103
|
const rectButtons = [
|
|
97
104
|
{
|
|
98
105
|
text: "Fit canvas",
|
|
99
|
-
title:
|
|
106
|
+
title:
|
|
107
|
+
"As large as possible while the whole image stays on the canvas. Centered.",
|
|
100
108
|
make: (size: Size) => centeredOnCanvas(maxFit(size.width, size.height)),
|
|
101
109
|
},
|
|
102
110
|
{
|
|
103
111
|
text: "Cover canvas",
|
|
104
|
-
title:
|
|
112
|
+
title:
|
|
113
|
+
"Just large enough to cover the whole canvas. Some of the image will be off screen. Centered.",
|
|
105
114
|
make: (size: Size) => centeredOnCanvas(minCover(size.width, size.height)),
|
|
106
115
|
},
|
|
107
116
|
{
|
|
@@ -110,7 +119,10 @@ export function buildStaticImagePanel(
|
|
|
110
119
|
make: (size: Size, rect: ReadOnlyRect) =>
|
|
111
120
|
sameCenter(preservePixels(size.width, size.height), rect),
|
|
112
121
|
},
|
|
113
|
-
].map(({ text, title, make }) => ({
|
|
122
|
+
].map(({ text, title, make }) => ({
|
|
123
|
+
btn: button(rectRow, text, title),
|
|
124
|
+
make,
|
|
125
|
+
}));
|
|
114
126
|
|
|
115
127
|
/**
|
|
116
128
|
* Snap one edge of the Dest Rect to the canvas, or center it, keeping its
|