autokast 0.0.0 → 0.1.1

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.
Files changed (79) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +165 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +300 -0
  5. package/dist/index.d.ts +4 -0
  6. package/dist/index.js +4 -0
  7. package/dist/inspect.d.ts +26 -0
  8. package/dist/inspect.js +193 -0
  9. package/dist/record/animations.d.ts +7 -0
  10. package/dist/record/animations.js +34 -0
  11. package/dist/record/capture.d.ts +85 -0
  12. package/dist/record/capture.js +202 -0
  13. package/dist/record/cast.d.ts +142 -0
  14. package/dist/record/cast.js +680 -0
  15. package/dist/record/cursor-style.d.ts +33 -0
  16. package/dist/record/cursor-style.js +252 -0
  17. package/dist/record/defaults.d.ts +96 -0
  18. package/dist/record/defaults.js +125 -0
  19. package/dist/record/editor.d.ts +11 -0
  20. package/dist/record/editor.js +48 -0
  21. package/dist/record/frame-pump.d.ts +91 -0
  22. package/dist/record/frame-pump.js +306 -0
  23. package/dist/record/index.d.ts +11 -0
  24. package/dist/record/index.js +287 -0
  25. package/dist/record/motion.d.ts +48 -0
  26. package/dist/record/motion.js +112 -0
  27. package/dist/record/pace.d.ts +69 -0
  28. package/dist/record/pace.js +133 -0
  29. package/dist/record/random.d.ts +12 -0
  30. package/dist/record/random.js +24 -0
  31. package/dist/record/scroll.d.ts +71 -0
  32. package/dist/record/scroll.js +249 -0
  33. package/dist/record/timeline.d.ts +34 -0
  34. package/dist/record/timeline.js +44 -0
  35. package/dist/render/background.d.ts +12 -0
  36. package/dist/render/background.js +209 -0
  37. package/dist/render/browser.d.ts +46 -0
  38. package/dist/render/browser.js +223 -0
  39. package/dist/render/camera.d.ts +119 -0
  40. package/dist/render/camera.js +372 -0
  41. package/dist/render/captions.d.ts +114 -0
  42. package/dist/render/captions.js +254 -0
  43. package/dist/render/color.d.ts +23 -0
  44. package/dist/render/color.js +78 -0
  45. package/dist/render/compositor.d.ts +185 -0
  46. package/dist/render/compositor.js +656 -0
  47. package/dist/render/cursor.d.ts +85 -0
  48. package/dist/render/cursor.js +314 -0
  49. package/dist/render/cursors/shapes.d.ts +34 -0
  50. package/dist/render/cursors/shapes.js +268 -0
  51. package/dist/render/defaults.d.ts +91 -0
  52. package/dist/render/defaults.js +139 -0
  53. package/dist/render/easing.d.ts +13 -0
  54. package/dist/render/easing.js +40 -0
  55. package/dist/render/effects.d.ts +39 -0
  56. package/dist/render/effects.js +91 -0
  57. package/dist/render/encoder.d.ts +52 -0
  58. package/dist/render/encoder.js +226 -0
  59. package/dist/render/index.d.ts +19 -0
  60. package/dist/render/index.js +138 -0
  61. package/dist/render/keycaps.d.ts +67 -0
  62. package/dist/render/keycaps.js +270 -0
  63. package/dist/render/scene.d.ts +59 -0
  64. package/dist/render/scene.js +230 -0
  65. package/dist/render/source.d.ts +21 -0
  66. package/dist/render/source.js +57 -0
  67. package/dist/render/spring.d.ts +11 -0
  68. package/dist/render/spring.js +47 -0
  69. package/dist/render/stage.d.ts +59 -0
  70. package/dist/render/stage.js +91 -0
  71. package/dist/render/timeline.d.ts +70 -0
  72. package/dist/render/timeline.js +157 -0
  73. package/dist/session.d.ts +14 -0
  74. package/dist/session.js +33 -0
  75. package/dist/types.d.ts +708 -0
  76. package/dist/types.js +1 -0
  77. package/package.json +61 -3
  78. package/skills/autokast/SKILL.md +300 -0
  79. package/skills/autokast/reference/jupyterlab.md +100 -0
