manim-web 0.20.0 → 0.22.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/BokehPass-BtX0qHyZ.js +52 -0
- package/dist/BokehPass-D-qNlcw3.js +52 -0
- package/dist/CopyShader-C2Oc7n1P.js +12 -0
- package/dist/EffectComposer-BrOvLZtb.js +88 -0
- package/dist/EffectComposer-D427QFuS.js +88 -0
- package/dist/OutputPass-BeBCm_Ta.js +29 -0
- package/dist/OutputPass-oQu4Xmeb.js +29 -0
- package/dist/Pass--g-Yi-4V.js +51 -0
- package/dist/Pass-CSHIrJrV.js +51 -0
- package/dist/RenderPass-DS8SYAhJ.js +16 -0
- package/dist/RenderPass-DqrV7dhy.js +16 -0
- package/dist/ShaderPass-MHAIxsHm.js +22 -0
- package/dist/ShaderPass-h4P0lBmc.js +22 -0
- package/dist/UnrealBloomPass-DXgh_M0E.js +123 -0
- package/dist/UnrealBloomPass-DxDOnUAw.js +123 -0
- package/dist/core/PostProcessing.d.ts +203 -0
- package/dist/core/PostProcessing.d.ts.map +1 -0
- package/dist/core/Scene.d.ts +23 -0
- package/dist/core/Scene.d.ts.map +1 -1
- package/dist/export/FrameExporter.d.ts +25 -12
- package/dist/export/FrameExporter.d.ts.map +1 -1
- package/dist/export/WebCodecsExporter.d.ts +39 -0
- package/dist/export/WebCodecsExporter.d.ts.map +1 -1
- package/dist/export/alphaBackground.d.ts +78 -0
- package/dist/export/alphaBackground.d.ts.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/integrations/react.js +17 -17
- package/dist/integrations/vue.js +16 -16
- package/dist/interaction/PanZoomControls.d.ts +133 -0
- package/dist/interaction/PanZoomControls.d.ts.map +1 -0
- package/dist/interaction/index.d.ts +1 -0
- package/dist/interaction/index.d.ts.map +1 -1
- package/dist/manim-web.browser.js +2426 -1708
- package/dist/mobjects/particles/ParticleSystem.d.ts +162 -0
- package/dist/mobjects/particles/ParticleSystem.d.ts.map +1 -0
- package/dist/mobjects/particles/index.d.ts +6 -0
- package/dist/mobjects/particles/index.d.ts.map +1 -0
- package/dist/mobjects/text/TextOnPath.d.ts +70 -0
- package/dist/mobjects/text/TextOnPath.d.ts.map +1 -0
- package/dist/mobjects/text/index.d.ts +2 -0
- package/dist/mobjects/text/index.d.ts.map +1 -1
- package/dist/mobjects/text/textOnPathLayout.d.ts +110 -0
- package/dist/mobjects/text/textOnPathLayout.d.ts.map +1 -0
- package/dist/{src-jWauXqbN.js → src-C18aslV3.js} +2408 -1690
- package/package.json +1 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Vector3Tuple } from '../../core/Mobject';
|
|
2
|
+
import { PMobject } from '../point/PMobject';
|
|
3
|
+
/** External forces applied to every particle each step. */
|
|
4
|
+
export interface ParticleForces {
|
|
5
|
+
/** Constant acceleration [x, y, z] in units/sec^2. Default: [0, 0, 0]. */
|
|
6
|
+
gravity?: Vector3Tuple;
|
|
7
|
+
/**
|
|
8
|
+
* Velocity damping per second, from 0 (none) to 1 (full stop in one second).
|
|
9
|
+
* Each step scales velocity by `1 - drag * dt`. Default: 0.
|
|
10
|
+
*/
|
|
11
|
+
drag?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A snapshot of one living particle, returned by {@link ParticleSystem.getParticles}.
|
|
15
|
+
* The arrays are copies, so a caller cannot mutate the internal state.
|
|
16
|
+
*/
|
|
17
|
+
export interface ParticleSnapshot {
|
|
18
|
+
/** Current position [x, y, z]. */
|
|
19
|
+
position: Vector3Tuple;
|
|
20
|
+
/** Current velocity [x, y, z] in units/sec. */
|
|
21
|
+
velocity: Vector3Tuple;
|
|
22
|
+
/** Age in seconds since the particle was spawned. */
|
|
23
|
+
age: number;
|
|
24
|
+
/** Total lifetime in seconds. The particle dies when `age > lifetime`. */
|
|
25
|
+
lifetime: number;
|
|
26
|
+
/** Current size, interpolated from `startSize` to `endSize` over the life. */
|
|
27
|
+
size: number;
|
|
28
|
+
/** Current color, interpolated from `startColor` to `endColor` over the life. */
|
|
29
|
+
color: string;
|
|
30
|
+
}
|
|
31
|
+
/** Options for creating a {@link ParticleSystem}. */
|
|
32
|
+
export interface ParticleSystemOptions {
|
|
33
|
+
/** Particles emitted per second. Default: 20. */
|
|
34
|
+
spawnRate?: number;
|
|
35
|
+
/** Maximum living particles. Emission stops at the cap. Default: 500. */
|
|
36
|
+
maxParticles?: number;
|
|
37
|
+
/** Base lifetime in seconds. Default: 2. */
|
|
38
|
+
lifetime?: number;
|
|
39
|
+
/** Random +/- lifetime variation in seconds. Default: 0. */
|
|
40
|
+
lifetimeSpread?: number;
|
|
41
|
+
/** Emitter origin [x, y, z]. Default: [0, 0, 0]. */
|
|
42
|
+
position?: Vector3Tuple;
|
|
43
|
+
/** Random +/- spawn offset per axis from the origin. Default: [0, 0, 0]. */
|
|
44
|
+
positionSpread?: Vector3Tuple;
|
|
45
|
+
/** Initial velocity [x, y, z] in units/sec. Default: [0, 1, 0]. */
|
|
46
|
+
velocity?: Vector3Tuple;
|
|
47
|
+
/** Random +/- velocity variation per axis. Default: [0, 0, 0]. */
|
|
48
|
+
velocitySpread?: Vector3Tuple;
|
|
49
|
+
/** Forces applied each step. Default: none. */
|
|
50
|
+
forces?: ParticleForces;
|
|
51
|
+
/** Size at birth. Default: 8. */
|
|
52
|
+
startSize?: number;
|
|
53
|
+
/** Size at death. Default: 0. */
|
|
54
|
+
endSize?: number;
|
|
55
|
+
/** Color at birth. Default: white. */
|
|
56
|
+
startColor?: string;
|
|
57
|
+
/** Color at death. Default: white. */
|
|
58
|
+
endColor?: string;
|
|
59
|
+
/** Interpolate color in Oklab space for a smoother blend. Default: false. */
|
|
60
|
+
useOklab?: boolean;
|
|
61
|
+
/** Seed for the deterministic PRNG. Default: 0. */
|
|
62
|
+
seed?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* ParticleSystem - an emitter that spawns, integrates, ages and culls particles.
|
|
66
|
+
*
|
|
67
|
+
* Add it to a scene and the render loop calls {@link update} each frame, which
|
|
68
|
+
* advances the simulation by `dt`. Call {@link step} to advance it manually,
|
|
69
|
+
* for tests or offline renders.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const fountain = new ParticleSystem({
|
|
74
|
+
* spawnRate: 60,
|
|
75
|
+
* lifetime: 1.5,
|
|
76
|
+
* velocity: [0, 4, 0],
|
|
77
|
+
* velocitySpread: [1, 0.5, 1],
|
|
78
|
+
* forces: { gravity: [0, -9.8, 0] },
|
|
79
|
+
* startColor: '#ffcc00',
|
|
80
|
+
* endColor: '#ff0033',
|
|
81
|
+
* seed: 7,
|
|
82
|
+
* });
|
|
83
|
+
* scene.add(fountain);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare class ParticleSystem extends PMobject {
|
|
87
|
+
private _spawnRate;
|
|
88
|
+
private readonly _maxParticles;
|
|
89
|
+
private readonly _lifetime;
|
|
90
|
+
private readonly _lifetimeSpread;
|
|
91
|
+
private readonly _origin;
|
|
92
|
+
private readonly _positionSpread;
|
|
93
|
+
private readonly _velocity;
|
|
94
|
+
private readonly _velocitySpread;
|
|
95
|
+
private readonly _gravity;
|
|
96
|
+
private readonly _drag;
|
|
97
|
+
private readonly _startSize;
|
|
98
|
+
private readonly _endSize;
|
|
99
|
+
private readonly _startColor;
|
|
100
|
+
private readonly _endColor;
|
|
101
|
+
private readonly _useOklab;
|
|
102
|
+
private _seed;
|
|
103
|
+
/** Living particles, oldest first. */
|
|
104
|
+
private _particles;
|
|
105
|
+
/** Fractional carry so a low `spawnRate * dt` still emits over several steps. */
|
|
106
|
+
private _spawnCarry;
|
|
107
|
+
/** The deterministic PRNG, re-created from the seed on {@link reset}. */
|
|
108
|
+
private _rng;
|
|
109
|
+
constructor(options?: ParticleSystemOptions);
|
|
110
|
+
/** The seed that drives the deterministic PRNG. */
|
|
111
|
+
get seed(): number;
|
|
112
|
+
/**
|
|
113
|
+
* Set the seed and restart the PRNG from it. Does not remove living particles;
|
|
114
|
+
* call {@link reset} for a full restart.
|
|
115
|
+
*/
|
|
116
|
+
set seed(value: number);
|
|
117
|
+
/** Set the emission rate in particles per second. */
|
|
118
|
+
setSpawnRate(rate: number): this;
|
|
119
|
+
/** The current emission rate in particles per second. */
|
|
120
|
+
getSpawnRate(): number;
|
|
121
|
+
/** The number of living particles. */
|
|
122
|
+
getLivingCount(): number;
|
|
123
|
+
/**
|
|
124
|
+
* Snapshots of all living particles, oldest first. The returned records are
|
|
125
|
+
* copies, so mutating them does not change the simulation.
|
|
126
|
+
*/
|
|
127
|
+
getParticles(): ParticleSnapshot[];
|
|
128
|
+
/**
|
|
129
|
+
* Remove every particle and restart the PRNG from the seed. After a reset, the
|
|
130
|
+
* same sequence of {@link step} calls reproduces the same evolution as a fresh
|
|
131
|
+
* system with the same seed.
|
|
132
|
+
*/
|
|
133
|
+
reset(): this;
|
|
134
|
+
/**
|
|
135
|
+
* Advance the simulation by `dt` seconds. The step spawns new particles for the
|
|
136
|
+
* elapsed time, integrates position and velocity under the forces, ages every
|
|
137
|
+
* particle, and removes those whose age passes their lifetime.
|
|
138
|
+
*
|
|
139
|
+
* @param dt - Elapsed time in seconds. Values <= 0 are ignored.
|
|
140
|
+
*/
|
|
141
|
+
step(dt: number): this;
|
|
142
|
+
/** Emit `floor(spawnRate * dt + carry)` particles, up to the cap. */
|
|
143
|
+
private _spawn;
|
|
144
|
+
/** Build one particle at the emitter, with seeded spread on spawn values. */
|
|
145
|
+
private _makeParticle;
|
|
146
|
+
/** A seeded random offset in the range [-amount, amount]. */
|
|
147
|
+
private _spread;
|
|
148
|
+
/**
|
|
149
|
+
* Semi-implicit Euler integration. For each particle, apply gravity and drag to
|
|
150
|
+
* the velocity, move by the new velocity, then age it and update its size and
|
|
151
|
+
* color from the age fraction.
|
|
152
|
+
*/
|
|
153
|
+
private _integrate;
|
|
154
|
+
/** Remove particles whose age has passed their lifetime. Order is preserved. */
|
|
155
|
+
private _cull;
|
|
156
|
+
/** Mirror the living particles into the PMobject point buffer for rendering. */
|
|
157
|
+
private _syncParticlesToPoints;
|
|
158
|
+
/** An empty system has no living particles, so skip the bounding box. */
|
|
159
|
+
isEmpty(): boolean;
|
|
160
|
+
copy(): ParticleSystem;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=ParticleSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParticleSystem.d.ts","sourceRoot":"","sources":["../../../src/mobjects/particles/ParticleSystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAqB7C,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,QAAQ,EAAE,YAAY,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,EAAE,YAAY,CAAC;IACvB,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qDAAqD;AACrD,MAAM,WAAW,qBAAqB;IACpC,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;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AAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IACpC,OAAO,CAAC,KAAK,CAAS;IAEtB,sCAAsC;IACtC,OAAO,CAAC,UAAU,CAAkB;IACpC,iFAAiF;IACjF,OAAO,CAAC,WAAW,CAAK;IACxB,yEAAyE;IACzE,OAAO,CAAC,IAAI,CAAe;gBAEf,OAAO,GAAE,qBAA0B;IA2C/C,mDAAmD;IACnD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;OAGG;IACH,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAGrB;IAED,qDAAqD;IACrD,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKhC,yDAAyD;IACzD,YAAY,IAAI,MAAM;IAItB,sCAAsC;IACtC,cAAc,IAAI,MAAM;IAIxB;;;OAGG;IACH,YAAY,IAAI,gBAAgB,EAAE;IAWlC;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAQb;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAStB,qEAAqE;IACrE,OAAO,CAAC,MAAM;IAUd,6EAA6E;IAC7E,OAAO,CAAC,aAAa;IAsBrB,6DAA6D;IAC7D,OAAO,CAAC,OAAO;IAKf;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAkBlB,gFAAgF;IAChF,OAAO,CAAC,KAAK;IAIb,gFAAgF;IAChF,OAAO,CAAC,sBAAsB;IAS9B,yEAAyE;IAChE,OAAO,IAAI,OAAO;IAIlB,IAAI,IAAI,cAAc;CAqBhC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Particle-based mobjects: emitters that spawn, integrate and cull particles
|
|
3
|
+
* over time under forces, for motion graphics such as explosions and sparks.
|
|
4
|
+
*/
|
|
5
|
+
export { ParticleSystem, type ParticleSystemOptions, type ParticleForces, type ParticleSnapshot, } from './ParticleSystem';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mobjects/particles/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { VGroup } from '../../core/VGroup';
|
|
2
|
+
import { VMobject } from '../../core/VMobject';
|
|
3
|
+
import { TextOnPathAlignment, TextOnPathOverflow } from './textOnPathLayout';
|
|
4
|
+
/** A path the text can follow: a VMobject, a raw point chain, or a function. */
|
|
5
|
+
export type TextOnPathSource = VMobject | number[][] | ((t: number) => number[]);
|
|
6
|
+
/** A pre-built glyph plus its advance width, for synchronous layout. */
|
|
7
|
+
export interface TextOnPathGlyph {
|
|
8
|
+
/** The glyph mobject to position. */
|
|
9
|
+
mobject: VMobject;
|
|
10
|
+
/** Advance width in world units. Defaults to `mobject.getWidth()`. */
|
|
11
|
+
width?: number;
|
|
12
|
+
/** Extra gap before this glyph (world units). Default 0. */
|
|
13
|
+
leadingGap?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Options for {@link TextOnPath}. */
|
|
16
|
+
export interface TextOnPathOptions {
|
|
17
|
+
/** The path to lay the glyphs on. */
|
|
18
|
+
path: TextOnPathSource;
|
|
19
|
+
/** Pre-built glyphs (synchronous mode). */
|
|
20
|
+
glyphs?: TextOnPathGlyph[];
|
|
21
|
+
/** Text to render (asynchronous font mode; needs `fontUrl`). */
|
|
22
|
+
text?: string;
|
|
23
|
+
/** URL of the font file (OTF/TTF) for font mode. */
|
|
24
|
+
fontUrl?: string;
|
|
25
|
+
/** Font size in pixels. Default 48. */
|
|
26
|
+
fontSize?: number;
|
|
27
|
+
/** Glyph color. Default '#ffffff'. */
|
|
28
|
+
color?: string;
|
|
29
|
+
/** Arc-length distance where the run starts. Default 0. */
|
|
30
|
+
startOffset?: number;
|
|
31
|
+
/** Extra spacing added after every glyph (world units). Default 0. */
|
|
32
|
+
tracking?: number;
|
|
33
|
+
/** Rotate each glyph to the path tangent. Default true. */
|
|
34
|
+
rotateWithTangent?: boolean;
|
|
35
|
+
/** Vertical placement relative to the curve. Default 'center'. */
|
|
36
|
+
alignment?: TextOnPathAlignment;
|
|
37
|
+
/** Clamp to the ends or wrap around the path. Default 'clamp'. */
|
|
38
|
+
overflow?: TextOnPathOverflow;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A VGroup of glyph mobjects laid out along a path.
|
|
42
|
+
*
|
|
43
|
+
* Synchronous usage:
|
|
44
|
+
* const t = new TextOnPath({ glyphs, path: arc });
|
|
45
|
+
*
|
|
46
|
+
* Font usage:
|
|
47
|
+
* const t = new TextOnPath({ text: 'Hello', fontUrl, path: arc });
|
|
48
|
+
* await t.waitForReady();
|
|
49
|
+
*/
|
|
50
|
+
export declare class TextOnPath extends VGroup {
|
|
51
|
+
private readonly _options;
|
|
52
|
+
private readonly _path;
|
|
53
|
+
private readonly _fontSize;
|
|
54
|
+
private readonly _glyphColor;
|
|
55
|
+
private _readyPromise;
|
|
56
|
+
constructor(options: TextOnPathOptions);
|
|
57
|
+
/** Resolves once the font has loaded and glyphs are laid out (font mode). */
|
|
58
|
+
waitForReady(): Promise<void>;
|
|
59
|
+
/** Build a {@link SampledPath} from any accepted path source. */
|
|
60
|
+
private static _buildPath;
|
|
61
|
+
/**
|
|
62
|
+
* Position every glyph mobject along the path and add it to this group.
|
|
63
|
+
* Each glyph is transformed while unparented, so `rotate` and `moveTo`
|
|
64
|
+
* act in world space, then added to the group.
|
|
65
|
+
*/
|
|
66
|
+
private _layoutGlyphs;
|
|
67
|
+
/** Load the font, build a GlyphVMobject per visible character, lay them out. */
|
|
68
|
+
private _loadAndBuild;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=TextOnPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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AE,kBAAkB,CAAC;CAC/B;AAED;;;;;;;;;GASG;AACH,qBAAa,UAAW,SAAQ,MAAM;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,OAAO,EAAE,iBAAiB;IA8BtC,6EAA6E;IACvE,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,iEAAiE;IACjE,OAAO,CAAC,MAAM,CAAC,UAAU;IAUzB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAkCrB,gFAAgF;YAClE,aAAa;CAmD5B"}
|
|
@@ -8,6 +8,8 @@ export { Text, type TextOptions } from './Text';
|
|
|
8
8
|
export { type TextStyleMaps, type TextStyleRun, buildStyledTextLines } from './textStyleRuns';
|
|
9
9
|
export { GlyphVMobject, type GlyphVMobjectOptions } from './GlyphVMobject';
|
|
10
10
|
export { TextGlyphGroup, type TextGlyphGroupOptions } from './TextGlyphGroup';
|
|
11
|
+
export { TextOnPath, type TextOnPathOptions, type TextOnPathGlyph, type TextOnPathSource, } from './TextOnPath';
|
|
12
|
+
export { computeGlyphPlacements, sampledPathFromPoints, sampledPathFromFunction, visibleGlyphChars, alignmentToOffset, type SampledPath, type GlyphLayoutEntry, type GlyphLayoutOptions, type GlyphPlacement, type TextOnPathAlignment, type TextOnPathOverflow, type PathPoint, } from './textOnPathLayout';
|
|
11
13
|
export { Paragraph, type ParagraphOptions } from './Paragraph';
|
|
12
14
|
export { MarkupText, type MarkupTextOptions, type StyledTextSegment } from './MarkupText';
|
|
13
15
|
export { ensureKatexStyles, areKatexStylesLoaded, setKatexStylesheetUrl } from './katexStyles';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/m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AE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGpF,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAG5D,OAAO,EACL,IAAI,EACJ,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,KAAK,EACV,KAAK,SAAS,EACd,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,EAC/B,WAAW,EACX,KAAK,kBAAkB,GACxB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure layout math for laying glyphs along an arbitrary curve (text-on-a-path).
|
|
3
|
+
*
|
|
4
|
+
* This module has no dependency on fonts or Three.js. It turns a list of glyph
|
|
5
|
+
* advance widths and a sampled path into per-glyph placements (a center point
|
|
6
|
+
* and a rotation angle). `TextOnPath` consumes these placements to position its
|
|
7
|
+
* glyph mobjects, which keeps the geometry independently testable.
|
|
8
|
+
*
|
|
9
|
+
* All distances are arc length in world units. Angles are radians (atan2).
|
|
10
|
+
*/
|
|
11
|
+
/** A 3D point `[x, y, z]`. */
|
|
12
|
+
export type PathPoint = [number, number, number];
|
|
13
|
+
/** Vertical placement of each glyph relative to the curve. */
|
|
14
|
+
export type TextOnPathAlignment = 'center' | 'baseline' | 'top';
|
|
15
|
+
/** Behavior when a glyph runs past the end of the path. */
|
|
16
|
+
export type TextOnPathOverflow = 'clamp' | 'wrap';
|
|
17
|
+
/**
|
|
18
|
+
* A path that reports its total arc length and can be sampled by arc-length
|
|
19
|
+
* distance. Built from a cubic Bezier point chain or from a function.
|
|
20
|
+
*/
|
|
21
|
+
export interface SampledPath {
|
|
22
|
+
/** Total arc length of the path in world units. */
|
|
23
|
+
readonly totalLength: number;
|
|
24
|
+
/** Point at absolute arc-length distance `d` (clamped to `[0, totalLength]`). */
|
|
25
|
+
pointAtDistance(d: number): PathPoint;
|
|
26
|
+
/** Tangent angle (radians) at absolute arc-length distance `d`. */
|
|
27
|
+
angleAtDistance(d: number): number;
|
|
28
|
+
}
|
|
29
|
+
/** One glyph to place, described only by its advance width and leading gap. */
|
|
30
|
+
export interface GlyphLayoutEntry {
|
|
31
|
+
/** Advance width of the glyph in world units. */
|
|
32
|
+
width: number;
|
|
33
|
+
/** Extra gap before this glyph (spaces, kerning). Default 0. */
|
|
34
|
+
leadingGap?: number;
|
|
35
|
+
}
|
|
36
|
+
/** Options that drive {@link computeGlyphPlacements}. */
|
|
37
|
+
export interface GlyphLayoutOptions {
|
|
38
|
+
/** Arc-length distance where the run starts. Default 0. */
|
|
39
|
+
startOffset?: number;
|
|
40
|
+
/** Extra spacing added after every glyph. Default 0. */
|
|
41
|
+
tracking?: number;
|
|
42
|
+
/** Rotate each glyph to the path tangent. Default true. */
|
|
43
|
+
rotateWithTangent?: boolean;
|
|
44
|
+
/** Perpendicular offset from the curve (world units). Default 0. */
|
|
45
|
+
alignmentOffset?: number;
|
|
46
|
+
/** Clamp to the ends or wrap around the path. Default 'clamp'. */
|
|
47
|
+
overflow?: TextOnPathOverflow;
|
|
48
|
+
}
|
|
49
|
+
/** The computed placement of one glyph along the path. */
|
|
50
|
+
export interface GlyphPlacement {
|
|
51
|
+
/** World point where the glyph center sits. */
|
|
52
|
+
center: PathPoint;
|
|
53
|
+
/** Rotation angle in radians (0 when `rotateWithTangent` is false). */
|
|
54
|
+
angle: number;
|
|
55
|
+
/** Arc-length distance of the glyph center before clamp or wrap. */
|
|
56
|
+
distance: number;
|
|
57
|
+
/** True when the glyph center ran past an end of the path. */
|
|
58
|
+
overflow: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Build a {@link SampledPath} from a shared-anchor cubic Bezier point chain
|
|
62
|
+
* (the point layout every VMobject uses).
|
|
63
|
+
*
|
|
64
|
+
* @param points - Point chain `[A0, H1, H2, A1, H3, H4, A2, ...]`
|
|
65
|
+
* @param samplesPerSegment - Samples per cubic for the arc-length table
|
|
66
|
+
*/
|
|
67
|
+
export declare function sampledPathFromPoints(points: number[][], samplesPerSegment?: number): SampledPath;
|
|
68
|
+
/**
|
|
69
|
+
* Build a {@link SampledPath} from a parametric function `t -> [x, y, z]`,
|
|
70
|
+
* `t` in `[0, 1]`.
|
|
71
|
+
*
|
|
72
|
+
* @param fn - Parametric curve function
|
|
73
|
+
* @param samples - Number of sample segments (default 200)
|
|
74
|
+
*/
|
|
75
|
+
export declare function sampledPathFromFunction(fn: (t: number) => number[], samples?: number): SampledPath;
|
|
76
|
+
/**
|
|
77
|
+
* Place glyphs along a path by advancing a pen along the arc length.
|
|
78
|
+
*
|
|
79
|
+
* Each glyph center is set at `pen + leadingGap + width / 2`, where `pen`
|
|
80
|
+
* advances by `width + tracking` after every glyph. A glyph whose center runs
|
|
81
|
+
* past an end is marked `overflow` and is either clamped to the nearest end or
|
|
82
|
+
* wrapped around the path, per `options.overflow`.
|
|
83
|
+
*
|
|
84
|
+
* @param glyphs - Glyph advance widths and leading gaps, in order
|
|
85
|
+
* @param path - The path to lay the glyphs on
|
|
86
|
+
* @param options - Layout options (see {@link GlyphLayoutOptions})
|
|
87
|
+
* @returns One placement per input glyph
|
|
88
|
+
*/
|
|
89
|
+
export declare function computeGlyphPlacements(glyphs: GlyphLayoutEntry[], path: SampledPath, options?: GlyphLayoutOptions): GlyphPlacement[];
|
|
90
|
+
/**
|
|
91
|
+
* The visible (non-whitespace) characters of a string, in order.
|
|
92
|
+
* Whitespace advances the pen but draws no glyph, so it is excluded here.
|
|
93
|
+
*
|
|
94
|
+
* @param text - Input string
|
|
95
|
+
* @returns Array of visible characters
|
|
96
|
+
*/
|
|
97
|
+
export declare function visibleGlyphChars(text: string): string[];
|
|
98
|
+
/**
|
|
99
|
+
* Map an {@link TextOnPathAlignment} to a perpendicular offset from the curve.
|
|
100
|
+
*
|
|
101
|
+
* `center` keeps the glyph center on the curve. `baseline` lifts it to the
|
|
102
|
+
* positive-perpendicular side (baseline near the curve) and `top` lowers it,
|
|
103
|
+
* each by `height / 2`.
|
|
104
|
+
*
|
|
105
|
+
* @param alignment - Alignment mode
|
|
106
|
+
* @param height - Representative glyph height in world units
|
|
107
|
+
* @returns Perpendicular offset in world units
|
|
108
|
+
*/
|
|
109
|
+
export declare function alignmentToOffset(alignment: TextOnPathAlignment, height: number): number;
|
|
110
|
+
//# sourceMappingURL=textOnPathLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textOnPathLayout.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/textOnPathLayout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,8BAA8B;AAC9B,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD,8DAA8D;AAC9D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAC;AAEhE,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,iFAAiF;IACjF,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,mEAAmE;IACnE,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACpC;AAED,+EAA+E;AAC/E,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,gEAAg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