canvas-recorder-lib 0.8.0 → 0.8.3
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/BREAKING-CHANGES.md +8 -8
- package/dev/canvas-recorder.css +6 -6
- package/dev/canvas-recorder.ts +62 -10
- package/dev/character-panel.ts +201 -0
- package/dev/delay-files.ts +3 -1
- package/dev/format-editor.ts +36 -0
- package/dev/multi-text-dialog.ts +31 -2
- package/dev/multi-text-panel.ts +6 -0
- package/dev/player-body.ts +3 -3
- package/dev/transcribe-core.ts +7 -4
- package/dev/transcript-align.ts +20 -17
- package/dist/dev/canvas-recorder.css +6 -6
- package/dist/dev/canvas-recorder.js +57 -10
- package/dist/dev/canvas-recorder.js.map +1 -1
- package/dist/dev/character-panel.d.ts +43 -0
- package/dist/dev/character-panel.d.ts.map +1 -0
- package/dist/dev/character-panel.js +133 -0
- package/dist/dev/character-panel.js.map +1 -0
- 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/format-editor.d.ts +16 -0
- package/dist/dev/format-editor.d.ts.map +1 -1
- package/dist/dev/format-editor.js +31 -0
- package/dist/dev/format-editor.js.map +1 -1
- package/dist/dev/multi-text-dialog.d.ts +2 -0
- package/dist/dev/multi-text-dialog.d.ts.map +1 -1
- package/dist/dev/multi-text-dialog.js +26 -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 +6 -0
- 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 +3 -3
- 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 +3 -3
- package/dist/dev/transcript-align.d.ts.map +1 -1
- package/dist/dev/transcript-align.js +16 -13
- package/dist/dev/transcript-align.js.map +1 -1
- package/dist/src/glib/font-choices.d.ts +61 -0
- package/dist/src/glib/font-choices.d.ts.map +1 -0
- package/dist/src/glib/font-choices.js +101 -0
- package/dist/src/glib/font-choices.js.map +1 -0
- package/dist/src/glib/letters-base.d.ts +97 -0
- package/dist/src/glib/letters-base.d.ts.map +1 -1
- package/dist/src/glib/letters-base.js +120 -18
- package/dist/src/glib/letters-base.js.map +1 -1
- package/dist/src/glib/line-font.d.ts +23 -3
- package/dist/src/glib/line-font.d.ts.map +1 -1
- package/dist/src/glib/line-font.js +40 -1
- package/dist/src/glib/line-font.js.map +1 -1
- package/dist/src/glib/path-shape.d.ts +7 -0
- package/dist/src/glib/path-shape.d.ts.map +1 -1
- package/dist/src/glib/path-shape.js +43 -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/slide-components/fourier.d.ts.map +1 -1
- package/dist/src/slide-components/fourier.js +14 -1
- package/dist/src/slide-components/fourier.js.map +1 -1
- package/dist/src/slide-components/halftone-shadow.d.ts.map +1 -1
- package/dist/src/slide-components/halftone-shadow.js +12 -9
- package/dist/src/slide-components/halftone-shadow.js.map +1 -1
- package/dist/src/slide-components/multi-text.d.ts +24 -0
- package/dist/src/slide-components/multi-text.d.ts.map +1 -1
- package/dist/src/slide-components/multi-text.js +75 -5
- package/dist/src/slide-components/multi-text.js.map +1 -1
- package/dist/src/slide-components/registry.d.ts.map +1 -1
- package/dist/src/slide-components/registry.js +3 -2
- 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 +9 -2
- package/dist/src/slide-components/show-error.js.map +1 -1
- package/dist/src/slide-components/simple-text.d.ts +20 -0
- package/dist/src/slide-components/simple-text.d.ts.map +1 -1
- package/dist/src/slide-components/simple-text.js +58 -5
- package/dist/src/slide-components/simple-text.js.map +1 -1
- package/internals.md +402 -406
- package/package.json +1 -1
- package/src/glib/font-choices.ts +132 -0
- package/src/glib/letters-base.ts +212 -18
- package/src/glib/line-font.ts +56 -3
- package/src/glib/path-shape.ts +66 -245
- package/src/glib/svg-arc.ts +141 -0
- package/src/glib/svg-path-parser.ts +308 -0
- package/src/slide-components/fourier.ts +15 -3
- package/src/slide-components/halftone-shadow.ts +12 -9
- package/src/slide-components/multi-text.ts +100 -4
- package/src/slide-components/registry.ts +3 -2
- package/src/slide-components/show-error.ts +9 -2
- package/src/slide-components/simple-text.ts +76 -4
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { ReadOnlyRect } from "phil-lib/misc";
|
|
2
|
-
import {
|
|
2
|
+
import { MIN_FONT_SIZE, MIN_FONT_WIDTH } from "../glib/line-font.ts";
|
|
3
|
+
import {
|
|
4
|
+
checkCharacters,
|
|
5
|
+
FONT_NAMES,
|
|
6
|
+
FontName,
|
|
7
|
+
makeFontByName,
|
|
8
|
+
MissingCharacters,
|
|
9
|
+
} from "../glib/font-choices.ts";
|
|
3
10
|
import { ParagraphLayout } from "../glib/paragraph-layout.ts";
|
|
4
11
|
import {
|
|
5
12
|
ColorScheduleInfo,
|
|
@@ -15,7 +22,9 @@ import { Font } from "../glib/letters-base.ts";
|
|
|
15
22
|
|
|
16
23
|
type CachedFont = {
|
|
17
24
|
readonly font: Font;
|
|
25
|
+
readonly fontName: FontName;
|
|
18
26
|
readonly size: number;
|
|
27
|
+
readonly fontWidth: number;
|
|
19
28
|
readonly boldness: number;
|
|
20
29
|
readonly obliqueness: number;
|
|
21
30
|
};
|
|
@@ -30,7 +39,21 @@ export class TextComponent extends DurationAgnosticComponent {
|
|
|
30
39
|
height: 4,
|
|
31
40
|
});
|
|
32
41
|
readonly textSchedule = new StringScheduleInfo("Text", "Type Here");
|
|
42
|
+
/**
|
|
43
|
+
* Which font: Line Font, Futura L or Cursive. See {@link FONT_NAMES}.
|
|
44
|
+
* Each font has its own set of characters.
|
|
45
|
+
*/
|
|
46
|
+
readonly fontSchedule = new SelectScheduleInfo<FontName, FontName>(
|
|
47
|
+
"Font",
|
|
48
|
+
"Line Font",
|
|
49
|
+
FONT_NAMES,
|
|
50
|
+
);
|
|
33
51
|
readonly sizeSchedule = new NumberScheduleInfo("Size", 1);
|
|
52
|
+
/**
|
|
53
|
+
* How wide the letters are, compared to normal, keeping their height. See
|
|
54
|
+
* {@link Font.stretch}.
|
|
55
|
+
*/
|
|
56
|
+
readonly fontWidthSchedule = new NumberScheduleInfo("Font Width", 1);
|
|
34
57
|
readonly boldnessSchedule = new NumberScheduleInfo("Boldness", 1);
|
|
35
58
|
readonly obliquenessSchedule = new NumberScheduleInfo("Obliqueness", 0);
|
|
36
59
|
readonly alignmentSchedule = new SelectScheduleInfo("Alignment", "left", [
|
|
@@ -47,7 +70,9 @@ export class TextComponent extends DurationAgnosticComponent {
|
|
|
47
70
|
color?: string | readonly Keyframe<string>[];
|
|
48
71
|
rect?: ReadOnlyRect | readonly Keyframe<ReadOnlyRect>[];
|
|
49
72
|
text?: string | readonly Keyframe<string>[];
|
|
73
|
+
font?: FontName | readonly Keyframe<FontName>[];
|
|
50
74
|
size?: number | readonly Keyframe<number>[];
|
|
75
|
+
fontWidth?: number | readonly Keyframe<number>[];
|
|
51
76
|
boldness?: number | readonly Keyframe<number>[];
|
|
52
77
|
obliqueness?: number | readonly Keyframe<number>[];
|
|
53
78
|
// I have mixed feelings on the complicated type definition.
|
|
@@ -68,7 +93,9 @@ export class TextComponent extends DurationAgnosticComponent {
|
|
|
68
93
|
this.colorSchedule,
|
|
69
94
|
this.rectSchedule,
|
|
70
95
|
this.textSchedule,
|
|
96
|
+
this.fontSchedule,
|
|
71
97
|
this.sizeSchedule,
|
|
98
|
+
this.fontWidthSchedule,
|
|
72
99
|
this.boldnessSchedule,
|
|
73
100
|
this.obliquenessSchedule,
|
|
74
101
|
this.alignmentSchedule,
|
|
@@ -82,9 +109,15 @@ export class TextComponent extends DurationAgnosticComponent {
|
|
|
82
109
|
if (initialValues.text !== undefined) {
|
|
83
110
|
this.textSchedule.set(initialValues.text);
|
|
84
111
|
}
|
|
112
|
+
if (initialValues.font !== undefined) {
|
|
113
|
+
this.fontSchedule.set(initialValues.font);
|
|
114
|
+
}
|
|
85
115
|
if (initialValues.size !== undefined) {
|
|
86
116
|
this.sizeSchedule.set(initialValues.size);
|
|
87
117
|
}
|
|
118
|
+
if (initialValues.fontWidth !== undefined) {
|
|
119
|
+
this.fontWidthSchedule.set(initialValues.fontWidth);
|
|
120
|
+
}
|
|
88
121
|
if (initialValues.boldness !== undefined) {
|
|
89
122
|
this.boldnessSchedule.set(initialValues.boldness);
|
|
90
123
|
}
|
|
@@ -95,6 +128,24 @@ export class TextComponent extends DurationAgnosticComponent {
|
|
|
95
128
|
this.alignmentSchedule.set(initialValues.alignmentSchedule);
|
|
96
129
|
}
|
|
97
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Characters in Text that Font can't draw. They're left out, so they never
|
|
133
|
+
* reach the canvas. For the Visual Editor's status.
|
|
134
|
+
*
|
|
135
|
+
* Checked over the whole timeline: at every keyframe of Text and of Font.
|
|
136
|
+
*/
|
|
137
|
+
missingCharacters(): MissingCharacters[] {
|
|
138
|
+
const times = [
|
|
139
|
+
...this.textSchedule.schedule,
|
|
140
|
+
...this.fontSchedule.schedule,
|
|
141
|
+
].map(({ time }) => time);
|
|
142
|
+
return checkCharacters(times, (timeInMs) => [
|
|
143
|
+
{
|
|
144
|
+
text: this.textSchedule.at(timeInMs),
|
|
145
|
+
fontName: this.fontSchedule.at(timeInMs),
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
148
|
+
}
|
|
98
149
|
#cachedFont: undefined | CachedFont;
|
|
99
150
|
#cachedPath:
|
|
100
151
|
| undefined
|
|
@@ -110,19 +161,40 @@ export class TextComponent extends DurationAgnosticComponent {
|
|
|
110
161
|
const color = this.colorSchedule.at(timeInMs);
|
|
111
162
|
const rect = this.rectSchedule.at(timeInMs);
|
|
112
163
|
const text = this.textSchedule.at(timeInMs);
|
|
113
|
-
const
|
|
164
|
+
const fontName = this.fontSchedule.at(timeInMs);
|
|
165
|
+
// 0 or less can't be drawn. Too small to see is the closest thing.
|
|
166
|
+
const size = Math.max(MIN_FONT_SIZE, this.sizeSchedule.at(timeInMs) || 0);
|
|
167
|
+
// 0 or less can't be drawn. As thin as it goes is the closest thing.
|
|
168
|
+
const fontWidth = Math.max(
|
|
169
|
+
MIN_FONT_WIDTH,
|
|
170
|
+
this.fontWidthSchedule.at(timeInMs) || 0,
|
|
171
|
+
);
|
|
114
172
|
const boldness = this.boldnessSchedule.at(timeInMs);
|
|
115
173
|
const obliqueness = this.obliquenessSchedule.at(timeInMs);
|
|
116
174
|
const alignment = this.alignmentSchedule.at(timeInMs);
|
|
117
175
|
context.strokeStyle = color;
|
|
118
176
|
if (
|
|
119
177
|
!this.#cachedFont ||
|
|
178
|
+
this.#cachedFont.fontName != fontName ||
|
|
120
179
|
this.#cachedFont.size != size ||
|
|
180
|
+
this.#cachedFont.fontWidth != fontWidth ||
|
|
121
181
|
this.#cachedFont.boldness != boldness ||
|
|
122
182
|
this.#cachedFont.obliqueness != obliqueness
|
|
123
183
|
) {
|
|
124
|
-
const font =
|
|
125
|
-
|
|
184
|
+
const font = makeFontByName(fontName, {
|
|
185
|
+
size,
|
|
186
|
+
width: fontWidth,
|
|
187
|
+
boldness,
|
|
188
|
+
obliqueness,
|
|
189
|
+
});
|
|
190
|
+
this.#cachedFont = {
|
|
191
|
+
font,
|
|
192
|
+
fontName,
|
|
193
|
+
size,
|
|
194
|
+
fontWidth,
|
|
195
|
+
boldness,
|
|
196
|
+
obliqueness,
|
|
197
|
+
};
|
|
126
198
|
}
|
|
127
199
|
if (
|
|
128
200
|
!this.#cachedPath ||
|