@@ -0,0 +1,372 @@
1
+ import { clamp, easing } from "./easing.js";
2
+ import { springStep } from "./spring.js";
3
+ /**
4
+ * Default space around a zoom focus without `scale`, in CSS pixels.
5
+ */
6
+ export const DEFAULT_FOCUS_PADDING = 40;
7
+ /**
8
+ * Follow keeps the cursor this fraction of the visible size away from the edges.
9
+ */
10
+ export const FOLLOW_MARGIN = 0.06;
11
+ /**
12
+ * Angular frequency of the follow spring, in 1/s (settles in about 0.7 s).
13
+ */
14
+ export const FOLLOW_OMEGA = 6;
15
+ /**
16
+ * Follow mode 'cursor': the cursor may move freely inside this central fraction of the
17
+ * visible size; the camera travels when it pushes past, on a calmer spring.
18
+ */
19
+ export const DEAD_ZONE = 0.3;
20
+ export const CURSOR_OMEGA = 5;
21
+ /**
22
+ * The follow mode of a shot: its own `follow` (true is 'edge', false is 'off'), or the
23
+ * render option.
24
+ */
25
+ export function followMode(event, fallback) {
26
+ const f = event?.follow;
27
+ return f === true ? 'edge' : f === false ? 'off' : (f ?? fallback);
28
+ }
29
+ /**
30
+ * The scale a zoom event asks for: `scale`, else its named `level`, else undefined (fit).
31
+ */
32
+ export function zoomScale(event, levels) {
33
+ if (event.scale !== undefined)
34
+ return event.scale;
35
+ if (event.level === undefined)
36
+ return undefined;
37
+ const scale = levels[event.level];
38
+ if (scale === undefined) {
39
+ throw new Error(`Unknown zoom level "${event.level}". Known levels: ${Object.keys(levels).join(', ')}.`);
40
+ }
41
+ return scale;
42
+ }
43
+ /**
44
+ * Moves the center so that the visible rectangle stays inside the viewport.
45
+ */
46
+ export function clampCamera(state, viewport) {
47
+ const hw = viewport.width / (2 * state.scale);
48
+ const hh = viewport.height / (2 * state.scale);
49
+ return {
50
+ scale: state.scale,
51
+ cx: clamp(state.cx, hw, viewport.width - hw),
52
+ cy: clamp(state.cy, hh, viewport.height - hh),
53
+ };
54
+ }
55
+ /**
56
+ * The camera state that a zoom event asks for. `scale` is the magnification relative to
57
+ * the rest view. Without it, the focus plus `padding` fits the region the camera can
58
+ * use, which is `fit` times the rest frame.
59
+ */
60
+ export function zoomTarget(event, viewport, maxScale, fit = { x: 1, y: 1 }) {
61
+ const focus = event.focus;
62
+ if (!focus)
63
+ return { scale: 1, cx: viewport.width / 2, cy: viewport.height / 2 };
64
+ let scale = event.scale;
65
+ if (scale === undefined) {
66
+ const pad = event.padding ?? DEFAULT_FOCUS_PADDING;
67
+ scale = Math.min((viewport.width * fit.x) / Math.max(1, focus.width + 2 * pad), (viewport.height * fit.y) / Math.max(1, focus.height + 2 * pad));
68
+ }
69
+ scale = clamp(scale, 1, maxScale);
70
+ const center = { scale, cx: focus.x + focus.width / 2, cy: focus.y + focus.height / 2 };
71
+ return clampCamera(center, viewport);
72
+ }
73
+ /**
74
+ * Interpolates two camera states. The scale changes geometrically and the center moves
75
+ * so that the zoom pivots on the one page point that has the same screen position in
76
+ * both states, like a pinch zoom: every page point moves on a straight line, with one
77
+ * speed peak. Equal scales give a straight pan. Only the end states are constrained.
78
+ */
79
+ export function interpolateCamera(a, b, e) {
80
+ const r = a.scale / b.scale;
81
+ const lr = Math.log(r);
82
+ const f = Math.abs(lr) < 1e-6 ? e : (1 - Math.exp(lr * e)) / (1 - r);
83
+ return {
84
+ scale: a.scale * Math.exp(-lr * e),
85
+ cx: a.cx + (b.cx - a.cx) * f,
86
+ cy: a.cy + (b.cy - a.cy) * f,
87
+ };
88
+ }
89
+ /**
90
+ * Camera state of a trajectory at output time `t`.
91
+ */
92
+ function evaluate(tr, t) {
93
+ if (tr.kind === 'static')
94
+ return tr.state;
95
+ if (tr.kind === 'coast') {
96
+ const k = (1 - Math.exp((-tr.omega * (t - tr.t0)) / 1000)) / tr.omega;
97
+ const s = tr.state;
98
+ return tr.constrain({ scale: s.scale, cx: s.cx + tr.vx * k, cy: s.cy + tr.vy * k }, t);
99
+ }
100
+ if (t >= tr.t0 + tr.duration)
101
+ return tr.to;
102
+ const e = tr.duration > 0 ? tr.ease((t - tr.t0) / tr.duration) : 1;
103
+ return interpolateCamera(evaluate(tr.from, t), tr.to, e);
104
+ }
105
+ /**
106
+ * Follow targets, by the follow mode of each shot:
107
+ * - 'off': the directed framing (home).
108
+ * - 'edge': home moved by the smallest offset that keeps the cursor `FOLLOW_MARGIN` inside
109
+ * the view (plus room for the cursor body below and right of the hotspot); the offset
110
+ * is 0 again when the cursor is well inside. A cursor-anchored shot has no framing to
111
+ * return to: the view stays where the cursor pushed it.
112
+ * - 'cursor': the view travels with the cursor, which may move freely in a central dead
113
+ * zone; the view never returns home.
114
+ * After each directive the follow waits until the cursor has been inside the home view:
115
+ * a cursor left outside when the zoom started does not pull the camera. NaN during
116
+ * transitions.
117
+ */
118
+ function followTargets(times, active, transitions, cursor, viewport, fallback, constrain) {
119
+ const n = times.length;
120
+ const fx = new Float64Array(n).fill(NaN);
121
+ const fy = new Float64Array(n).fill(NaN);
122
+ const rest = { scale: 1, cx: viewport.width / 2, cy: viewport.height / 2 };
123
+ let segment = -2;
124
+ let engaged = false;
125
+ let ax = rest.cx;
126
+ let ay = rest.cy;
127
+ for (let i = 0; i < n; i++) {
128
+ const tr = active[i] >= 0 ? transitions[active[i]] : null;
129
+ const home = tr ? tr.home : rest;
130
+ if (active[i] !== segment) {
131
+ segment = active[i];
132
+ engaged = false;
133
+ ax = home.cx;
134
+ ay = home.cy;
135
+ }
136
+ const mode = tr ? tr.mode : fallback;
137
+ const s = home.scale;
138
+ const hw = viewport.width / (2 * s);
139
+ const hh = viewport.height / (2 * s);
140
+ const x = cursor ? cursor.x[i] : home.cx;
141
+ const y = cursor ? cursor.y[i] : home.cy;
142
+ if (Math.abs(x - home.cx) <= hw && Math.abs(y - home.cy) <= hh)
143
+ engaged = true;
144
+ if (tr && times[i] < tr.end)
145
+ continue;
146
+ let cx = home.cx;
147
+ let cy = home.cy;
148
+ if (mode !== 'off' && cursor && engaged && s > 1.001) {
149
+ const mx = (FOLLOW_MARGIN * viewport.width) / s;
150
+ const my = (FOLLOW_MARGIN * viewport.height) / s;
151
+ const ext = Math.min(cursor.extent, hw - mx);
152
+ let left = hw - mx;
153
+ let right = hw - mx - ext;
154
+ let up = hh - my;
155
+ let down = hh - my - ext;
156
+ if (mode === 'cursor') {
157
+ left = right = (DEAD_ZONE / 2) * 2 * hw;
158
+ up = down = (DEAD_ZONE / 2) * 2 * hh;
159
+ }
160
+ const accumulate = mode === 'cursor' || tr?.event.anchor === 'cursor';
161
+ const bx = accumulate ? ax : home.cx;
162
+ const by = accumulate ? ay : home.cy;
163
+ cx = x < bx - left ? x + left : x > bx + right ? x - right : bx;
164
+ cy = y < by - up ? y + up : y > by + down ? y - down : by;
165
+ const c = constrain({ scale: s, cx, cy }, times[i]);
166
+ cx = c.cx;
167
+ cy = c.cy;
168
+ if (accumulate) {
169
+ ax = cx;
170
+ ay = cy;
171
+ }
172
+ }
173
+ fx[i] = cx;
174
+ fy[i] = cy;
175
+ }
176
+ return [fx, fy];
177
+ }
178
+ /**
179
+ * Computes the camera for every output frame. A zoom event starts a transition from the
180
+ * current motion (a running transition keeps running underneath, so position and
181
+ * velocity stay continuous). Between transitions, a critically damped spring pans toward
182
+ * the follow target. The spring reads the target 2/omega ahead, which cancels its lag, so
183
+ * the cursor stays in view even during fast moves. A transition lands on the follow target
184
+ * of its end time, so an engaged follow adds no second move.
185
+ */
186
+ export function computeCamera(times, zooms, cursor, viewport, options) {
187
+ const n = times.length;
188
+ const track = {
189
+ scale: new Float64Array(n),
190
+ cx: new Float64Array(n),
191
+ cy: new Float64Array(n),
192
+ };
193
+ const constrain = options.constrain ?? ((state) => clampCamera(state, viewport));
194
+ const speed = options.followSpeed ?? 1;
195
+ const levels = options.levels ?? {};
196
+ const cursorAt = (t) => {
197
+ let i = 0;
198
+ while (i < n - 1 && times[i + 1] <= t)
199
+ i++;
200
+ return cursor ? { x: cursor.x[i], y: cursor.y[i] } : null;
201
+ };
202
+ const transitions = [...zooms]
203
+ .sort((a, b) => a.out - b.out)
204
+ .map((event) => {
205
+ const end = event.out + Math.max(0, event.duration ?? options.duration);
206
+ let focus = event.focus;
207
+ if (event.anchor === 'cursor') {
208
+ const at = focus
209
+ ? { x: focus.x + focus.width / 2, y: focus.y + focus.height / 2 }
210
+ : cursorAt(event.out);
211
+ focus = at && { x: at.x, y: at.y, width: 0, height: 0 };
212
+ }
213
+ const scale = zoomScale(event, levels);
214
+ const target = zoomTarget({ focus, scale, padding: event.padding }, viewport, options.maxScale, options.fit?.(end));
215
+ const home = constrain(target, end);
216
+ const mode = followMode(event, options.follow);
217
+ const omega = (mode === 'cursor' ? CURSOR_OMEGA : FOLLOW_OMEGA) * speed;
218
+ return { t0: event.out, end, event, mode, omega, home, land: home };
219
+ });
220
+ const active = new Int32Array(n).fill(-1);
221
+ for (let i = 0, j = -1; i < n; i++) {
222
+ while (j + 1 < transitions.length && transitions[j + 1].t0 <= times[i])
223
+ j++;
224
+ active[i] = j;
225
+ }
226
+ const [fx, fy] = followTargets(times, active, transitions, cursor, viewport, options.follow, constrain);
227
+ const omegaAt = (i) => active[i] >= 0 ? transitions[active[i]].omega : FOLLOW_OMEGA * speed;
228
+ const lookAhead = (from) => {
229
+ let a = from;
230
+ const lead = 2000 / omegaAt(from);
231
+ while (a + 1 < n &&
232
+ times[a + 1] <= times[from] + lead &&
233
+ active[a + 1] === active[from] &&
234
+ !Number.isNaN(fx[a + 1])) {
235
+ a++;
236
+ }
237
+ return a;
238
+ };
239
+ transitions.forEach((tr, j) => {
240
+ let i = 0;
241
+ while (i < n && (active[i] < j || (active[i] === j && times[i] < tr.end)))
242
+ i++;
243
+ if (i >= n || active[i] !== j || Number.isNaN(fx[i]))
244
+ return;
245
+ const a = lookAhead(i);
246
+ tr.land = constrain({ scale: tr.home.scale, cx: fx[a], cy: fy[a] }, tr.end);
247
+ });
248
+ let state = { scale: 1, cx: viewport.width / 2, cy: viewport.height / 2 };
249
+ let vx = 0;
250
+ let vy = 0;
251
+ let traj = null;
252
+ let current = -1;
253
+ let ahead = 0;
254
+ let prevT = n > 0 ? times[0] : 0;
255
+ for (let i = 0; i < n; i++) {
256
+ const t = times[i];
257
+ while (current < active[i]) {
258
+ const tr = transitions[++current];
259
+ let from;
260
+ if (traj && tr.t0 < traj.t0 + traj.duration)
261
+ from = traj;
262
+ else if (Math.hypot(vx, vy) > 1) {
263
+ from = { kind: 'coast', state, vx, vy, t0: prevT, constrain, omega: omegaAt(i - 1) };
264
+ }
265
+ else
266
+ from = { kind: 'static', state };
267
+ traj = {
268
+ kind: 'transition',
269
+ from,
270
+ to: tr.land,
271
+ t0: tr.t0,
272
+ duration: tr.end - tr.t0,
273
+ ease: easing(tr.event.easing ?? options.easing),
274
+ };
275
+ }
276
+ const dt = Math.max(1e-6, t - prevT) / 1000;
277
+ if (traj && t < traj.t0 + traj.duration) {
278
+ const s = evaluate(traj, t);
279
+ if (i > 0) {
280
+ vx = (s.cx - state.cx) / dt;
281
+ vy = (s.cy - state.cy) / dt;
282
+ }
283
+ state = s;
284
+ }
285
+ else {
286
+ if (traj) {
287
+ state = traj.to;
288
+ traj = null;
289
+ vx = 0;
290
+ vy = 0;
291
+ }
292
+ const omega = omegaAt(i);
293
+ if (ahead < i)
294
+ ahead = i;
295
+ while (ahead + 1 < n &&
296
+ times[ahead + 1] <= t + 2000 / omega &&
297
+ active[ahead + 1] === active[i] &&
298
+ !Number.isNaN(fx[ahead + 1])) {
299
+ ahead++;
300
+ }
301
+ const tx = Number.isNaN(fx[ahead]) ? state.cx : fx[ahead];
302
+ const ty = Number.isNaN(fy[ahead]) ? state.cy : fy[ahead];
303
+ let cx;
304
+ let cy;
305
+ [cx, vx] = springStep(state.cx, vx, tx, omega, dt);
306
+ [cy, vy] = springStep(state.cy, vy, ty, omega, dt);
307
+ const held = constrain({ scale: state.scale, cx, cy }, t);
308
+ if (held.cx !== cx)
309
+ vx = 0;
310
+ if (held.cy !== cy)
311
+ vy = 0;
312
+ state = held;
313
+ }
314
+ track.scale[i] = state.scale;
315
+ track.cx[i] = state.cx;
316
+ track.cy[i] = state.cy;
317
+ prevT = t;
318
+ }
319
+ return track;
320
+ }
321
+ /**
322
+ * Generates zoom events from clicks and typing: zoom in so the camera arrives
323
+ * about 300 ms before the first click, pan when a later click is far away, and
324
+ * zoom out `hold` ms after the last activity.
325
+ */
326
+ export function autoZoomEvents(events, cursorAt, viewport, auto, duration) {
327
+ const lead = 300;
328
+ const acts = [];
329
+ for (const e of events) {
330
+ if (e.type === 'mouseDown' && e.button === 'left') {
331
+ acts.push({ out: e.out, t: e.t, x: e.x, y: e.y });
332
+ }
333
+ else if (e.type === 'key' && e.kind === 'text') {
334
+ acts.push({ out: e.out, t: e.t, ...cursorAt(e.out) });
335
+ }
336
+ }
337
+ const zooms = [];
338
+ const point = (a) => ({ x: a.x, y: a.y, width: 0, height: 0 });
339
+ const visibleW = viewport.width / auto.scale;
340
+ const visibleH = viewport.height / auto.scale;
341
+ let i = 0;
342
+ let free = 0;
343
+ while (i < acts.length) {
344
+ const first = acts[i];
345
+ const start = Math.max(free, first.out - lead - duration);
346
+ zooms.push({ type: 'zoom', t: first.t, out: start, focus: point(first), scale: auto.scale });
347
+ let center = clampCamera({ scale: auto.scale, cx: first.x, cy: first.y }, viewport);
348
+ let last = first;
349
+ let lastZoom = start;
350
+ i++;
351
+ while (i < acts.length) {
352
+ const a = acts[i];
353
+ const joins = a.out - last.out <= auto.mergeWindow ||
354
+ a.out - lead - duration <= last.out + auto.hold + duration;
355
+ if (!joins)
356
+ break;
357
+ const far = Math.abs(a.x - center.cx) > visibleW * 0.3 || Math.abs(a.y - center.cy) > visibleH * 0.3;
358
+ if (far) {
359
+ const out = Math.max(lastZoom + 1, a.out - lead - duration);
360
+ zooms.push({ type: 'zoom', t: a.t, out, focus: point(a), scale: auto.scale });
361
+ center = clampCamera({ scale: auto.scale, cx: a.x, cy: a.y }, viewport);
362
+ lastZoom = out;
363
+ }
364
+ last = a;
365
+ i++;
366
+ }
367
+ const zoomOut = Math.max(lastZoom + 1, last.out + auto.hold);
368
+ zooms.push({ type: 'zoom', t: last.t, out: zoomOut, focus: null });
369
+ free = zoomOut + duration;
370
+ }
371
+ return zooms;
372
+ }
@@ -0,0 +1,114 @@
1
+ import { type SKRSContext2D } from '@napi-rs/canvas';
2
+ import type { CaptionEvent } from '../types.ts';
3
+ import { type Rgba } from './color.ts';
4
+ import type { TimedEvent } from './timeline.ts';
5
+ /**
6
+ * Timing of the caption band and text, in output milliseconds.
7
+ */
8
+ export declare const BAND_DURATION = 700;
9
+ export declare const MERGE_GAP = 600;
10
+ /**
11
+ * One caption with the times its text enters and leaves.
12
+ */
13
+ export interface CaptionCue {
14
+ text: string;
15
+ /**
16
+ * True when `**` marks some of the words of the caption, but not all.
17
+ */
18
+ emphasis: boolean;
19
+ start: number;
20
+ end: number;
21
+ textIn: number;
22
+ textOut: number;
23
+ }
24
+ /**
25
+ * A run of captions that keeps the band open: it opens at `open` and closes at `close`.
26
+ */
27
+ export interface BandGroup {
28
+ open: number;
29
+ close: number;
30
+ }
31
+ /**
32
+ * Plans caption cues and band groups. Captions within MERGE_GAP of each other share
33
+ * one open band and only swap their text. `split` breaks the text of a caption into
34
+ * lines: a caption shows one line at a time, and its lines share its duration.
35
+ */
36
+ export declare function planCaptions(events: TimedEvent<CaptionEvent>[], split?: (text: string) => string[]): {
37
+ cues: CaptionCue[];
38
+ groups: BandGroup[];
39
+ };
40
+ /**
41
+ * How far the band is open at output time `t`, 0 to 1 (already eased).
42
+ */
43
+ export declare function bandAt(groups: BandGroup[], t: number): number;
44
+ export declare function bandTrack(times: ArrayLike<number>, groups: BandGroup[]): Float64Array;
45
+ /**
46
+ * Line height of a caption, in font sizes.
47
+ */
48
+ export declare const LINE_HEIGHT = 1.18;
49
+ /**
50
+ * Share of the window width that a caption can take.
51
+ */
52
+ export declare const CAPTION_WIDTH = 0.72;
53
+ /**
54
+ * A part of a word in one tone. `x` is its offset from the start of the line.
55
+ */
56
+ export interface CaptionRun {
57
+ text: string;
58
+ x: number;
59
+ strong: boolean;
60
+ }
61
+ /**
62
+ * One line of caption text, laid out.
63
+ */
64
+ export interface CaptionLine {
65
+ fontSize: number;
66
+ text: string;
67
+ width: number;
68
+ runs: CaptionRun[];
69
+ }
70
+ interface ParsedWord {
71
+ text: string;
72
+ runs: {
73
+ text: string;
74
+ strong: boolean;
75
+ }[];
76
+ }
77
+ /**
78
+ * Splits caption text into words. `**` starts and ends the emphasis and is not shown.
79
+ */
80
+ export declare function parseCaption(text: string): ParsedWord[];
81
+ /**
82
+ * Breaks caption text into lines no wider than `maxWidth`, each with its `**` marks: the
83
+ * fewest lines, of about the same width. `measure(text, fontSize)` returns a width in
84
+ * pixels. A word wider than `maxWidth` has a line of its own.
85
+ */
86
+ export declare function splitCaption(text: string, measure: (text: string, fontSize: number) => number, maxWidth: number, fontSize: number): string[];
87
+ /**
88
+ * Lays out one line of caption text. The font shrinks only when the line is wider than
89
+ * `maxWidth`, which `splitCaption` prevents for all text but one very long word.
90
+ */
91
+ export declare function layoutCaption(text: string, measure: (text: string, fontSize: number) => number, maxWidth: number, fontSize: number): CaptionLine;
92
+ export interface CaptionStyle {
93
+ family: string;
94
+ fontSize: number;
95
+ color: Rgba;
96
+ unit: number;
97
+ }
98
+ export declare function captionFont(style: Pick<CaptionStyle, 'family'>, size: number): string;
99
+ /**
100
+ * Tracking for a font size: -1.5% of the size for the text.
101
+ */
102
+ export declare function tracking(size: number): string;
103
+ /**
104
+ * Width of text in the caption font, for `splitCaption` and `layoutCaption`.
105
+ */
106
+ export declare function captionMeasure(family: string): (text: string, size: number) => number;
107
+ /**
108
+ * Draws a caption line with its top-left corner at (x, top) in output pixels. The text
109
+ * comes into focus from left to right: behind a soft edge that crosses the line it is
110
+ * sharp, inside the edge it is blurred and faint. Words outside the emphasis have a lower
111
+ * tone. On exit the line goes out of focus and fades with a small upward drift.
112
+ */
113
+ export declare function drawCaption(ctx: SKRSContext2D, cue: CaptionCue, line: CaptionLine, style: CaptionStyle, x: number, top: number, t: number): void;
114
+ export {};