@beff/aula 0.8.2 → 0.9.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/generated/aula.core5.wasm +0 -0
- package/dist/index.d.ts +7304 -6
- package/dist/index.js +14864 -11
- package/dist/index.js.map +1 -0
- package/package.json +8 -25
- package/dist/animations.d.ts +0 -635
- package/dist/animations.js +0 -1778
- package/dist/braces.d.ts +0 -84
- package/dist/braces.js +0 -253
- package/dist/card.d.ts +0 -17
- package/dist/card.js +0 -90
- package/dist/colors-palette.d.ts +0 -2242
- package/dist/colors-palette.js +0 -2241
- package/dist/colors.d.ts +0 -120
- package/dist/colors.js +0 -403
- package/dist/curves.d.ts +0 -10
- package/dist/curves.js +0 -128
- package/dist/engine.d.ts +0 -1705
- package/dist/engine.js +0 -3561
- package/dist/errors.d.ts +0 -19
- package/dist/errors.js +0 -25
- package/dist/geometry.d.ts +0 -551
- package/dist/geometry.js +0 -1555
- package/dist/graph.d.ts +0 -117
- package/dist/graph.js +0 -526
- package/dist/graphing.d.ts +0 -597
- package/dist/graphing.js +0 -1504
- package/dist/host.d.ts +0 -19
- package/dist/host.js +0 -85
- package/dist/lexicon.d.ts +0 -10
- package/dist/lexicon.js +0 -23
- package/dist/load.d.ts +0 -21
- package/dist/load.js +0 -109
- package/dist/logo.d.ts +0 -30
- package/dist/logo.js +0 -186
- package/dist/manim.d.ts +0 -22
- package/dist/manim.js +0 -19
- package/dist/media.d.ts +0 -34
- package/dist/media.js +0 -391
- package/dist/mobjects.d.ts +0 -127
- package/dist/mobjects.js +0 -316
- package/dist/picture.d.ts +0 -23
- package/dist/picture.js +0 -291
- package/dist/pointcloud.d.ts +0 -144
- package/dist/pointcloud.js +0 -384
- package/dist/rates.d.ts +0 -19
- package/dist/rates.js +0 -54
- package/dist/run.d.ts +0 -101
- package/dist/run.js +0 -323
- package/dist/tables.d.ts +0 -179
- package/dist/tables.js +0 -403
- package/dist/tex.d.ts +0 -8
- package/dist/tex.js +0 -257
- package/dist/text-layouts.d.ts +0 -64
- package/dist/text-layouts.js +0 -225
- package/dist/text.d.ts +0 -61
- package/dist/text.js +0 -78
- package/dist/theme.d.ts +0 -25
- package/dist/theme.js +0 -12
- package/dist/user-code.d.ts +0 -5
- package/dist/user-code.js +0 -20
- package/dist/utils.d.ts +0 -152
- package/dist/utils.js +0 -517
- package/dist/vector-field.d.ts +0 -132
- package/dist/vector-field.js +0 -361
package/dist/braces.d.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { type Animation, type MathTexMobject, type Point, type StyleOptions, Mobject } from "./engine.ts";
|
|
2
|
-
import type { Mobject as RawMobject } from "./generated/interfaces/aula-engine-engine.js";
|
|
3
|
-
/** The options of `putAtTip`, `getText` and `getTex` of a Brace. */
|
|
4
|
-
export interface PutAtTipOptions {
|
|
5
|
-
/** True (the default): `nextTo` the tip. False: the centre goes out from the tip. */
|
|
6
|
-
useNextTo?: boolean;
|
|
7
|
-
buff?: number;
|
|
8
|
-
alignedEdge?: Point;
|
|
9
|
-
}
|
|
10
|
-
/** A brace: Manim's `Brace`, with its label methods. */
|
|
11
|
-
export declare class BraceMobject extends Mobject {
|
|
12
|
-
#private;
|
|
13
|
-
constructor(handle: RawMobject, tip: number);
|
|
14
|
-
copy(): BraceMobject;
|
|
15
|
-
/** The point of the tip (Manim `get_tip`). */
|
|
16
|
-
getTip(): Point;
|
|
17
|
-
/** The unit vector from the centre to the tip (Manim `get_direction`). */
|
|
18
|
-
getDirection(): Point;
|
|
19
|
-
/** Puts `mob` at the tip and returns the brace (Manim `put_at_tip`). */
|
|
20
|
-
putAtTip(mob: Mobject, opts?: PutAtTipOptions): this;
|
|
21
|
-
/** A `Tex` of the strings, at the tip (Manim `get_text`). */
|
|
22
|
-
getText(...text: (string | PutAtTipOptions)[]): MathTexMobject;
|
|
23
|
-
/** A `MathTex` of the strings, at the tip (Manim `get_tex`). */
|
|
24
|
-
getTex(...tex: (string | PutAtTipOptions)[]): MathTexMobject;
|
|
25
|
-
}
|
|
26
|
-
/** A brace as a type: what Brace returns. */
|
|
27
|
-
export type Brace = BraceMobject;
|
|
28
|
-
/** The options of Brace (Manim's keyword arguments). */
|
|
29
|
-
export interface BraceOptions extends StyleOptions {
|
|
30
|
-
buff?: number;
|
|
31
|
-
/** Larger values make the straight parts longer and the curves shorter. */
|
|
32
|
-
sharpness?: number;
|
|
33
|
-
}
|
|
34
|
-
/** A curly brace `buff` from `mobject`, on its side in `direction` (any direction), as wide as
|
|
35
|
-
* the mobject seen from there (Manim `Brace`, with Manim's outline). */
|
|
36
|
-
export declare function Brace(mobject: Mobject, direction?: Point, opts?: BraceOptions): BraceMobject;
|
|
37
|
-
/** A brace along the line from `point1` to `point2` (Manim `BraceBetweenPoints`). With no
|
|
38
|
-
* `direction`, it is on the right of the way from `point1` to `point2`. */
|
|
39
|
-
export declare function BraceBetweenPoints(point1: Point, point2: Point, direction?: Point, opts?: BraceOptions): BraceMobject;
|
|
40
|
-
/** A brace bent along `arc` (Manim `ArcBrace`): `m.RIGHT` (the default) outside, `m.LEFT`
|
|
41
|
-
* inside. */
|
|
42
|
-
export declare function ArcBrace(arc?: Mobject, direction?: Point, opts?: BraceOptions): BraceMobject;
|
|
43
|
-
/** A label maker of BraceLabel: `m.MathTex`, `m.Tex` or `m.Text`. */
|
|
44
|
-
export type LabelConstructor = (text: string, opts: {
|
|
45
|
-
fontSize?: number;
|
|
46
|
-
}) => Mobject;
|
|
47
|
-
/** The options of BraceLabel (Manim's keyword arguments). */
|
|
48
|
-
export interface BraceLabelOptions {
|
|
49
|
-
braceDirection?: Point;
|
|
50
|
-
labelConstructor?: LabelConstructor;
|
|
51
|
-
fontSize?: number;
|
|
52
|
-
buff?: number;
|
|
53
|
-
braceConfig?: BraceOptions;
|
|
54
|
-
}
|
|
55
|
-
/** A brace and its label: Manim's `BraceLabel`. */
|
|
56
|
-
export declare class BraceLabelMobject extends Mobject {
|
|
57
|
-
#private;
|
|
58
|
-
brace: BraceMobject;
|
|
59
|
-
label: Mobject;
|
|
60
|
-
readonly braceDirection: Point;
|
|
61
|
-
readonly labelConstructor: LabelConstructor;
|
|
62
|
-
constructor(handle: RawMobject, parts: {
|
|
63
|
-
brace: BraceMobject;
|
|
64
|
-
label: Mobject;
|
|
65
|
-
}, o: Required<Omit<BraceLabelOptions, "buff" | "braceConfig">>);
|
|
66
|
-
copy(): BraceLabelMobject;
|
|
67
|
-
/** `braceAnim(brace)` with `labelAnim(label)` (Manim `creation_anim`). */
|
|
68
|
-
creationAnim(labelAnim?: (m: Mobject) => Animation, braceAnim?: (m: Mobject) => Animation): Animation;
|
|
69
|
-
/** A new brace on `obj` (an array is grouped), with the label at its tip (Manim `shift_brace`). */
|
|
70
|
-
shiftBrace(obj: Mobject | readonly Mobject[], opts?: BraceOptions): this;
|
|
71
|
-
/** A new label of the strings, at the tip (Manim `change_label`). */
|
|
72
|
-
changeLabel(...text: (string | {
|
|
73
|
-
fontSize?: number;
|
|
74
|
-
})[]): this;
|
|
75
|
-
/** `shiftBrace(obj)` then `changeLabel(...text)` (Manim `change_brace_label`). */
|
|
76
|
-
changeBraceLabel(obj: Mobject | readonly Mobject[], ...text: (string | {
|
|
77
|
-
fontSize?: number;
|
|
78
|
-
})[]): this;
|
|
79
|
-
}
|
|
80
|
-
/** Manim's `BraceLabel(obj, text, { braceDirection, labelConstructor, fontSize, buff, braceConfig })`:
|
|
81
|
-
* a brace on `obj` and a `MathTex` label at its tip. */
|
|
82
|
-
export declare function BraceLabel(obj: Mobject, text: string | readonly string[], opts?: BraceLabelOptions): BraceLabelMobject;
|
|
83
|
-
/** `BraceLabel` with a `Text` label (Manim `BraceText`). */
|
|
84
|
-
export declare function BraceText(obj: Mobject, text: string, opts?: BraceLabelOptions): BraceLabelMobject;
|
package/dist/braces.js
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
// Manim CE's braces: Brace (with CE's outline, in any direction), BraceBetweenPoints, ArcBrace,
|
|
2
|
-
// BraceLabel and BraceText.
|
|
3
|
-
import { DL, DOWN, DR, MED_SMALL_BUFF, MathTex, Mobject, ORIGIN, PI, Polyline, Tex, Text, UL, VGroup, WHITE, add, mul, norm, raw, split, sub, } from "./engine.js";
|
|
4
|
-
import { FadeIn, GrowFromCenter, AnimationGroup } from "./animations.js";
|
|
5
|
-
import { Arc, Line } from "./geometry.js";
|
|
6
|
-
import { engine } from "./load.js";
|
|
7
|
-
/** Manim's brace outline, an SVG path; `{0}` and `{1}` are the lengths of the straight parts. */
|
|
8
|
-
const BRACE_PATH = "m0.01216 0c-0.01152 0-0.01216 6.103e-4 -0.01216 0.01311v0.007762c0.06776 0.122 0.1799 0.1455 " +
|
|
9
|
-
"0.2307 0.1455h{0}c0.03046 3.899e-4 0.07964 0.00449 0.1246 0.02636 0.0537 0.02695 0.07418 " +
|
|
10
|
-
"0.05816 0.08648 0.07769 0.001562 0.002538 0.004539 0.002563 0.01098 0.002563 0.006444-2e-8 " +
|
|
11
|
-
"0.009421-2.47e-5 0.01098-0.002563 0.0123-0.01953 0.03278-0.05074 0.08648-0.07769 0.04491" +
|
|
12
|
-
"-0.02187 0.09409-0.02597 0.1246-0.02636h{0}c0.05077 0 0.1629-0.02346 0.2307-0.1455v-0.007762" +
|
|
13
|
-
"c-1.78e-6 -0.0125-6.365e-4 -0.01311-0.01216-0.01311-0.006444-3.919e-8 -0.009348 2.448e-5 " +
|
|
14
|
-
"-0.01091 0.002563-0.0123 0.01953-0.03278 0.05074-0.08648 0.07769-0.04491 0.02187-0.09416 " +
|
|
15
|
-
"0.02597-0.1246 0.02636h{1}c-0.04786 0-0.1502 0.02094-0.2185 0.1256-0.06833-0.1046-0.1706" +
|
|
16
|
-
"-0.1256-0.2185-0.1256h{1}c-0.03046-3.899e-4 -0.07972-0.004491-0.1246-0.02636-0.0537-0.02695" +
|
|
17
|
-
"-0.07418-0.05816-0.08648-0.07769-0.001562-0.002538-0.004467-0.002563-0.01091-0.002563z";
|
|
18
|
-
/** The width of the outline with no straight parts (Manim's `default_min_width`). */
|
|
19
|
-
const MIN_WIDTH = 0.90552;
|
|
20
|
-
/** The control points of a relative SVG path with `m`, `c`, `h`, `v` and `z`, four for each
|
|
21
|
-
* curve, with y up (the SVG's y is down). */
|
|
22
|
-
function svgPoints(d) {
|
|
23
|
-
const tokens = d.match(/[mchvz]|-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?/g) ?? [];
|
|
24
|
-
const out = [];
|
|
25
|
-
let pen = [0, 0];
|
|
26
|
-
let start = [0, 0];
|
|
27
|
-
let command = "";
|
|
28
|
-
let i = 0;
|
|
29
|
-
const num = () => Number(tokens[i++]);
|
|
30
|
-
const line = (to) => {
|
|
31
|
-
out.push(pen, add(pen, mul(sub(to, pen), 1 / 3)), add(pen, mul(sub(to, pen), 2 / 3)), to);
|
|
32
|
-
pen = to;
|
|
33
|
-
};
|
|
34
|
-
while (i < tokens.length) {
|
|
35
|
-
const t = tokens[i] ?? "";
|
|
36
|
-
if (/[mchvz]/.test(t)) {
|
|
37
|
-
command = t;
|
|
38
|
-
i++;
|
|
39
|
-
if (command === "z") {
|
|
40
|
-
if (norm(sub(pen, start)) > 1e-9)
|
|
41
|
-
line(start);
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (command === "m") {
|
|
46
|
-
pen = add(pen, [num(), num()]);
|
|
47
|
-
start = pen;
|
|
48
|
-
command = "l";
|
|
49
|
-
}
|
|
50
|
-
else if (command === "c") {
|
|
51
|
-
const [a, b, c] = [add(pen, [num(), num()]), add(pen, [num(), num()]), add(pen, [num(), num()])];
|
|
52
|
-
out.push(pen, a, b, c);
|
|
53
|
-
pen = c;
|
|
54
|
-
}
|
|
55
|
-
else if (command === "h")
|
|
56
|
-
line(add(pen, [num(), 0]));
|
|
57
|
-
else if (command === "v")
|
|
58
|
-
line(add(pen, [0, num()]));
|
|
59
|
-
else
|
|
60
|
-
i++;
|
|
61
|
-
}
|
|
62
|
-
return out.map(([x, y]) => [x, -y]);
|
|
63
|
-
}
|
|
64
|
-
/** A brace: Manim's `Brace`, with its label methods. */
|
|
65
|
-
export class BraceMobject extends Mobject {
|
|
66
|
-
#tip;
|
|
67
|
-
constructor(handle, tip) {
|
|
68
|
-
super(handle);
|
|
69
|
-
this.#tip = tip;
|
|
70
|
-
}
|
|
71
|
-
copy() {
|
|
72
|
-
return new BraceMobject(raw(this).copy(), this.#tip);
|
|
73
|
-
}
|
|
74
|
-
/** The point of the tip (Manim `get_tip`). */
|
|
75
|
-
getTip() {
|
|
76
|
-
return this.getPoints()[this.#tip] ?? this.getCenter();
|
|
77
|
-
}
|
|
78
|
-
/** The unit vector from the centre to the tip (Manim `get_direction`). */
|
|
79
|
-
getDirection() {
|
|
80
|
-
const v = sub(this.getTip(), this.getCenter());
|
|
81
|
-
const n = norm(v);
|
|
82
|
-
return n === 0 ? DOWN : mul(v, 1 / n);
|
|
83
|
-
}
|
|
84
|
-
/** Puts `mob` at the tip and returns the brace (Manim `put_at_tip`). */
|
|
85
|
-
putAtTip(mob, opts = {}) {
|
|
86
|
-
const { useNextTo = true, buff = MED_SMALL_BUFF, alignedEdge } = opts;
|
|
87
|
-
const d = this.getDirection();
|
|
88
|
-
if (useNextTo) {
|
|
89
|
-
mob.nextTo(this.getTip(), [Math.round(d[0]), Math.round(d[1])], {
|
|
90
|
-
buff,
|
|
91
|
-
...(alignedEdge === undefined ? {} : { alignedEdge }),
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
else
|
|
95
|
-
mob.moveTo(this.getTip()).shift(mul(d, mob.width / 2 + buff));
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
/** A `Tex` of the strings, at the tip (Manim `get_text`). */
|
|
99
|
-
getText(...text) {
|
|
100
|
-
const [strings, o] = split(text);
|
|
101
|
-
const label = Tex(...strings);
|
|
102
|
-
this.putAtTip(label, o);
|
|
103
|
-
return label;
|
|
104
|
-
}
|
|
105
|
-
/** A `MathTex` of the strings, at the tip (Manim `get_tex`). */
|
|
106
|
-
getTex(...tex) {
|
|
107
|
-
const [strings, o] = split(tex);
|
|
108
|
-
const label = MathTex(...strings);
|
|
109
|
-
this.putAtTip(label, o);
|
|
110
|
-
return label;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/** A curly brace `buff` from `mobject`, on its side in `direction` (any direction), as wide as
|
|
114
|
-
* the mobject seen from there (Manim `Brace`, with Manim's outline). */
|
|
115
|
-
export function Brace(mobject, direction = DOWN, opts = {}) {
|
|
116
|
-
const { buff = 0.2, sharpness = 2, strokeWidth = 0, fillOpacity = 1, color = WHITE, ...style } = opts;
|
|
117
|
-
const angle = -Math.atan2(direction[0], direction[1]) + PI;
|
|
118
|
-
const turned = mobject.copy().rotate(-angle, { aboutPoint: ORIGIN });
|
|
119
|
-
const left = turned.getCorner(DL);
|
|
120
|
-
const targetWidth = turned.getCorner(DR)[0] - left[0];
|
|
121
|
-
const linear = Math.max(0, (targetWidth * sharpness - MIN_WIDTH) / 2);
|
|
122
|
-
const points = svgPoints(BRACE_PATH.replaceAll("{0}", String(linear)).replaceAll("{1}", String(-linear)));
|
|
123
|
-
const outline = Polyline([0, 0], [1, 0]).setPoints(points);
|
|
124
|
-
const bottom = outline.getBottom();
|
|
125
|
-
const tip = points.reduce((best, p, i) => (norm(sub(p, bottom)) < norm(sub(points[best] ?? p, bottom)) ? i : best), 0);
|
|
126
|
-
outline.setColor(color);
|
|
127
|
-
outline.setFill(style.fillColor ?? color, { opacity: fillOpacity });
|
|
128
|
-
outline.setStroke(style.strokeColor ?? color, { width: strokeWidth, opacity: style.strokeOpacity ?? 1 });
|
|
129
|
-
outline.stretchToFitWidth(targetWidth);
|
|
130
|
-
outline.shift(add(sub(left, outline.getCorner(UL)), mul(DOWN, buff)));
|
|
131
|
-
outline.rotate(angle, { aboutPoint: ORIGIN });
|
|
132
|
-
return new BraceMobject(raw(outline), tip);
|
|
133
|
-
}
|
|
134
|
-
/** A brace along the line from `point1` to `point2` (Manim `BraceBetweenPoints`). With no
|
|
135
|
-
* `direction`, it is on the right of the way from `point1` to `point2`. */
|
|
136
|
-
export function BraceBetweenPoints(point1, point2, direction = ORIGIN, opts = {}) {
|
|
137
|
-
const v = sub(point2, point1);
|
|
138
|
-
const d = direction[0] === 0 && direction[1] === 0 ? [v[1], -v[0]] : direction;
|
|
139
|
-
return Brace(Line(point1, point2), d, opts);
|
|
140
|
-
}
|
|
141
|
-
const sq = (q) => q[0] * q[0] + q[1] * q[1];
|
|
142
|
-
/** The centre, radius, start angle and signed angle of an arc, from its points. */
|
|
143
|
-
function arcGeometry(arc) {
|
|
144
|
-
const p = (t) => arc.pointFromProportion(t);
|
|
145
|
-
const [a, b, c] = [p(0), p(1 / 3), p(2 / 3)];
|
|
146
|
-
const d = 2 * (a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1]));
|
|
147
|
-
const center = [
|
|
148
|
-
(sq(a) * (b[1] - c[1]) + sq(b) * (c[1] - a[1]) + sq(c) * (a[1] - b[1])) / d,
|
|
149
|
-
(sq(a) * (c[0] - b[0]) + sq(b) * (a[0] - c[0]) + sq(c) * (b[0] - a[0])) / d,
|
|
150
|
-
];
|
|
151
|
-
const at = (q) => Math.atan2(q[1] - center[1], q[0] - center[0]);
|
|
152
|
-
let angle = 0;
|
|
153
|
-
let prev = at(a);
|
|
154
|
-
for (let i = 1; i <= 64; i++) {
|
|
155
|
-
const next = at(p(i / 64));
|
|
156
|
-
let step = next - prev;
|
|
157
|
-
while (step > PI)
|
|
158
|
-
step -= 2 * PI;
|
|
159
|
-
while (step < -PI)
|
|
160
|
-
step += 2 * PI;
|
|
161
|
-
angle += step;
|
|
162
|
-
prev = next;
|
|
163
|
-
}
|
|
164
|
-
return { center, radius: norm(sub(a, center)), startAngle: at(a), angle };
|
|
165
|
-
}
|
|
166
|
-
/** A brace bent along `arc` (Manim `ArcBrace`): `m.RIGHT` (the default) outside, `m.LEFT`
|
|
167
|
-
* inside. */
|
|
168
|
-
export function ArcBrace(arc, direction = [1, 0], opts = {}) {
|
|
169
|
-
const shape = arc ?? Arc({ startAngle: -1, angle: 2, radius: 1 });
|
|
170
|
-
const { center, radius, startAngle, angle } = arcGeometry(shape);
|
|
171
|
-
const line = Line([0, startAngle], [0, startAngle + angle]);
|
|
172
|
-
let brace;
|
|
173
|
-
if (radius >= 1) {
|
|
174
|
-
line.scale(radius, { aboutPoint: ORIGIN });
|
|
175
|
-
brace = Brace(line, direction, opts);
|
|
176
|
-
brace.scale(1 / radius, { aboutPoint: ORIGIN });
|
|
177
|
-
}
|
|
178
|
-
else
|
|
179
|
-
brace = Brace(line, direction, opts);
|
|
180
|
-
brace.shift([Math.log(Math.max(radius, 0.3)), 0]);
|
|
181
|
-
brace.applyFunction(([x, y]) => [Math.exp(x) * Math.cos(y), Math.exp(x) * Math.sin(y)]);
|
|
182
|
-
return brace.shift(center);
|
|
183
|
-
}
|
|
184
|
-
/** A brace and its label: Manim's `BraceLabel`. */
|
|
185
|
-
export class BraceLabelMobject extends Mobject {
|
|
186
|
-
brace;
|
|
187
|
-
label;
|
|
188
|
-
braceDirection;
|
|
189
|
-
labelConstructor;
|
|
190
|
-
#fontSize;
|
|
191
|
-
constructor(handle, parts, o) {
|
|
192
|
-
super(handle);
|
|
193
|
-
this.brace = parts.brace;
|
|
194
|
-
this.label = parts.label;
|
|
195
|
-
this.braceDirection = o.braceDirection;
|
|
196
|
-
this.labelConstructor = o.labelConstructor;
|
|
197
|
-
this.#fontSize = o.fontSize;
|
|
198
|
-
}
|
|
199
|
-
copy() {
|
|
200
|
-
const handle = raw(this).copy();
|
|
201
|
-
const c = new BraceLabelMobject(handle, { brace: this.brace, label: this.label }, {
|
|
202
|
-
braceDirection: this.braceDirection,
|
|
203
|
-
labelConstructor: this.labelConstructor,
|
|
204
|
-
fontSize: this.#fontSize,
|
|
205
|
-
});
|
|
206
|
-
const [brace, label] = c.submobjects;
|
|
207
|
-
if (brace instanceof BraceMobject)
|
|
208
|
-
c.brace = brace;
|
|
209
|
-
if (label !== undefined)
|
|
210
|
-
c.label = label;
|
|
211
|
-
return c;
|
|
212
|
-
}
|
|
213
|
-
/** `braceAnim(brace)` with `labelAnim(label)` (Manim `creation_anim`). */
|
|
214
|
-
creationAnim(labelAnim = FadeIn, braceAnim = GrowFromCenter) {
|
|
215
|
-
return AnimationGroup(braceAnim(this.brace), labelAnim(this.label));
|
|
216
|
-
}
|
|
217
|
-
/** A new brace on `obj` (an array is grouped), with the label at its tip (Manim `shift_brace`). */
|
|
218
|
-
shiftBrace(obj, opts = {}) {
|
|
219
|
-
const target = obj instanceof Mobject ? obj : VGroup(obj);
|
|
220
|
-
const brace = Brace(target, this.braceDirection, opts);
|
|
221
|
-
this.remove(this.brace);
|
|
222
|
-
this.brace = brace;
|
|
223
|
-
brace.putAtTip(this.label);
|
|
224
|
-
this.add(brace);
|
|
225
|
-
return this;
|
|
226
|
-
}
|
|
227
|
-
/** A new label of the strings, at the tip (Manim `change_label`). */
|
|
228
|
-
changeLabel(...text) {
|
|
229
|
-
const [strings, o = {}] = split(text);
|
|
230
|
-
this.remove(this.label);
|
|
231
|
-
this.label = this.labelConstructor(strings.join(" "), { fontSize: o.fontSize ?? this.#fontSize });
|
|
232
|
-
this.brace.putAtTip(this.label);
|
|
233
|
-
this.add(this.label);
|
|
234
|
-
return this;
|
|
235
|
-
}
|
|
236
|
-
/** `shiftBrace(obj)` then `changeLabel(...text)` (Manim `change_brace_label`). */
|
|
237
|
-
changeBraceLabel(obj, ...text) {
|
|
238
|
-
return this.shiftBrace(obj).changeLabel(...text);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
/** Manim's `BraceLabel(obj, text, { braceDirection, labelConstructor, fontSize, buff, braceConfig })`:
|
|
242
|
-
* a brace on `obj` and a `MathTex` label at its tip. */
|
|
243
|
-
export function BraceLabel(obj, text, opts = {}) {
|
|
244
|
-
const { braceDirection = DOWN, labelConstructor = (t, o) => MathTex(t, o), fontSize = 48, buff = 0.2, braceConfig = {}, } = opts;
|
|
245
|
-
const brace = Brace(obj, braceDirection, { buff, ...braceConfig });
|
|
246
|
-
const label = labelConstructor(typeof text === "string" ? text : text.join(" "), { fontSize });
|
|
247
|
-
brace.putAtTip(label);
|
|
248
|
-
return new BraceLabelMobject(engine.vGroup([raw(brace), raw(label)]), { brace, label }, { braceDirection, labelConstructor, fontSize });
|
|
249
|
-
}
|
|
250
|
-
/** `BraceLabel` with a `Text` label (Manim `BraceText`). */
|
|
251
|
-
export function BraceText(obj, text, opts = {}) {
|
|
252
|
-
return BraceLabel(obj, text, { labelConstructor: (t, o) => Text(t, o), ...opts });
|
|
253
|
-
}
|
package/dist/card.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type Card, type Mobject } from "./engine.ts";
|
|
2
|
-
import type { Theme } from "./theme.ts";
|
|
3
|
-
/** The gap between the docked heading and its chapter number, also on each frame while the
|
|
4
|
-
* heading docks. */
|
|
5
|
-
export declare const NUMBER_GAP = 0.3;
|
|
6
|
-
/** The big heading of a card: a group of the heading, the kicker above it (an empty group when
|
|
7
|
-
* `kicker` is "") and an accent rule below it. */
|
|
8
|
-
export declare function chapterCard(title: string, kicker: string, theme: Theme): Mobject;
|
|
9
|
-
/** The docked heading: a group of the heading in the top left and its number after it (an
|
|
10
|
-
* empty group when `number` is ""). */
|
|
11
|
-
export declare function dockedHeading(title: string, number: string, theme: Theme): Mobject;
|
|
12
|
-
/** The default card: the big heading fades in on the first word of the heading cue. 0.3 seconds
|
|
13
|
-
* after the cue ends, the heading docks (0.7 seconds): the kicker and the rule fade out in the
|
|
14
|
-
* first half, and the number fades in during the second half. On each frame the number is
|
|
15
|
-
* `NUMBER_GAP` after the moving heading, so it never touches it, whatever the length of the
|
|
16
|
-
* heading. */
|
|
17
|
-
export declare const card: Card;
|
package/dist/card.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// The chapter card: the default `card` of a project (`card`). While the
|
|
2
|
-
// heading cue is spoken, the heading is big in the middle, with the chapter number above it
|
|
3
|
-
// (the kicker) and an accent rule below it. Then the heading docks in the top left, and the
|
|
4
|
-
// number follows it. The title card (chapter 0) has no number.
|
|
5
|
-
//
|
|
6
|
-
// The engine gives the times of the heading cue and keeps the chrome (the hooks of `Heading`);
|
|
7
|
-
// all the layout and the motion are here, with the same API as a chapter (`m`).
|
|
8
|
-
import { FadeIn, Transform, UpdateFromAlphaFunc } from "./animations.js";
|
|
9
|
-
import { BOLD, DOWN, linear, RIGHT, smooth, Text, UL, UP, VGroup, } from "./engine.js";
|
|
10
|
-
import { Line } from "./geometry.js";
|
|
11
|
-
/** The gap between the docked heading and its chapter number, also on each frame while the
|
|
12
|
-
* heading docks. */
|
|
13
|
-
export const NUMBER_GAP = 0.3;
|
|
14
|
-
/** The widest heading of a card: a longer one shrinks to this width. */
|
|
15
|
-
const CARD_WIDTH = 12.5;
|
|
16
|
-
/** Smooth progress over the first half of an animation, then held. */
|
|
17
|
-
function firstHalf(t) {
|
|
18
|
-
return smooth(Math.min(2 * t, 1));
|
|
19
|
-
}
|
|
20
|
-
/** Held, then smooth progress over the second half of an animation. */
|
|
21
|
-
function secondHalf(t) {
|
|
22
|
-
return smooth(Math.max(2 * t - 1, 0));
|
|
23
|
-
}
|
|
24
|
-
/** `n` with two digits: `03`. */
|
|
25
|
-
function twoDigits(n) {
|
|
26
|
-
return String(n).padStart(2, "0");
|
|
27
|
-
}
|
|
28
|
-
/** The big heading of a card: a group of the heading, the kicker above it (an empty group when
|
|
29
|
-
* `kicker` is "") and an accent rule below it. */
|
|
30
|
-
export function chapterCard(title, kicker, theme) {
|
|
31
|
-
const big = Text(title, { fontSize: theme.headingSize, color: theme.heading, weight: BOLD });
|
|
32
|
-
if (big.width > CARD_WIDTH)
|
|
33
|
-
big.scaleToFitWidth(CARD_WIDTH);
|
|
34
|
-
big.moveTo([0, 0.2]);
|
|
35
|
-
const tag = kicker === ""
|
|
36
|
-
? VGroup()
|
|
37
|
-
: Text(kicker, { fontSize: theme.kickerSize, color: theme.accent }).nextTo(big, UP, { buff: 0.35 });
|
|
38
|
-
const rule = Line([-1.5, 0], [1.5, 0])
|
|
39
|
-
.setStroke(theme.accent, { width: 3, opacity: 1 })
|
|
40
|
-
.nextTo(big, DOWN, { buff: 0.4 });
|
|
41
|
-
return VGroup(big, tag, rule);
|
|
42
|
-
}
|
|
43
|
-
/** The docked heading: a group of the heading in the top left and its number after it (an
|
|
44
|
-
* empty group when `number` is ""). */
|
|
45
|
-
export function dockedHeading(title, number, theme) {
|
|
46
|
-
const small = Text(title, { fontSize: theme.dockedSize, color: theme.docked, weight: BOLD }).toCorner(UL, {
|
|
47
|
-
buff: 0.35,
|
|
48
|
-
});
|
|
49
|
-
const tag = number === ""
|
|
50
|
-
? VGroup()
|
|
51
|
-
: Text(number, { fontSize: theme.numberSize, color: theme.accent }).nextTo(small, RIGHT, { buff: NUMBER_GAP });
|
|
52
|
-
return VGroup(small, tag);
|
|
53
|
-
}
|
|
54
|
-
/** The member `i` of a group, or an empty group. */
|
|
55
|
-
function member(group, i) {
|
|
56
|
-
return group.submobjects[i] ?? VGroup();
|
|
57
|
-
}
|
|
58
|
-
/** `part` fades out in place during the first half of a play. */
|
|
59
|
-
function hide(part) {
|
|
60
|
-
return part.animate({ rateFunc: firstHalf }).setOpacity(0);
|
|
61
|
-
}
|
|
62
|
-
/** The default card: the big heading fades in on the first word of the heading cue. 0.3 seconds
|
|
63
|
-
* after the cue ends, the heading docks (0.7 seconds): the kicker and the rule fade out in the
|
|
64
|
-
* first half, and the number fades in during the second half. On each frame the number is
|
|
65
|
-
* `NUMBER_GAP` after the moving heading, so it never touches it, whatever the length of the
|
|
66
|
-
* heading. */
|
|
67
|
-
export const card = (s, heading) => {
|
|
68
|
-
const { theme } = heading;
|
|
69
|
-
const number = heading.chapter > 0 ? `${twoDigits(heading.chapter)} / ${twoDigits(heading.count)}` : "";
|
|
70
|
-
const big = chapterCard(heading.title, number, theme);
|
|
71
|
-
s.wait(Math.max(0, heading.start - s.time));
|
|
72
|
-
// The card is chrome from its first frame: `fadeAll` keeps it.
|
|
73
|
-
heading.chrome(big);
|
|
74
|
-
s.play(FadeIn(big, { shift: [0, 0.15] }), { runTime: 0.8 });
|
|
75
|
-
s.wait(Math.max(0, heading.end + 0.3 - s.time));
|
|
76
|
-
const small = dockedHeading(heading.title, number, theme);
|
|
77
|
-
const title = member(big, 0);
|
|
78
|
-
const tag = member(small, 1);
|
|
79
|
-
const docked = tag.copy();
|
|
80
|
-
heading.chrome(big, tag);
|
|
81
|
-
s.play(Transform(title, member(small, 0)), hide(member(big, 1)), hide(member(big, 2)),
|
|
82
|
-
// After the transform, so it reads the heading of the same frame.
|
|
83
|
-
UpdateFromAlphaFunc(tag, (t, alpha) => {
|
|
84
|
-
if (number === "")
|
|
85
|
-
return;
|
|
86
|
-
t.become(docked);
|
|
87
|
-
t.setOpacity(secondHalf(alpha));
|
|
88
|
-
t.nextTo(title, RIGHT, { buff: NUMBER_GAP });
|
|
89
|
-
}, { rateFunc: linear }), { runTime: 0.7 });
|
|
90
|
-
};
|