@beff/aula 0.5.1 → 0.6.0
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/dist/engine.d.ts +19 -1
- package/dist/engine.js +51 -7
- package/dist/generated/aula.core5.wasm +0 -0
- package/dist/generated/aula.js +489 -156
- package/dist/generated/interfaces/aula-engine-engine.d.ts +4 -0
- package/dist/manim.d.ts +2 -2
- package/dist/manim.js +1 -1
- package/dist/media.d.ts +4 -3
- package/dist/media.js +5 -4
- package/dist/picture.d.ts +23 -0
- package/dist/picture.js +291 -0
- package/dist/run.d.ts +1 -1
- package/dist/run.js +26 -1
- package/package.json +1 -1
package/dist/engine.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Animation as RawAnimation, Mobject as RawMobject, Rate as RawRate,
|
|
|
2
2
|
import type { Color, Diagnostic, Location, Point, ChapterText as RawChapterText, ParagraphText as RawParagraphText } from "./generated/interfaces/aula-engine-types.js";
|
|
3
3
|
import type { Lexicon } from "./lexicon.ts";
|
|
4
4
|
import type { MediaInfo } from "./media.ts";
|
|
5
|
+
import type { PlacedPicture } from "./picture.ts";
|
|
5
6
|
import type { Theme } from "./theme.ts";
|
|
6
7
|
import { type CapStyleType, type Complex, type LineJointType } from "./utils.ts";
|
|
7
8
|
export type { Instant, Screen, Shown } from "./generated/interfaces/aula-engine-engine.js";
|
|
@@ -1077,6 +1078,20 @@ export declare function gradientColors(colors: readonly Color[], n: number): Col
|
|
|
1077
1078
|
/** House-font text (Manim `Text`). All on-screen words use Text. Its submobjects are the
|
|
1078
1079
|
* glyphs, one for each character that is not whitespace. */
|
|
1079
1080
|
export declare function Text(text: string, opts?: TextOptions): Mobject;
|
|
1081
|
+
/** The options of Image. */
|
|
1082
|
+
export interface ImageOptions {
|
|
1083
|
+
/** The height in scene units (default 2, or what `width` gives). */
|
|
1084
|
+
height?: number;
|
|
1085
|
+
/** The width in scene units. */
|
|
1086
|
+
width?: number;
|
|
1087
|
+
}
|
|
1088
|
+
/** A picture from a file of the project (`m.Image("shot.png")`), an object of the scene like a
|
|
1089
|
+
* shape: it moves, scales, rotates and fades (`fadeIn`, `setOpacity`), and the frame crops it.
|
|
1090
|
+
* The path is from the chapter file and stays inside the project folder (no URLs). PNG, JPEG and
|
|
1091
|
+
* WebP are shown as they are, a GIF shows its first frame, and an SVG is a picture. It is 2 units
|
|
1092
|
+
* high, as wide as the file's ratio gives. `aula check` reports a missing file, an unknown
|
|
1093
|
+
* format and a file that is too large, at this call. A picture has no stroke. */
|
|
1094
|
+
export declare function Image(path: string, opts?: ImageOptions): Mobject;
|
|
1080
1095
|
/** The background panel of Code (Manim's `background_config`). Colours default to the
|
|
1081
1096
|
* formatter style's panel. */
|
|
1082
1097
|
export interface CodeBackgroundConfig {
|
|
@@ -1600,6 +1615,9 @@ export interface ChapterSlot {
|
|
|
1600
1615
|
/** What the file `path` of an `embed` is (a path from the project folder), or why it cannot
|
|
1601
1616
|
* play: the message of the error. */
|
|
1602
1617
|
clip(path: string): MediaInfo | string;
|
|
1618
|
+
/** The picture of the file `path` of an `m.Image` (a path from the chapter file, inside the
|
|
1619
|
+
* project folder), or why it cannot be drawn: the message of the error. */
|
|
1620
|
+
picture(path: string): PlacedPicture | string;
|
|
1603
1621
|
}
|
|
1604
1622
|
/** Reads a chapter: calls `rows` and no move. It gives the text and the text problems; the
|
|
1605
1623
|
* paragraph checks run only in `drawRows`. A chapter error is thrown (a AulaError, a WIT
|
|
@@ -1682,6 +1700,6 @@ export interface SceneRun {
|
|
|
1682
1700
|
frames: number;
|
|
1683
1701
|
trace: Leaf[][];
|
|
1684
1702
|
}
|
|
1685
|
-
/** Draws `draw` as a Manim construct. `s.play` and `s.wait` run from t = 0 at
|
|
1703
|
+
/** Draws `draw` as a Manim construct. `s.play` and `s.wait` run from t = 0 at 60 frames a
|
|
1686
1704
|
* second, on a black background. There is no project, no narration and no heading. */
|
|
1687
1705
|
export declare function renderScene(draw: (s: Scene) => void): SceneRun;
|
package/dist/engine.js
CHANGED
|
@@ -2619,6 +2619,29 @@ export function Text(text, opts = {}) {
|
|
|
2619
2619
|
mob.scaleToFitWidth(width);
|
|
2620
2620
|
return mob;
|
|
2621
2621
|
}
|
|
2622
|
+
/** A picture from a file of the project (`m.Image("shot.png")`), an object of the scene like a
|
|
2623
|
+
* shape: it moves, scales, rotates and fades (`fadeIn`, `setOpacity`), and the frame crops it.
|
|
2624
|
+
* The path is from the chapter file and stays inside the project folder (no URLs). PNG, JPEG and
|
|
2625
|
+
* WebP are shown as they are, a GIF shows its first frame, and an SVG is a picture. It is 2 units
|
|
2626
|
+
* high, as wide as the file's ratio gives. `aula check` reports a missing file, an unknown
|
|
2627
|
+
* format and a file that is too large, at this call. A picture has no stroke. */
|
|
2628
|
+
export function Image(path, opts = {}) {
|
|
2629
|
+
const { height, width } = opts;
|
|
2630
|
+
if (typeof path !== "string")
|
|
2631
|
+
fault("m.Image: the path must be a string", 'm.Image("pictures/shot.png")');
|
|
2632
|
+
if (placing === undefined) {
|
|
2633
|
+
fault(`m.Image(${JSON.stringify(path)}): called outside a chapter`, "make the picture in the rows or in a move of a chapter, which know the project folder");
|
|
2634
|
+
}
|
|
2635
|
+
const found = placing.picture(path);
|
|
2636
|
+
if (typeof found === "string")
|
|
2637
|
+
fault(found);
|
|
2638
|
+
const mob = wrap(engine.image(found.path, found.mime, found.width, found.height, found.bytes));
|
|
2639
|
+
if (height !== undefined)
|
|
2640
|
+
mob.scaleToFitHeight(height);
|
|
2641
|
+
if (width !== undefined)
|
|
2642
|
+
mob.scaleToFitWidth(width);
|
|
2643
|
+
return mob;
|
|
2644
|
+
}
|
|
2622
2645
|
/** Source code with syntax highlighting: Manim's `Code`. Its submobjects are the background,
|
|
2623
2646
|
* the line numbers (with `addLineNumbers`) and the code lines. */
|
|
2624
2647
|
export class CodeMobject extends Mobject {
|
|
@@ -3299,10 +3322,23 @@ function clipFile(slot, path, image) {
|
|
|
3299
3322
|
}
|
|
3300
3323
|
return { tag: "ok", val: { kind: main.kind, seconds: main.seconds } };
|
|
3301
3324
|
}
|
|
3325
|
+
/** The chapter that runs: where `m.Image` looks for its file. */
|
|
3326
|
+
let placing;
|
|
3327
|
+
/** Runs `f` with `slot` as the chapter that runs. */
|
|
3328
|
+
function inSlot(slot, f) {
|
|
3329
|
+
const before = placing;
|
|
3330
|
+
placing = slot;
|
|
3331
|
+
try {
|
|
3332
|
+
return f();
|
|
3333
|
+
}
|
|
3334
|
+
finally {
|
|
3335
|
+
placing = before;
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3302
3338
|
/** The rows of a chapter: a new call of its `rows`, with the seed of `shuffle` at its start. */
|
|
3303
|
-
function rowsOf(chapter) {
|
|
3339
|
+
function rowsOf(chapter, slot) {
|
|
3304
3340
|
freshSeed();
|
|
3305
|
-
return chapter.rows().map((r) => r[ROW]);
|
|
3341
|
+
return inSlot(slot, () => chapter.rows().map((r) => r[ROW]));
|
|
3306
3342
|
}
|
|
3307
3343
|
/** The notes in the engine's form: each key with its values, in the record's order. */
|
|
3308
3344
|
function noteList(notes) {
|
|
@@ -3310,6 +3346,9 @@ function noteList(notes) {
|
|
|
3310
3346
|
}
|
|
3311
3347
|
/** Gives the rows to the engine in order; with a scene, it runs each move after its `show`. */
|
|
3312
3348
|
function write(handle, chapter, rows, slot, scene, card) {
|
|
3349
|
+
inSlot(slot, () => writeRows(handle, chapter, rows, slot, scene, card));
|
|
3350
|
+
}
|
|
3351
|
+
function writeRows(handle, chapter, rows, slot, scene, card) {
|
|
3313
3352
|
handle.lexicon([...slot.lexicon]);
|
|
3314
3353
|
handle.header(placeIn(chapter.headingCall, slot), [...chapter.headingParts], chapter.metaphor);
|
|
3315
3354
|
card?.();
|
|
@@ -3385,7 +3424,9 @@ function playCard(handle, slot, at, card, heading) {
|
|
|
3385
3424
|
};
|
|
3386
3425
|
moving = true;
|
|
3387
3426
|
try {
|
|
3388
|
-
|
|
3427
|
+
inSlot(slot, () => {
|
|
3428
|
+
card(scene, { ...heading, start, end, chrome });
|
|
3429
|
+
});
|
|
3389
3430
|
}
|
|
3390
3431
|
finally {
|
|
3391
3432
|
moving = false;
|
|
@@ -3403,7 +3444,7 @@ function textOf(chapter, rows, slot) {
|
|
|
3403
3444
|
* paragraph checks run only in `drawRows`. A chapter error is thrown (a AulaError, a WIT
|
|
3404
3445
|
* `result` error or the JS error). */
|
|
3405
3446
|
export function readRows(chapter, slot) {
|
|
3406
|
-
const rows = rowsOf(chapter);
|
|
3447
|
+
const rows = rowsOf(chapter, slot);
|
|
3407
3448
|
const { text, problems } = textOf(chapter, rows, slot);
|
|
3408
3449
|
return { text, diagnostics: problems };
|
|
3409
3450
|
}
|
|
@@ -3412,7 +3453,7 @@ export function readRows(chapter, slot) {
|
|
|
3412
3453
|
* and the paragraph checks (with `exists`, `Host.exists`) look at the pictures in order. A
|
|
3413
3454
|
* chapter error is thrown (a AulaError, a WIT `result` error or the JS error). */
|
|
3414
3455
|
export function checkRows(chapter, theme, card, slot, exists) {
|
|
3415
|
-
const rows = rowsOf(chapter);
|
|
3456
|
+
const rows = rowsOf(chapter, slot);
|
|
3416
3457
|
const { text } = textOf(chapter, rows, slot);
|
|
3417
3458
|
const handle = engine.Chapter.orderPass(slot.number, slot.count + 1);
|
|
3418
3459
|
const scene = new Scene(handle, slot);
|
|
@@ -3444,6 +3485,7 @@ export function checkTitleCard(title, theme, card, count) {
|
|
|
3444
3485
|
frames: () => [],
|
|
3445
3486
|
lexicon: [],
|
|
3446
3487
|
clip: () => "no files",
|
|
3488
|
+
picture: () => "a picture needs a project folder",
|
|
3447
3489
|
};
|
|
3448
3490
|
const scene = playCard(handle, slot, { file: "", line: 0, col: 0 }, card, { title, chapter: 0, count, theme });
|
|
3449
3491
|
handle.finish();
|
|
@@ -3467,7 +3509,7 @@ function finished(handle) {
|
|
|
3467
3509
|
* narration waits. A chapter error is thrown (a AulaError, a WIT `result` error or the JS
|
|
3468
3510
|
* error). */
|
|
3469
3511
|
export function drawRows(chapter, theme, card, slot, drawing) {
|
|
3470
|
-
const rows = rowsOf(chapter);
|
|
3512
|
+
const rows = rowsOf(chapter, slot);
|
|
3471
3513
|
const handle = engine.Chapter.render(drawing.narration, theme.background, slot.number, drawing.count, drawing.name, drawing.lint, drawing.prune);
|
|
3472
3514
|
const scene = new Scene(handle, slot);
|
|
3473
3515
|
const heading = { title: chapter.heading, chapter: slot.number, count: slot.count, theme };
|
|
@@ -3489,11 +3531,12 @@ export function drawTitle(title, theme, card, drawing) {
|
|
|
3489
3531
|
frames: () => [],
|
|
3490
3532
|
lexicon: [],
|
|
3491
3533
|
clip: () => "no files",
|
|
3534
|
+
picture: () => "a picture needs a project folder",
|
|
3492
3535
|
};
|
|
3493
3536
|
playCard(handle, slot, { file: "", line: 0, col: 0 }, card, { title, chapter: 0, count, theme });
|
|
3494
3537
|
return finished(handle);
|
|
3495
3538
|
}
|
|
3496
|
-
/** Draws `draw` as a Manim construct. `s.play` and `s.wait` run from t = 0 at
|
|
3539
|
+
/** Draws `draw` as a Manim construct. `s.play` and `s.wait` run from t = 0 at 60 frames a
|
|
3497
3540
|
* second, on a black background. There is no project, no narration and no heading. */
|
|
3498
3541
|
export function renderScene(draw) {
|
|
3499
3542
|
const handle = engine.Chapter.scene();
|
|
@@ -3505,6 +3548,7 @@ export function renderScene(draw) {
|
|
|
3505
3548
|
frames: () => [],
|
|
3506
3549
|
lexicon: [],
|
|
3507
3550
|
clip: () => "no files",
|
|
3551
|
+
picture: () => "a picture needs a project folder",
|
|
3508
3552
|
};
|
|
3509
3553
|
draw(new Scene(handle, slot));
|
|
3510
3554
|
handle.finish();
|
|
Binary file
|