@beff/aula 0.0.1 → 0.1.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.
Files changed (77) hide show
  1. package/README.md +9 -1
  2. package/dist/animations.d.ts +634 -0
  3. package/dist/animations.js +1793 -0
  4. package/dist/braces.d.ts +84 -0
  5. package/dist/braces.js +253 -0
  6. package/dist/card.d.ts +17 -0
  7. package/dist/card.js +90 -0
  8. package/dist/colors-palette.d.ts +2242 -0
  9. package/dist/colors-palette.js +2241 -0
  10. package/dist/colors.d.ts +120 -0
  11. package/dist/colors.js +403 -0
  12. package/dist/curves.d.ts +10 -0
  13. package/dist/curves.js +128 -0
  14. package/dist/engine.d.ts +1595 -0
  15. package/dist/engine.js +3364 -0
  16. package/dist/errors.d.ts +19 -0
  17. package/dist/errors.js +25 -0
  18. package/dist/generated/aula.conditional-suspending-3-i32-to-void.wasm +0 -0
  19. package/dist/generated/aula.core.wasm +0 -0
  20. package/dist/generated/aula.core2.wasm +0 -0
  21. package/dist/generated/aula.core3.wasm +0 -0
  22. package/dist/generated/aula.core4.wasm +0 -0
  23. package/dist/generated/aula.core5.wasm +0 -0
  24. package/dist/generated/aula.core6.wasm +0 -0
  25. package/dist/generated/aula.core7.wasm +0 -0
  26. package/dist/generated/aula.core8.wasm +0 -0
  27. package/dist/generated/aula.d.ts +80 -0
  28. package/dist/generated/aula.js +54639 -0
  29. package/dist/generated/interfaces/aula-engine-engine.d.ts +983 -0
  30. package/dist/generated/interfaces/aula-engine-host.d.ts +10 -0
  31. package/dist/generated/interfaces/aula-engine-tts.d.ts +43 -0
  32. package/dist/generated/interfaces/aula-engine-types.d.ts +60 -0
  33. package/dist/geometry.d.ts +551 -0
  34. package/dist/geometry.js +1821 -0
  35. package/dist/graph.d.ts +117 -0
  36. package/dist/graph.js +526 -0
  37. package/dist/graphing.d.ts +597 -0
  38. package/dist/graphing.js +1504 -0
  39. package/dist/host.d.ts +19 -0
  40. package/dist/host.js +85 -0
  41. package/dist/index.d.ts +5 -0
  42. package/dist/index.js +11 -0
  43. package/dist/licenses/aula-g2p-NOTICE.txt +13 -0
  44. package/dist/licenses/espeak-ng-COPYING.txt +674 -0
  45. package/dist/licenses/fonts-OFL-JetBrainsMono.txt +93 -0
  46. package/dist/licenses/fonts-OFL-NunitoSans.txt +93 -0
  47. package/dist/load.d.ts +16 -0
  48. package/dist/load.js +69 -0
  49. package/dist/logo.d.ts +30 -0
  50. package/dist/logo.js +186 -0
  51. package/dist/manim.d.ts +22 -0
  52. package/dist/manim.js +19 -0
  53. package/dist/mobjects.d.ts +127 -0
  54. package/dist/mobjects.js +316 -0
  55. package/dist/pointcloud.d.ts +144 -0
  56. package/dist/pointcloud.js +400 -0
  57. package/dist/rates.d.ts +19 -0
  58. package/dist/rates.js +54 -0
  59. package/dist/run.d.ts +82 -0
  60. package/dist/run.js +245 -0
  61. package/dist/tables.d.ts +179 -0
  62. package/dist/tables.js +403 -0
  63. package/dist/tex.d.ts +8 -0
  64. package/dist/tex.js +257 -0
  65. package/dist/text-layouts.d.ts +64 -0
  66. package/dist/text-layouts.js +225 -0
  67. package/dist/text.d.ts +35 -0
  68. package/dist/text.js +52 -0
  69. package/dist/theme.d.ts +25 -0
  70. package/dist/theme.js +12 -0
  71. package/dist/user-code.d.ts +5 -0
  72. package/dist/user-code.js +20 -0
  73. package/dist/utils.d.ts +152 -0
  74. package/dist/utils.js +517 -0
  75. package/dist/vector-field.d.ts +132 -0
  76. package/dist/vector-field.js +361 -0
  77. package/package.json +46 -5
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2016 The Nunito Sans Project Authors (https://github.com/Fonthausen/NunitoSans)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
package/dist/load.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import type * as EngineExports from "./generated/interfaces/aula-engine-engine.js";
2
+ import type * as TtsExports from "./generated/interfaces/aula-engine-tts.js";
3
+ type Engine = typeof EngineExports;
4
+ type Tts = typeof TtsExports;
5
+ /** The engine's functions: `unloaded` until `loadEngine()` is done. A live binding: the modules
6
+ * that import it see the loaded engine. */
7
+ export declare let engine: Engine;
8
+ /** The narrator's inference engine (crates/aula-tts): `unloaded` until `loadEngine()` is done. */
9
+ export declare let tts: Tts;
10
+ /** Loads the engine: on the first call only; every call gives the same promise. */
11
+ export declare function loadEngine(): Promise<void>;
12
+ /** True when `value` is the error of a WIT `result` of the engine (jco's ComponentError). */
13
+ export declare function isComponentError(value: unknown): value is Error & {
14
+ readonly payload: unknown;
15
+ };
16
+ export {};
package/dist/load.js ADDED
@@ -0,0 +1,69 @@
1
+ // The engine component, loaded on its first use. An import of @beff/aula does no async work: a
2
+ // module that imports it (a worker, a test, a project) is ready at once. `loadEngine()` compiles
3
+ // the core wasm files of the component and instantiates it with the host (host.ts) one time;
4
+ // each caller gets the same promise. The engine's functions are synchronous, so the operation
5
+ // that runs project code awaits `loadEngine()` first (`loadProject`, `loadProjects`), and so does
6
+ // an entry file that calls the engine directly.
7
+ import { instantiate } from "./generated/aula.js";
8
+ import * as host from "./host.js";
9
+ import { fault } from "./errors.js";
10
+ /** The core wasm files of the component, by the name that jco gives them: the engine with
11
+ * eSpeak NG plugged in (scripts/engine-build.ts). Each URL is written out, so that a bundler
12
+ * finds the file. */
13
+ const CORE = {
14
+ "aula.core.wasm": new URL("./generated/aula.core.wasm", import.meta.url),
15
+ "aula.core2.wasm": new URL("./generated/aula.core2.wasm", import.meta.url),
16
+ "aula.core3.wasm": new URL("./generated/aula.core3.wasm", import.meta.url),
17
+ "aula.core4.wasm": new URL("./generated/aula.core4.wasm", import.meta.url),
18
+ "aula.core5.wasm": new URL("./generated/aula.core5.wasm", import.meta.url),
19
+ "aula.core6.wasm": new URL("./generated/aula.core6.wasm", import.meta.url),
20
+ "aula.core7.wasm": new URL("./generated/aula.core7.wasm", import.meta.url),
21
+ "aula.core8.wasm": new URL("./generated/aula.core8.wasm", import.meta.url),
22
+ "aula.conditional-suspending-3-i32-to-void.wasm": new URL("./generated/aula.conditional-suspending-3-i32-to-void.wasm", import.meta.url),
23
+ };
24
+ /** The engine before `loadEngine()`: each use fails with the fix. */
25
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- each property of the proxy throws
26
+ const unloaded = new Proxy({}, {
27
+ get: (_, name) => fault(`the aula engine is not loaded (engine.${String(name)})`, 'await loadEngine() of "@beff/aula/run" before the first call to the engine'),
28
+ });
29
+ /** The engine's functions: `unloaded` until `loadEngine()` is done. A live binding: the modules
30
+ * that import it see the loaded engine. */
31
+ export let engine = unloaded;
32
+ /** The narrator's inference engine (crates/aula-tts): `unloaded` until `loadEngine()` is done. */
33
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the same proxy: each use throws
34
+ export let tts = unloaded;
35
+ let root;
36
+ let loading;
37
+ /** The compiled core module at `url`: a file in Node, else a download. */
38
+ async function compile(url) {
39
+ if (url.protocol === "file:") {
40
+ const { readFile } = await import("node:fs/promises");
41
+ return WebAssembly.compile(await readFile(url));
42
+ }
43
+ const response = await fetch(url);
44
+ if (!response.ok)
45
+ throw new Error(`${url.href}: HTTP ${String(response.status)}`);
46
+ return response.headers.get("Content-Type") === "application/wasm"
47
+ ? WebAssembly.compileStreaming(response)
48
+ : WebAssembly.compile(await response.arrayBuffer());
49
+ }
50
+ /** Loads the engine: on the first call only; every call gives the same promise. */
51
+ export function loadEngine() {
52
+ loading ??= (async () => {
53
+ // jco's `instantiate` gives the root, or a promise of it when the core modules come from
54
+ // a promise, as here.
55
+ const loaded = await Promise.resolve(instantiate((path) => compile(CORE[path] ?? fault(`the engine component has no core file ${path}`)), {
56
+ "aula:engine/host": host,
57
+ "aula:engine/types": {},
58
+ }));
59
+ root = loaded;
60
+ engine = loaded.engine;
61
+ tts = loaded.tts;
62
+ })();
63
+ return loading;
64
+ }
65
+ /** True when `value` is the error of a WIT `result` of the engine (jco's ComponentError). */
66
+ export function isComponentError(value) {
67
+ // oxlint-disable-next-line no-underscore-dangle -- the name that jco gives it
68
+ return root !== undefined && root._util.isComponentError(value);
69
+ }
package/dist/logo.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { type Animation, type Point, Mobject } from "./engine.ts";
2
+ /** Manim's banner: `ManimBanner({ darkTheme })`. Its submobjects are `shapes` and `M`;
3
+ * `expand` adds `anim`, the letters "anim". */
4
+ export declare class ManimBannerMobject extends Mobject {
5
+ fontColor: string;
6
+ scaleFactor: number;
7
+ /** The letter M. */
8
+ M: Mobject;
9
+ circle: Mobject;
10
+ square: Mobject;
11
+ triangle: Mobject;
12
+ /** The triangle, the square and the circle. */
13
+ shapes: Mobject;
14
+ /** The letters "anim", which `expand` shows. */
15
+ anim: Mobject;
16
+ copy(): ManimBannerMobject;
17
+ /** Scales the banner, also the letters that are not shown yet (Manim `scale`). */
18
+ scale(scaleFactor: number, opts?: {
19
+ scaleStroke?: boolean;
20
+ aboutPoint?: Point;
21
+ aboutEdge?: Point;
22
+ }): this;
23
+ /** The shapes spiral in and the M fades in (Manim `create`). */
24
+ create(runTime?: number): Animation;
25
+ /** The shapes slide away and uncover the letters "anim" (Manim `expand`). `direction` is
26
+ * `"left"`, `"right"` or `"center"`. After it, `anim` is a submobject of the banner. */
27
+ expand(runTime?: number, direction?: "left" | "right" | "center"): Animation;
28
+ }
29
+ /** Manim's banner (Manim `ManimBanner`): `ManimBanner({ darkTheme })`, light letters by default. */
30
+ export declare function ManimBanner(darkTheme?: boolean): ManimBannerMobject;
package/dist/logo.js ADDED
@@ -0,0 +1,186 @@
1
+ // Manim CE's banner: ManimBanner, the logo of Manim (a circle, a square, a triangle and the
2
+ // letter M), with its animations `create` and `expand`. The letters are Manim's own SVG paths.
3
+ import { DOWN, LEFT, ORIGIN, RIGHT, TAU, UP, Mobject, Polyline, VGroup, add, easeInOutCubic, mul, raw, smooth, sub, wrong, } from "./engine.js";
4
+ import { AnimationGroup, FadeIn, Succession, UpdateFromAlphaFunc } from "./animations.js";
5
+ import { svgPathPoints } from "./curves.js";
6
+ import { engine } from "./load.js";
7
+ import { Circle, Square, Triangle } from "./geometry.js";
8
+ /** Manim's `MANIM_SVG_PATHS`: the letters M, a, n, i and m. */
9
+ const PATHS = [
10
+ "M4.64259-2.092154L2.739726-6.625156C2.660025-6.824408 2.650062-6.824408 2.381071-6.824408H.52802C.348692-6.824408 .199253-6.824408 .199253-6.645081C.199253-6.475716 .37858-6.475716 .428394-6.475716C.547945-6.475716 .816936-6.455791 1.036115-6.37609V-1.05604C1.036115-.846824 1.036115-.408468 .358655-.348692C.169365-.328767 .169365-.18929 .169365-.179328C.169365 0 .328767 0 .508095 0H2.052304C2.231631 0 2.381071 0 2.381071-.179328C2.381071-.268991 2.30137-.33873 2.221669-.348692C1.454545-.408468 1.454545-.826899 1.454545-1.05604V-6.017435L1.464508-6.027397L3.895392-.209215C3.975093-.029888 4.044832 0 4.104608 0C4.224159 0 4.254047-.079701 4.303861-.199253L6.744707-6.027397L6.75467-6.017435V-1.05604C6.75467-.846824 6.75467-.408468 6.07721-.348692C5.88792-.328767 5.88792-.18929 5.88792-.179328C5.88792 0 6.047323 0 6.22665 0H8.886675C9.066002 0 9.215442 0 9.215442-.179328C9.215442-.268991 9.135741-.33873 9.05604-.348692C8.288917-.408468 8.288917-.826899 8.288917-1.05604V-5.768369C8.288917-5.977584 8.288917-6.41594 8.966376-6.475716C9.066002-6.485679 9.155666-6.535492 9.155666-6.645081C9.155666-6.824408 9.006227-6.824408 8.826899-6.824408H6.90411C6.645081-6.824408 6.625156-6.824408 6.535492-6.615193L4.64259-2.092154ZM4.343711-1.912827C4.423412-1.743462 4.433375-1.733499 4.552927-1.693649L4.11457-.637609H4.094645L1.823163-6.057285C1.77335-6.1868 1.693649-6.356164 1.554172-6.475716H2.420922L4.343711-1.912827ZM1.334994-.348692H1.165629C1.185554-.37858 1.205479-.408468 1.225405-.428394C1.235367-.438356 1.235367-.448319 1.24533-.458281L1.334994-.348692ZM7.103362-6.475716H8.159402C7.940224-6.22665 7.940224-5.967621 7.940224-5.788294V-1.036115C7.940224-.856787 7.940224-.597758 8.169365-.348692H6.884184C7.103362-.597758 7.103362-.856787 7.103362-1.036115V-6.475716Z",
11
+ "M1.464508-4.024907C1.464508-4.234122 1.743462-4.393524 2.092154-4.393524C2.669988-4.393524 2.929016-4.124533 2.929016-3.516812V-2.789539C1.77335-2.440847 .249066-2.042341 .249066-.916563C.249066-.308842 .71731 .139477 1.354919 .139477C1.92279 .139477 2.381071-.059776 2.929016-.557908C3.038605-.049813 3.257783 .139477 3.745953 .139477C4.174346 .139477 4.483188-.019925 4.861768-.428394L4.712329-.637609L4.612702-.537983C4.582814-.508095 4.552927-.498132 4.503113-.498132C4.363636-.498132 4.293898-.587796 4.293898-.747198V-3.347447C4.293898-4.184309 3.536737-4.712329 2.321295-4.712329C1.195517-4.712329 .438356-4.204234 .438356-3.457036C.438356-3.048568 .67746-2.799502 1.085928-2.799502C1.484433-2.799502 1.763387-3.038605 1.763387-3.377335C1.763387-3.676214 1.464508-3.88543 1.464508-4.024907ZM2.919054-.996264C2.650062-.687422 2.450809-.56787 2.211706-.56787C1.912827-.56787 1.703611-.836862 1.703611-1.235367C1.703611-1.8132 2.122042-2.231631 2.919054-2.440847V-.996264Z",
12
+ "M2.948941-4.044832C3.297634-4.044832 3.466999-3.775841 3.466999-3.217933V-.806974C3.466999-.438356 3.337484-.278954 2.998755-.239103V0H5.339975V-.239103C4.951432-.268991 4.851806-.388543 4.851806-.806974V-3.307597C4.851806-4.164384 4.323786-4.712329 3.506849-4.712329C2.909091-4.712329 2.450809-4.433375 2.082192-3.845579V-4.592777H.179328V-4.353674C.617684-4.283935 .707347-4.184309 .707347-3.765878V-.836862C.707347-.418431 .627646-.328767 .179328-.239103V0H2.580324V-.239103C2.211706-.288917 2.092154-.438356 2.092154-.806974V-3.466999C2.092154-3.576588 2.530511-4.044832 2.948941-4.044832Z",
13
+ "M2.15193-4.592777H.239103V-4.353674C.67746-4.26401 .767123-4.174346 .767123-3.765878V-.836862C.767123-.428394 .697385-.348692 .239103-.239103V0H2.6401V-.239103C2.291407-.288917 2.15193-.428394 2.15193-.806974V-4.592777ZM1.454545-6.884184C1.026152-6.884184 .67746-6.535492 .67746-6.117061C.67746-5.668742 1.006227-5.339975 1.444583-5.339975S2.221669-5.668742 2.221669-6.107098C2.221669-6.535492 1.882939-6.884184 1.454545-6.884184Z",
14
+ "M2.929016-4.044832C3.317559-4.044832 3.466999-3.815691 3.466999-3.217933V-.806974C3.466999-.398506 3.35741-.268991 2.988792-.239103V0H5.32005V-.239103C4.971357-.278954 4.851806-.428394 4.851806-.806974V-3.466999C4.851806-3.576588 5.310087-4.044832 5.69863-4.044832C6.07721-4.044832 6.22665-3.805729 6.22665-3.217933V-.806974C6.22665-.388543 6.117061-.268991 5.738481-.239103V0H8.109589V-.239103C7.721046-.259029 7.611457-.37858 7.611457-.806974V-3.307597C7.611457-4.164384 7.083437-4.712329 6.266501-4.712329C5.69863-4.712329 5.32005-4.483188 4.801993-3.845579C4.503113-4.473225 4.154421-4.712329 3.526775-4.712329S2.440847-4.443337 2.062267-3.845579V-4.592777H.179328V-4.353674C.617684-4.293898 .707347-4.174346 .707347-3.765878V-.836862C.707347-.428394 .617684-.318804 .179328-.239103V0H2.550436V-.239103C2.201743-.288917 2.092154-.428394 2.092154-.806974V-3.466999C2.092154-3.58655 2.530511-4.044832 2.929016-4.044832Z",
15
+ ];
16
+ /** A filled letter from SVG path data, upright (Manim `VMobjectFromSVGPath(...).flip(RIGHT)`). */
17
+ function letter(d) {
18
+ const points = svgPathPoints(d).map(([x, y]) => [x, -y]);
19
+ return Polyline(ORIGIN, ORIGIN).setPoints(points).setStroke({ width: 0 }).center();
20
+ }
21
+ /** Moves the children of `parent` so that `first` is the first one (Manim `add_to_back`). */
22
+ function toBack(parent, first) {
23
+ const rest = parent.submobjects.filter((s) => s !== first);
24
+ parent.remove(...parent.submobjects);
25
+ parent.add(first, ...rest);
26
+ }
27
+ /** Manim's banner: `ManimBanner({ darkTheme })`. Its submobjects are `shapes` and `M`;
28
+ * `expand` adds `anim`, the letters "anim". */
29
+ export class ManimBannerMobject extends Mobject {
30
+ fontColor = "#ece6e2";
31
+ scaleFactor = 1;
32
+ /** The letter M. */
33
+ M = VGroup();
34
+ circle = VGroup();
35
+ square = VGroup();
36
+ triangle = VGroup();
37
+ /** The triangle, the square and the circle. */
38
+ shapes = VGroup();
39
+ /** The letters "anim", which `expand` shows. */
40
+ anim = VGroup();
41
+ copy() {
42
+ const c = new ManimBannerMobject(raw(this).copy());
43
+ const [from, to] = [this.getFamily(), c.getFamily()];
44
+ const same = (m) => to[from.indexOf(m)] ?? m.copy();
45
+ c.fontColor = this.fontColor;
46
+ c.scaleFactor = this.scaleFactor;
47
+ c.M = same(this.M);
48
+ c.circle = same(this.circle);
49
+ c.square = same(this.square);
50
+ c.triangle = same(this.triangle);
51
+ c.shapes = same(this.shapes);
52
+ c.anim = same(this.anim);
53
+ return c;
54
+ }
55
+ /** Scales the banner, also the letters that are not shown yet (Manim `scale`). */
56
+ scale(scaleFactor, opts = {}) {
57
+ const { scaleStroke = false, ...about } = opts;
58
+ this.scaleFactor *= scaleFactor;
59
+ if (!this.submobjects.includes(this.anim))
60
+ this.anim.scale(scaleFactor, about);
61
+ super.scale(scaleFactor, about);
62
+ if (scaleStroke) {
63
+ for (const m of this.getFamily()) {
64
+ if (m.hasPoints() && m.getStrokeWidth() > 0)
65
+ m.setStroke({ width: m.getStrokeWidth() * scaleFactor });
66
+ }
67
+ }
68
+ return this;
69
+ }
70
+ /** The shapes spiral in and the M fades in (Manim `create`). */
71
+ create(runTime = 2) {
72
+ return AnimationGroup(spiralIn(this.shapes, runTime), FadeIn(this.M, { runTime: runTime / 2 }), { lagRatio: 0.1 });
73
+ }
74
+ /** The shapes slide away and uncover the letters "anim" (Manim `expand`). `direction` is
75
+ * `"left"`, `"right"` or `"center"`. After it, `anim` is a submobject of the banner. */
76
+ expand(runTime = 1.5, direction = "center") {
77
+ if (!["left", "right", "center"].includes(direction)) {
78
+ wrong("expand", `direction must be "left", "right" or "center"; got ${JSON.stringify(direction)}`);
79
+ }
80
+ const offset = 6.25 * this.scaleFactor;
81
+ const overshoot = this.scaleFactor * 0.8;
82
+ this.anim.nextTo(this.M, RIGHT, { buff: 0.06 }).alignTo(this.M, DOWN);
83
+ this.anim.setOpacity(0);
84
+ this.shapes.saveState();
85
+ const clone = (this.anim.submobjects.at(-1) ?? this.anim).copy();
86
+ this.add(clone);
87
+ clone.moveTo(this.shapes);
88
+ const savedLeft = this.M.getLeft()[0];
89
+ const left = [this.M, this.anim, clone];
90
+ const shift = (vector) => {
91
+ this.shapes.restore();
92
+ const now = Math.min(...left.map((m) => m.getLeft()[0]));
93
+ for (const m of left)
94
+ m.shift([savedLeft - now, 0]);
95
+ if (direction === "right")
96
+ this.shapes.shift(vector);
97
+ else if (direction === "center") {
98
+ this.shapes.shift(mul(vector, 0.5));
99
+ for (const m of left)
100
+ m.shift(mul(vector, -0.5));
101
+ }
102
+ else
103
+ for (const m of left)
104
+ m.shift(mul(vector, -1));
105
+ };
106
+ const slide = UpdateFromAlphaFunc(this, (_mob, alpha) => {
107
+ shift(mul(RIGHT, alpha * (offset + overshoot)));
108
+ for (const l of this.anim.submobjects) {
109
+ if (this.square.getCenter()[0] > l.getCenter()[0])
110
+ l.setOpacity(1);
111
+ }
112
+ if (alpha === 1) {
113
+ if (!this.submobjects.includes(this.anim))
114
+ this.add(this.anim);
115
+ toBack(this, this.anim);
116
+ this.shapes.saveState();
117
+ }
118
+ }, { runTime: (runTime * 2) / 3, rateFunc: easeInOutCubic });
119
+ const back = UpdateFromAlphaFunc(this, (_mob, alpha) => {
120
+ if (alpha === 0) {
121
+ clone.setOpacity(1);
122
+ clone.moveTo(this.anim.submobjects.at(-1) ?? this.anim);
123
+ this.anim.setOpacity(1);
124
+ }
125
+ shift(mul(LEFT, alpha * overshoot));
126
+ if (alpha === 1) {
127
+ this.remove(clone);
128
+ toBack(this, this.shapes);
129
+ }
130
+ }, { runTime: runTime / 3, rateFunc: smooth });
131
+ return Succession(slide, back);
132
+ }
133
+ }
134
+ /** Manim's `SpiralIn`: each shape flies in on a spiral from 8 times its distance to the
135
+ * centre, and fades in during the first 0.3 of the time. */
136
+ function spiralIn(shapes, runTime) {
137
+ const centre = shapes.getCenter();
138
+ const originals = shapes.submobjects.map((s) => s.copy());
139
+ const finals = shapes.submobjects.map((s) => s.getCenter());
140
+ const starts = finals.map((f) => add(f, mul(sub(f, centre), 8)));
141
+ return UpdateFromAlphaFunc(shapes, (mob, alpha) => {
142
+ mob.submobjects.forEach((shape, i) => {
143
+ const original = originals[i];
144
+ const [start, final] = [starts[i] ?? ORIGIN, finals[i] ?? ORIGIN];
145
+ if (original === undefined)
146
+ return;
147
+ shape.become(original).moveTo(start);
148
+ shape.shift(mul(sub(final, start), alpha));
149
+ shape.rotate(TAU * alpha, { aboutPoint: centre });
150
+ shape.rotate(-TAU * alpha, { aboutPoint: shape.getCenter() });
151
+ shape.setFill({ opacity: Math.min(original.getFillOpacity(), (alpha * original.getFillOpacity()) / 0.3) });
152
+ shape.setStroke({
153
+ opacity: Math.min(original.getStrokeOpacity(), (alpha * original.getStrokeOpacity()) / 0.3),
154
+ });
155
+ });
156
+ }, { runTime });
157
+ }
158
+ function banner(darkTheme) {
159
+ const b = new ManimBannerMobject(engine.vGroup([]));
160
+ b.fontColor = darkTheme ? "#ece6e2" : "#343434";
161
+ const [mPath = "", ...letters] = PATHS;
162
+ b.M = letter(mPath).scale((7 * 48) / 960);
163
+ b.M.setFill(b.fontColor, { opacity: 1 }).shift(add(mul(LEFT, 2.25), mul(UP, 1.5)));
164
+ b.circle = Circle({ color: "#81b29a", fillOpacity: 1 }).shift(LEFT);
165
+ b.square = Square({ color: "#454866", fillOpacity: 1 }).shift(UP);
166
+ b.triangle = Triangle({ color: "#e07a5f", fillOpacity: 1 }).shift(RIGHT);
167
+ b.shapes = VGroup(b.triangle, b.square, b.circle);
168
+ b.add(b.shapes, b.M);
169
+ b.moveTo(ORIGIN);
170
+ const anim = VGroup();
171
+ letters.forEach((d, i) => {
172
+ const l = letter(d).scale(48 / 960);
173
+ if (i > 0)
174
+ l.nextTo(anim, RIGHT, { buff: 0.01 });
175
+ l.alignTo(b.M, DOWN);
176
+ anim.add(l);
177
+ });
178
+ anim.setFill(b.fontColor, { opacity: 1 });
179
+ anim.height = 0.75748 * b.M.height;
180
+ b.anim = anim;
181
+ return b;
182
+ }
183
+ /** Manim's banner (Manim `ManimBanner`): `ManimBanner({ darkTheme })`, light letters by default. */
184
+ export function ManimBanner(darkTheme = true) {
185
+ return banner(darkTheme);
186
+ }
@@ -0,0 +1,22 @@
1
+ export type { Card, Color, Heading, Location } from "./engine.ts";
2
+ export { card, chapterCard, dockedHeading, NUMBER_GAP } from "./card.ts";
3
+ export { theme, type Theme } from "./theme.ts";
4
+ export type { AboutOptions, StyleSettings, VMobjectOptions, BackgroundRectangleOptions, GridOptions, MobjectAttributes, MobjectOptions, RadialGradientOptions, UpdaterBuilder, AnimationBuilder, BoundMethod, PathFunc, AnimationOptions, Animations, DecimalNumberMobject, DecimalNumberOptions, IntegerMobject, CodeBackgroundConfig, CodeMobject, CodeOptions, CodeParagraphConfig, Mobjects, Points, RateFunc, StyleOptions, TexMatch, TexOptions, TextOptions, DashedVMobjectOptions, Weight, Slant, TrackerBuilder, } from "./engine.ts";
5
+ export { BLACK, BOLD, DEGREES, DL, DOWN, DR, FRAME_HEIGHT, FRAME_WIDTH, LARGE_BUFF, LEFT, MED_LARGE_BUFF, MED_SMALL_BUFF, NORMAL, ORIGIN, PI, RIGHT, SMALL_BUFF, TAU, UL, UP, UR, WHITE, YELLOW, PURE_YELLOW, doubleSmooth, linear, rushFrom, rushInto, slowInto, smooth, thereAndBack, thereAndBackWithPause, easeInSine, easeOutSine, easeInOutSine, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint, easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, easeInBack, easeOutBack, easeInOutBack, easeInElastic, easeOutElastic, easeInOutElastic, easeInBounce, easeOutBounce, easeInOutBounce, add, lerp, mul, norm, sub, Animation, Mobject, ValueTracker, MathTex, Code, CubicBezier, DecimalNumber, DashedVMobject, Integer, Polyline, Tex, Text, VGroup, VMobject, alwaysRedraw, Scene, } from "./engine.ts";
6
+ export type { AddTipOptions, AngleMobject, AngleOptions, AnnularSectorOptions, ArcBetweenPointsOptions, ArcMobject, ArcOptions, ArcPolygonMobject, ArcPolygonOptions, ArrowMobject, ArrowSettings, ArrowTipMobject, BackgroundRectangleMobject, CircleMobject, CurvedArrowOptions, DashedLineMobject, DashedLineOptions, FunctionGraphMobject, LabelOptions, LabeledLineOptions, LineMobject, LineOptions, ParametricFunctionMobject, ParametricFunctionOptions, PolygramMobject, RectangleOptions, RegularPolygramOptions, Scaling, SquareMobject, StarOptions, StealthTipMobject, TRange, TipOptions, TipShape, TipableOptions, TipableVMobjectMobject, VectorMobject, } from "./geometry.ts";
7
+ export { Angle, AnnotationDot, AnnularSector, Annulus, Arc, ArcBetweenPoints, ArcPolygon, ArcPolygonFromArcs, Arrow, ArrowCircleFilledTip, ArrowCircleTip, ArrowSquareFilledTip, ArrowSquareTip, ArrowTip, ArrowTriangleFilledTip, ArrowTriangleTip, BackgroundRectangle, Circle, ConvexHull, Cross, CurvedArrow, CurvedDoubleArrow, Cutout, DashedLine, Difference, Dot, DoubleArrow, Elbow, Ellipse, Exclusion, FunctionGraph, ImplicitFunction, Intersection, Label, LabeledArrow, LabeledDot, LabeledLine, LabeledPolygram, Line, ParametricFunction, Polygon, Polygram, Rectangle, RegularPolygon, RegularPolygram, RightAngle, RoundedRectangle, Sector, Square, Star, StealthTip, SurroundingRectangle, TangentLine, TangentialArc, TipableVMobject, Triangle, Underline, Union, Vector, } from "./geometry.ts";
8
+ export * from "./colors-palette.ts";
9
+ export { HSV, ManimColor, RGBA, RandomColorGenerator, averageColor, colorGradient, colorToIntRgb, colorToIntRgba, colorToRgb, colorToRgba, hexToRgb, interpolateColor, invertColor, randomBrightColor, randomColor, rgbToColor, rgbToHex, rgbaToColor, } from "./colors.ts";
10
+ export type { ParsableManimColor } from "./colors.ts";
11
+ export * from "./rates.ts";
12
+ export * from "./utils.ts";
13
+ export * from "./braces.ts";
14
+ export * from "./mobjects.ts";
15
+ export * from "./tables.ts";
16
+ export * from "./text-layouts.ts";
17
+ export * from "./animations.ts";
18
+ export * from "./graphing.ts";
19
+ export * from "./graph.ts";
20
+ export * from "./pointcloud.ts";
21
+ export * from "./vector-field.ts";
22
+ export * from "./logo.ts";
package/dist/manim.js ADDED
@@ -0,0 +1,19 @@
1
+ // The chapter card, the docked heading and the theme: the defaults of every project.
2
+ export { card, chapterCard, dockedHeading, NUMBER_GAP } from "./card.js";
3
+ export { theme } from "./theme.js";
4
+ export { BLACK, BOLD, DEGREES, DL, DOWN, DR, FRAME_HEIGHT, FRAME_WIDTH, LARGE_BUFF, LEFT, MED_LARGE_BUFF, MED_SMALL_BUFF, NORMAL, ORIGIN, PI, RIGHT, SMALL_BUFF, TAU, UL, UP, UR, WHITE, YELLOW, PURE_YELLOW, doubleSmooth, linear, rushFrom, rushInto, slowInto, smooth, thereAndBack, thereAndBackWithPause, easeInSine, easeOutSine, easeInOutSine, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint, easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, easeInBack, easeOutBack, easeInOutBack, easeInElastic, easeOutElastic, easeInOutElastic, easeInBounce, easeOutBounce, easeInOutBounce, add, lerp, mul, norm, sub, Animation, Mobject, ValueTracker, MathTex, Code, CubicBezier, DecimalNumber, DashedVMobject, Integer, Polyline, Tex, Text, VGroup, VMobject, alwaysRedraw, Scene, } from "./engine.js";
5
+ export { Angle, AnnotationDot, AnnularSector, Annulus, Arc, ArcBetweenPoints, ArcPolygon, ArcPolygonFromArcs, Arrow, ArrowCircleFilledTip, ArrowCircleTip, ArrowSquareFilledTip, ArrowSquareTip, ArrowTip, ArrowTriangleFilledTip, ArrowTriangleTip, BackgroundRectangle, Circle, ConvexHull, Cross, CurvedArrow, CurvedDoubleArrow, Cutout, DashedLine, Difference, Dot, DoubleArrow, Elbow, Ellipse, Exclusion, FunctionGraph, ImplicitFunction, Intersection, Label, LabeledArrow, LabeledDot, LabeledLine, LabeledPolygram, Line, ParametricFunction, Polygon, Polygram, Rectangle, RegularPolygon, RegularPolygram, RightAngle, RoundedRectangle, Sector, Square, Star, StealthTip, SurroundingRectangle, TangentLine, TangentialArc, TipableVMobject, Triangle, Underline, Union, Vector, } from "./geometry.js";
6
+ export * from "./colors-palette.js";
7
+ export { HSV, ManimColor, RGBA, RandomColorGenerator, averageColor, colorGradient, colorToIntRgb, colorToIntRgba, colorToRgb, colorToRgba, hexToRgb, interpolateColor, invertColor, randomBrightColor, randomColor, rgbToColor, rgbToHex, rgbaToColor, } from "./colors.js";
8
+ export * from "./rates.js";
9
+ export * from "./utils.js";
10
+ export * from "./braces.js";
11
+ export * from "./mobjects.js";
12
+ export * from "./tables.js";
13
+ export * from "./text-layouts.js";
14
+ export * from "./animations.js";
15
+ export * from "./graphing.js";
16
+ export * from "./graph.js";
17
+ export * from "./pointcloud.js";
18
+ export * from "./vector-field.js";
19
+ export * from "./logo.js";