@motionscript/math 0.1.0-alpha.9 → 0.1.1-alpha.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/CHANGELOG.md +23 -0
- package/dist/annotate/angle-mark.d.ts +4 -14
- package/dist/annotate/angle-mark.d.ts.map +1 -1
- package/dist/annotate/angle-mark.js +2 -1
- package/dist/annotate/angle-mark.js.map +1 -1
- package/dist/annotate/curly-brace.d.ts +4 -16
- package/dist/annotate/curly-brace.d.ts.map +1 -1
- package/dist/annotate/curly-brace.js.map +1 -1
- package/dist/annotate/emphasis-mark.d.ts +0 -5
- package/dist/annotate/emphasis-mark.d.ts.map +1 -1
- package/dist/annotate/emphasis-mark.js.map +1 -1
- package/dist/browser/chunks/chunk-FZ2YBTPL.js +2 -0
- package/dist/browser/chunks/chunk-FZ2YBTPL.js.map +7 -0
- package/dist/browser/chunks/chunk-T42HWKBC.js +2 -0
- package/dist/browser/chunks/chunk-T42HWKBC.js.map +7 -0
- package/dist/browser/chunks/{mathjax-WV55AC2P.js → mathjax-SOM6RSPV.js} +1 -1
- package/dist/browser/chunks/{mathjax-WV55AC2P.js.map → mathjax-SOM6RSPV.js.map} +2 -2
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/tex.js +1 -1
- package/dist/engine.d.ts +3 -4
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +3 -4
- package/dist/engine.js.map +1 -1
- package/dist/kit/cache.d.ts +10 -21
- package/dist/kit/cache.d.ts.map +1 -1
- package/dist/kit/cache.js +33 -24
- package/dist/kit/cache.js.map +1 -1
- package/dist/kit/component.d.ts +5 -14
- package/dist/kit/component.d.ts.map +1 -1
- package/dist/kit/component.js +1 -8
- package/dist/kit/component.js.map +1 -1
- package/dist/kit/coords.d.ts +1 -1
- package/dist/kit/coords.d.ts.map +1 -1
- package/dist/kit/coords.js +2 -1
- package/dist/kit/coords.js.map +1 -1
- package/dist/kit/curve.d.ts +1 -5
- package/dist/kit/curve.d.ts.map +1 -1
- package/dist/kit/curve.js.map +1 -1
- package/dist/kit/equation.d.ts +10 -30
- package/dist/kit/equation.d.ts.map +1 -1
- package/dist/kit/equation.js +9 -44
- package/dist/kit/equation.js.map +1 -1
- package/dist/kit/equation3d.d.ts +3 -3
- package/dist/kit/equation3d.d.ts.map +1 -1
- package/dist/kit/equation3d.js +27 -59
- package/dist/kit/equation3d.js.map +1 -1
- package/dist/kit/expression.d.ts +7 -7
- package/dist/kit/expression.d.ts.map +1 -1
- package/dist/kit/expression.js +18 -17
- package/dist/kit/expression.js.map +1 -1
- package/dist/kit/field-mark.d.ts +0 -7
- package/dist/kit/field-mark.d.ts.map +1 -1
- package/dist/kit/field-mark.js.map +1 -1
- package/dist/kit/field.d.ts +2 -2
- package/dist/kit/field.d.ts.map +1 -1
- package/dist/kit/field.js +11 -31
- package/dist/kit/field.js.map +1 -1
- package/dist/kit/follow.d.ts +3 -10
- package/dist/kit/follow.d.ts.map +1 -1
- package/dist/kit/follow.js +5 -11
- package/dist/kit/follow.js.map +1 -1
- package/dist/kit/furniture.d.ts +2 -1
- package/dist/kit/furniture.d.ts.map +1 -1
- package/dist/kit/furniture.js +6 -3
- package/dist/kit/furniture.js.map +1 -1
- package/dist/kit/geometry.d.ts +1 -0
- package/dist/kit/geometry.d.ts.map +1 -1
- package/dist/kit/geometry.js +3 -0
- package/dist/kit/geometry.js.map +1 -1
- package/dist/kit/mark.d.ts +4 -10
- package/dist/kit/mark.d.ts.map +1 -1
- package/dist/kit/mark.js.map +1 -1
- package/dist/kit/place.d.ts +3 -5
- package/dist/kit/place.d.ts.map +1 -1
- package/dist/kit/place.js +3 -5
- package/dist/kit/place.js.map +1 -1
- package/dist/kit/sampler.d.ts +0 -5
- package/dist/kit/sampler.d.ts.map +1 -1
- package/dist/kit/sampler.js.map +1 -1
- package/dist/kit/system.d.ts +0 -1
- package/dist/kit/system.d.ts.map +1 -1
- package/dist/kit/system.js +3 -10
- package/dist/kit/system.js.map +1 -1
- package/dist/marks/curve-area.d.ts +2 -12
- package/dist/marks/curve-area.d.ts.map +1 -1
- package/dist/marks/curve-area.js +4 -9
- package/dist/marks/curve-area.js.map +1 -1
- package/dist/marks/drop-lines.d.ts +1 -5
- package/dist/marks/drop-lines.d.ts.map +1 -1
- package/dist/marks/drop-lines.js.map +1 -1
- package/dist/marks/plot-point.d.ts +4 -13
- package/dist/marks/plot-point.d.ts.map +1 -1
- package/dist/marks/plot-point.js.map +1 -1
- package/dist/marks/riemann-sum.d.ts +1 -7
- package/dist/marks/riemann-sum.d.ts.map +1 -1
- package/dist/marks/riemann-sum.js +2 -2
- package/dist/marks/riemann-sum.js.map +1 -1
- package/dist/marks/tangent-line.d.ts +2 -12
- package/dist/marks/tangent-line.d.ts.map +1 -1
- package/dist/marks/tangent-line.js +1 -5
- package/dist/marks/tangent-line.js.map +1 -1
- package/dist/marks/vector-arrow.d.ts +2 -11
- package/dist/marks/vector-arrow.d.ts.map +1 -1
- package/dist/marks/vector-arrow.js +3 -6
- package/dist/marks/vector-arrow.js.map +1 -1
- package/dist/nodes.d.ts +1 -12
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js.map +1 -1
- package/dist/plots/function-plot.d.ts +1 -6
- package/dist/plots/function-plot.d.ts.map +1 -1
- package/dist/plots/function-plot.js +1 -5
- package/dist/plots/function-plot.js.map +1 -1
- package/dist/plots/points-plot.d.ts +1 -6
- package/dist/plots/points-plot.d.ts.map +1 -1
- package/dist/plots/points-plot.js.map +1 -1
- package/dist/plots/stream-lines.d.ts +0 -7
- package/dist/plots/stream-lines.d.ts.map +1 -1
- package/dist/plots/stream-lines.js.map +1 -1
- package/dist/plots/traced-path.d.ts +1 -12
- package/dist/plots/traced-path.d.ts.map +1 -1
- package/dist/plots/traced-path.js +1 -6
- package/dist/plots/traced-path.js.map +1 -1
- package/dist/plots/vector-field.d.ts +1 -10
- package/dist/plots/vector-field.d.ts.map +1 -1
- package/dist/plots/vector-field.js +3 -6
- package/dist/plots/vector-field.js.map +1 -1
- package/dist/structures/network-graph.d.ts +15 -34
- package/dist/structures/network-graph.d.ts.map +1 -1
- package/dist/structures/network-graph.js +2 -5
- package/dist/structures/network-graph.js.map +1 -1
- package/dist/structures/sample-space.d.ts +8 -22
- package/dist/structures/sample-space.d.ts.map +1 -1
- package/dist/structures/sample-space.js +3 -5
- package/dist/structures/sample-space.js.map +1 -1
- package/dist/systems/axes2d.d.ts +0 -1
- package/dist/systems/axes2d.d.ts.map +1 -1
- package/dist/systems/axes2d.js +3 -4
- package/dist/systems/axes2d.js.map +1 -1
- package/dist/systems/number-line.d.ts +7 -22
- package/dist/systems/number-line.d.ts.map +1 -1
- package/dist/systems/number-line.js +2 -2
- package/dist/systems/number-line.js.map +1 -1
- package/dist/systems/number-plane.d.ts +12 -27
- package/dist/systems/number-plane.d.ts.map +1 -1
- package/dist/systems/number-plane.js +1 -7
- package/dist/systems/number-plane.js.map +1 -1
- package/dist/systems/polar-plane.d.ts +11 -26
- package/dist/systems/polar-plane.d.ts.map +1 -1
- package/dist/systems/polar-plane.js +7 -10
- package/dist/systems/polar-plane.js.map +1 -1
- package/dist/tex/geometry.d.ts +5 -24
- package/dist/tex/geometry.d.ts.map +1 -1
- package/dist/tex/geometry.js +19 -90
- package/dist/tex/geometry.js.map +1 -1
- package/dist/tex/mathjax.d.ts +0 -13
- package/dist/tex/mathjax.d.ts.map +1 -1
- package/dist/tex/mathjax.js +4 -24
- package/dist/tex/mathjax.js.map +1 -1
- package/dist/tex/matrix.d.ts +1 -10
- package/dist/tex/matrix.d.ts.map +1 -1
- package/dist/tex/matrix.js +1 -5
- package/dist/tex/matrix.js.map +1 -1
- package/dist/tex/tween.d.ts +9 -30
- package/dist/tex/tween.d.ts.map +1 -1
- package/dist/tex/tween.js +19 -67
- package/dist/tex/tween.js.map +1 -1
- package/dist/tex/typeset.d.ts +2 -23
- package/dist/tex/typeset.d.ts.map +1 -1
- package/dist/tex/typeset.js +4 -30
- package/dist/tex/typeset.js.map +1 -1
- package/dist/three/axes3d.d.ts +32 -62
- package/dist/three/axes3d.d.ts.map +1 -1
- package/dist/three/axes3d.js +5 -13
- package/dist/three/axes3d.js.map +1 -1
- package/dist/three/curve-plot3d.d.ts +4 -15
- package/dist/three/curve-plot3d.d.ts.map +1 -1
- package/dist/three/curve-plot3d.js.map +1 -1
- package/dist/three/plot-point3d.d.ts +7 -14
- package/dist/three/plot-point3d.d.ts.map +1 -1
- package/dist/three/plot-point3d.js.map +1 -1
- package/dist/three/space.d.ts +3 -8
- package/dist/three/space.d.ts.map +1 -1
- package/dist/three/space.js +1 -8
- package/dist/three/space.js.map +1 -1
- package/dist/three/surface-plot3d.d.ts +9 -23
- package/dist/three/surface-plot3d.d.ts.map +1 -1
- package/dist/three/surface-plot3d.js.map +1 -1
- package/dist/three/vector-arrow3d.d.ts +1 -7
- package/dist/three/vector-arrow3d.d.ts.map +1 -1
- package/dist/three/vector-arrow3d.js.map +1 -1
- package/package.json +4 -4
- package/src/annotate/angle-mark.ts +4 -14
- package/src/annotate/curly-brace.ts +2 -14
- package/src/annotate/emphasis-mark.ts +1 -6
- package/src/engine.ts +3 -4
- package/src/kit/cache.ts +33 -25
- package/src/kit/component.ts +5 -19
- package/src/kit/coords.ts +2 -2
- package/src/kit/curve.ts +1 -5
- package/src/kit/equation.ts +12 -50
- package/src/kit/equation3d.ts +23 -59
- package/src/kit/expression.ts +18 -23
- package/src/kit/field-mark.ts +1 -7
- package/src/kit/field.ts +10 -26
- package/src/kit/follow.ts +5 -13
- package/src/kit/furniture.ts +7 -4
- package/src/kit/geometry.ts +4 -0
- package/src/kit/mark.ts +4 -11
- package/src/kit/place.ts +3 -5
- package/src/kit/sampler.ts +0 -6
- package/src/kit/system.ts +3 -12
- package/src/marks/curve-area.ts +3 -16
- package/src/marks/drop-lines.ts +0 -6
- package/src/marks/plot-point.ts +2 -12
- package/src/marks/riemann-sum.ts +2 -10
- package/src/marks/tangent-line.ts +1 -13
- package/src/marks/vector-arrow.ts +3 -13
- package/src/nodes.ts +1 -12
- package/src/plots/function-plot.ts +1 -6
- package/src/plots/points-plot.ts +0 -7
- package/src/plots/stream-lines.ts +1 -8
- package/src/plots/traced-path.ts +2 -13
- package/src/plots/vector-field.ts +4 -12
- package/src/structures/network-graph.ts +6 -25
- package/src/structures/sample-space.ts +5 -20
- package/src/systems/axes2d.ts +3 -6
- package/src/systems/number-line.ts +4 -20
- package/src/systems/number-plane.ts +4 -19
- package/src/systems/polar-plane.ts +11 -25
- package/src/tex/geometry.ts +24 -126
- package/src/tex/mathjax.ts +4 -26
- package/src/tex/matrix.ts +1 -11
- package/src/tex/tween.ts +21 -75
- package/src/tex/typeset.ts +4 -37
- package/src/three/axes3d.ts +7 -42
- package/src/three/curve-plot3d.ts +0 -12
- package/src/three/plot-point3d.ts +0 -10
- package/src/three/space.ts +2 -11
- package/src/three/surface-plot3d.ts +0 -15
- package/src/three/vector-arrow3d.ts +0 -8
- package/dist/browser/chunks/chunk-IRZCG6PM.js +0 -2
- package/dist/browser/chunks/chunk-IRZCG6PM.js.map +0 -7
- package/dist/browser/chunks/chunk-WMVW6ZIV.js +0 -2
- package/dist/browser/chunks/chunk-WMVW6ZIV.js.map +0 -7
- package/dist/kit/withdrawn.d.ts +0 -9
- package/dist/kit/withdrawn.d.ts.map +0 -1
- package/dist/kit/withdrawn.js +0 -9
- package/dist/kit/withdrawn.js.map +0 -1
- package/src/kit/withdrawn.ts +0 -8
package/src/tex/typeset.ts
CHANGED
|
@@ -36,17 +36,8 @@ import { createBoundedCache } from "../kit/cache";
|
|
|
36
36
|
import { omit } from "../kit/component";
|
|
37
37
|
import { lerpPartFills, partPaint, readPartFills, withPartFill, type PartFill, type PartFillResolved } from "../kit/part-fills";
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
* A formula typeset to glyph paths: what `latex` and `latexMatrix` share. A
|
|
41
|
-
* node says where its formula comes from (`formula`); this lays it out, draws
|
|
42
|
-
* it, writes it on, paints its parts, and morphs it into another.
|
|
43
|
-
*
|
|
44
|
-
* A morph is held by the entries the formula is written from: mid-tween each
|
|
45
|
-
* holds both ends ({@link Morph}), so a seek to any time draws the morph there
|
|
46
|
-
* from the node's own state, and a plain `to({ latex })` morphs as `morphTo` does.
|
|
47
|
-
*/
|
|
39
|
+
// Mid-morph an entry holds both ends (Morph), so a seek draws the morph from the node's own state.
|
|
48
40
|
|
|
49
|
-
/** A value on its way to another: what an entry the formula is written from holds mid-tween. */
|
|
50
41
|
export class Morph<T> {
|
|
51
42
|
constructor(readonly from: T, readonly to: T, readonly t: number) { }
|
|
52
43
|
}
|
|
@@ -75,7 +66,6 @@ export function morphOf<T>(parts: readonly Morphing<unknown>[], combine: (ends:
|
|
|
75
66
|
|
|
76
67
|
const { start: _start, end: _end, ...glyphPaint } = Paint.state;
|
|
77
68
|
|
|
78
|
-
/** What every formula has: the glyphs' paint, the flow its children are laid out in, its size, its part fills and how much of it is written. */
|
|
79
69
|
export const TYPESET = {
|
|
80
70
|
// A formula writes itself on (`written`), so it trims no outline.
|
|
81
71
|
...glyphPaint,
|
|
@@ -83,10 +73,6 @@ export const TYPESET = {
|
|
|
83
73
|
fontSize: 16,
|
|
84
74
|
/** Paints for parts of the formula, named by their source. Later entries win where two name a glyph. */
|
|
85
75
|
partFills: Types.custom<PartFill[], PartFillResolved[]>([], { resolve: readPartFills, lerp: lerpPartFills, kind: "vector" }),
|
|
86
|
-
/**
|
|
87
|
-
* How much of the formula is written, 0 to 1: its glyphs are drawn one after
|
|
88
|
-
* another, each outlined and then filled.
|
|
89
|
-
*/
|
|
90
76
|
written: Types.number(1, { min: 0, max: 1, step: 0.01 }),
|
|
91
77
|
/** Reported for a host that read it; the morph is held by the formula's own entries. */
|
|
92
78
|
morphProgress: Types.number(0, { animatable: false }),
|
|
@@ -95,9 +81,7 @@ export const TYPESET = {
|
|
|
95
81
|
export const TYPESET_COMMANDS = {
|
|
96
82
|
...omit(Paint.commands, "progressTo", "flash"),
|
|
97
83
|
...commandsFor(TYPESET, {
|
|
98
|
-
/** Write the formula on, or off: its glyphs one after another, each outlined and then filled. */
|
|
99
84
|
writeTo: { args: ["written"] },
|
|
100
|
-
/** Paint one part of the formula, leaving the rest as it is. */
|
|
101
85
|
partFillTo: {
|
|
102
86
|
args: {
|
|
103
87
|
part: Types.text(""),
|
|
@@ -115,9 +99,6 @@ export const TYPESET_COMMANDS = {
|
|
|
115
99
|
|
|
116
100
|
type TypesetValues = Values<typeof TYPESET>;
|
|
117
101
|
|
|
118
|
-
// ---- the formula at a moment ------------------------------------------------
|
|
119
|
-
|
|
120
|
-
/** What is drawn of a formula now: its glyphs, its parts, its centre frame and size, and mid-morph each end's part fills. */
|
|
121
102
|
export interface FormulaFrame {
|
|
122
103
|
readonly tokens: readonly AnimatedToken[];
|
|
123
104
|
readonly parts: readonly LatexPart[];
|
|
@@ -148,7 +129,6 @@ function atRest(source: string, fontSize: number): FormulaFrame {
|
|
|
148
129
|
const resting = new WeakMap<LatexToken[], FormulaFrame>();
|
|
149
130
|
|
|
150
131
|
function restingFrame(result: LatexPathResult): FormulaFrame {
|
|
151
|
-
// The typeset result is shared by every reader of the formula; its tokens wrapped once.
|
|
152
132
|
let frame = resting.get(result.tokens);
|
|
153
133
|
if (!frame) {
|
|
154
134
|
frame = {
|
|
@@ -217,15 +197,12 @@ export function formulaFrame(
|
|
|
217
197
|
};
|
|
218
198
|
}
|
|
219
199
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
/** Its formula's size and its padding, hugging; the factory applies a set or filling size. */
|
|
200
|
+
/** Hugging size; the factory applies a set or filling one. */
|
|
223
201
|
export function measureFormula(frame: FormulaFrame, s: { readonly padding: InsetsResolved }): Size2D {
|
|
224
202
|
const pad = s.padding;
|
|
225
203
|
return { width: frame.width + pad.left + pad.right, height: frame.height + pad.top + pad.bottom };
|
|
226
204
|
}
|
|
227
205
|
|
|
228
|
-
/** Its children, laid out in its box clear of its stroke, as a shape lays out its own. */
|
|
229
206
|
export function layoutFormula(box: BoxBounds, s: Flow.FlowState & { readonly stroke: StrokeResolved[] }, children: readonly ChildView<any>[]): readonly Placement2D[] {
|
|
230
207
|
return Flow.layout(box, s, children, strokeInset(s.stroke));
|
|
231
208
|
}
|
|
@@ -244,18 +221,12 @@ export function loadFormula(loader: Loader): void {
|
|
|
244
221
|
loader.task(MATHJAX_LOADER, loadMathJax, { before: "layout" });
|
|
245
222
|
}
|
|
246
223
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
/** How much of one glyph's writing overlaps the next one's. */
|
|
224
|
+
/** The share of one glyph's writing that overlaps the next one's. */
|
|
250
225
|
const WRITE_OVERLAP = 0.6;
|
|
251
226
|
/** The outline a glyph is written with, as a share of the type size. */
|
|
252
227
|
const WRITE_STROKE = 1 / 32;
|
|
253
228
|
|
|
254
|
-
/**
|
|
255
|
-
* The glyphs, in a node's paint order: each one's shadow, fill and stroke
|
|
256
|
-
* (the shadow op first, so the paint after it casts it), the pen's line while
|
|
257
|
-
* it is being written, then the children, then the overlay through the glyphs.
|
|
258
|
-
*/
|
|
229
|
+
/** Glyphs (shadow, fill, stroke, then the pen's line while written), then children, then the overlay through the glyphs. */
|
|
259
230
|
export function drawFormula(ctx: RenderContext, s: TypesetValues, frame: FormulaFrame): void {
|
|
260
231
|
ctx.inFront(() => drawGlyphs(ctx, s, frame));
|
|
261
232
|
ctx.children();
|
|
@@ -365,8 +336,6 @@ function eachToken(
|
|
|
365
336
|
});
|
|
366
337
|
}
|
|
367
338
|
|
|
368
|
-
// ---- parts --------------------------------------------------------------------
|
|
369
|
-
|
|
370
339
|
/**
|
|
371
340
|
* The box around one part of the formula, centred on the node's own centre and
|
|
372
341
|
* y-up, or `null` when the formula does not write `part` (or is mid-morph).
|
|
@@ -417,8 +386,6 @@ export function latexPartBounds(node: object, part: string, occurrence = 1): Box
|
|
|
417
386
|
return frame ? partBoundsIn(frame, part, occurrence) : undefined;
|
|
418
387
|
}
|
|
419
388
|
|
|
420
|
-
// ---- paint helpers ------------------------------------------------------------
|
|
421
|
-
|
|
422
389
|
function fillsByToken(partFills: readonly PartFillResolved[], parts: readonly LatexPart[], count: number): TokenFills {
|
|
423
390
|
const out: TokenFills = new Array(count);
|
|
424
391
|
for (const entry of partFills) {
|
package/src/three/axes3d.ts
CHANGED
|
@@ -9,8 +9,6 @@ import {
|
|
|
9
9
|
Shapes,
|
|
10
10
|
Types,
|
|
11
11
|
View3D,
|
|
12
|
-
type Canvas3DProps,
|
|
13
|
-
type Color,
|
|
14
12
|
type NodeOf,
|
|
15
13
|
type Scene3D,
|
|
16
14
|
type Transform3D,
|
|
@@ -28,6 +26,8 @@ import {
|
|
|
28
26
|
type GapSize as _GapSize,
|
|
29
27
|
type Node2D as _Node2D,
|
|
30
28
|
type Node2DProps as _Node2DProps,
|
|
29
|
+
type Color as _Color,
|
|
30
|
+
|
|
31
31
|
type NormalizedColor as _NormalizedColor,
|
|
32
32
|
type PostEffect3D as _PostEffect3D,
|
|
33
33
|
type RectCornerRadius as _RectCornerRadius,
|
|
@@ -41,38 +41,12 @@ import {
|
|
|
41
41
|
type Vector2 as _Vector2,
|
|
42
42
|
} from "@motionscript/sdk";
|
|
43
43
|
import type { Interval } from "../kit/coords";
|
|
44
|
-
import { AXIS_COLOR,
|
|
44
|
+
import { AXIS_COLOR, intervalEntry } from "../kit/furniture";
|
|
45
45
|
import { clamp } from "../kit/geometry";
|
|
46
46
|
import { formatTick, ticksFor } from "../kit/ticks";
|
|
47
47
|
import { drawLabel3D, type LabelStyle3D } from "./label3d";
|
|
48
48
|
import { GRAPH_3D, graphSpace, type Graph3D, type GraphSpace } from "./space";
|
|
49
49
|
|
|
50
|
-
export interface Axes3dProps extends Canvas3DProps {
|
|
51
|
-
xRange?: Interval;
|
|
52
|
-
yRange?: Interval;
|
|
53
|
-
zRange?: Interval;
|
|
54
|
-
xLength?: number;
|
|
55
|
-
yLength?: number;
|
|
56
|
-
zLength?: number;
|
|
57
|
-
xStep?: number;
|
|
58
|
-
yStep?: number;
|
|
59
|
-
zStep?: number;
|
|
60
|
-
color?: Color;
|
|
61
|
-
thickness?: number;
|
|
62
|
-
tips?: boolean;
|
|
63
|
-
ticks?: boolean;
|
|
64
|
-
tickSize?: number;
|
|
65
|
-
grid?: boolean;
|
|
66
|
-
gridLineColor?: Color;
|
|
67
|
-
labels?: boolean;
|
|
68
|
-
labelSize?: number;
|
|
69
|
-
labelColor?: Color;
|
|
70
|
-
fontFamily?: string;
|
|
71
|
-
xLabel?: string;
|
|
72
|
-
yLabel?: string;
|
|
73
|
-
zLabel?: string;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
50
|
/** How many pixels of a 2D axis one scene unit counts as, when an axis picks its own tick spacing. */
|
|
77
51
|
const UNIT_AS_PIXELS = 64;
|
|
78
52
|
|
|
@@ -84,15 +58,11 @@ const ALONG: Record<AxisName, Vector3Input> = { x: [90, 0, 0], y: [0, 0, -90], z
|
|
|
84
58
|
/** The graph axis each axis's tick marks lie along. */
|
|
85
59
|
const TICK_ALONG: Record<AxisName, AxisName> = { x: "y", y: "x", z: "y" };
|
|
86
60
|
|
|
87
|
-
function range(initial: Interval) {
|
|
88
|
-
return Types.custom<Interval>(initial, { resolve: readInterval, lerp: lerpInterval });
|
|
89
|
-
}
|
|
90
|
-
|
|
91
61
|
/** The axes' own entries, beside a 3D canvas's. */
|
|
92
62
|
const own = {
|
|
93
|
-
xRange:
|
|
94
|
-
yRange:
|
|
95
|
-
zRange:
|
|
63
|
+
xRange: intervalEntry([-3, 3]),
|
|
64
|
+
yRange: intervalEntry([-3, 3]),
|
|
65
|
+
zRange: intervalEntry([-2, 2]),
|
|
96
66
|
/** How long each axis is drawn, in scene units. */
|
|
97
67
|
xLength: Types.number(6, { min: 0.01, step: 0.1 }),
|
|
98
68
|
yLength: Types.number(6, { min: 0.01, step: 0.1 }),
|
|
@@ -125,12 +95,7 @@ const own = {
|
|
|
125
95
|
|
|
126
96
|
type AxesValues = Values<typeof own>;
|
|
127
97
|
|
|
128
|
-
/**
|
|
129
|
-
* A 3D graph: three axes through a box of graph coordinates, z up, seen through
|
|
130
|
-
* a camera of its own, so it stands on a 2D stage as it is, the way `axes2d`
|
|
131
|
-
* does. Its 3D children sit in its graph coordinates: a surface, a space curve,
|
|
132
|
-
* a point, an arrow, or any 3D node. `orbitTo` swings the camera round it.
|
|
133
|
-
*/
|
|
98
|
+
/** A 3D graph: three axes through a box of graph coordinates, z up, seen through its own camera. Its 3D children sit in graph coordinates. */
|
|
134
99
|
export const Axes3d = component2d({
|
|
135
100
|
key: "axes3d",
|
|
136
101
|
state: { ...Paint.state, ...Flow.state, ...Shapes.corners, ...View3D.state, ...own },
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
Material,
|
|
6
6
|
Types,
|
|
7
7
|
type Geometry3D,
|
|
8
|
-
type Mesh3DProps,
|
|
9
8
|
type NodeOf,
|
|
10
9
|
type Values,
|
|
11
10
|
type Vector3,
|
|
@@ -21,7 +20,6 @@ import {
|
|
|
21
20
|
type Shading3D as _Shading3D,
|
|
22
21
|
type Texture3D as _Texture3D,
|
|
23
22
|
} from "@motionscript/sdk";
|
|
24
|
-
import type { Interval } from "../kit/coords";
|
|
25
23
|
import { parseSpaceCurve, spaceCurveParams, type SpaceCurveEquation } from "../kit/equation3d";
|
|
26
24
|
import type { ExpressionScope } from "../kit/expression";
|
|
27
25
|
import { PLOT_COLOR } from "../kit/furniture";
|
|
@@ -30,16 +28,6 @@ import { lerpParams, lerpSource, readSource, scopeFor, type PlotSource } from ".
|
|
|
30
28
|
import { domainEntry, meshEntries } from "./entries";
|
|
31
29
|
import { graphEntry, graphOf, type GraphSpace } from "./space";
|
|
32
30
|
|
|
33
|
-
export interface CurvePlot3dProps extends Mesh3DProps {
|
|
34
|
-
expression?: string | PlotSource;
|
|
35
|
-
domain?: Interval | null;
|
|
36
|
-
params?: ExpressionScope;
|
|
37
|
-
samples?: number;
|
|
38
|
-
thickness?: number;
|
|
39
|
-
start?: number;
|
|
40
|
-
end?: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
31
|
const state = {
|
|
44
32
|
...meshEntries,
|
|
45
33
|
expression: Types.custom<string | PlotSource, PlotSource>("", {
|
|
@@ -3,8 +3,6 @@ import {
|
|
|
3
3
|
Geo,
|
|
4
4
|
Material,
|
|
5
5
|
Types,
|
|
6
|
-
type Color,
|
|
7
|
-
type Mesh3DProps,
|
|
8
6
|
type NodeOf,
|
|
9
7
|
// Named so the emitted declaration reaches these through the sdk, not core.
|
|
10
8
|
type Blend3D as _Blend3D,
|
|
@@ -22,14 +20,6 @@ import {
|
|
|
22
20
|
import { meshEntries } from "./entries";
|
|
23
21
|
import { drawLabel3D } from "./label3d";
|
|
24
22
|
|
|
25
|
-
export interface PlotPoint3dProps extends Mesh3DProps {
|
|
26
|
-
radius?: number;
|
|
27
|
-
label?: string;
|
|
28
|
-
labelSize?: number;
|
|
29
|
-
labelColor?: Color;
|
|
30
|
-
fontFamily?: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
23
|
/**
|
|
34
24
|
* A dot at graph coordinates in a 3D graph, with an optional label. Put inside
|
|
35
25
|
* a surface it rides it: its `x` and `y` say where, and its height is the surface's.
|
package/src/three/space.ts
CHANGED
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
createContext,
|
|
3
3
|
Types,
|
|
4
4
|
type ChildSpace3D,
|
|
5
|
-
type Node3D,
|
|
6
5
|
type Type,
|
|
7
6
|
type Vector3,
|
|
8
7
|
// Named so the emitted declaration reaches these through the sdk, not core.
|
|
@@ -21,7 +20,7 @@ export interface GraphSpace extends ChildSpace3D {
|
|
|
21
20
|
readonly zRange: Interval;
|
|
22
21
|
/** Changes exactly when the mapping does: what a mark's geometry is cached under. */
|
|
23
22
|
readonly revision: string;
|
|
24
|
-
/** A
|
|
23
|
+
/** A graph step as a local one: what a mark's own geometry is drawn in. */
|
|
25
24
|
offset(x: number, y: number, z: number): Vector3;
|
|
26
25
|
}
|
|
27
26
|
|
|
@@ -56,10 +55,7 @@ export interface Graph3D {
|
|
|
56
55
|
/** The graph a mark is inside: `axes3d` provides itself to everything in it. */
|
|
57
56
|
export const GRAPH_3D = createContext<Graph3D | null>(null, "math:graph3d");
|
|
58
57
|
|
|
59
|
-
/**
|
|
60
|
-
* The entry a mark reads the graph it is drawn in through, set from the nearest
|
|
61
|
-
* `axes3d` above it, through any 3D node between; `null` outside one.
|
|
62
|
-
*/
|
|
58
|
+
/** The entry a mark reads its graph through, set from the nearest `axes3d` above it; `null` outside one. */
|
|
63
59
|
export function graphEntry(): Type<Graph3D | null, Graph3D | null, true> {
|
|
64
60
|
return Types.custom<Graph3D | null, Graph3D | null, { readonly private: true }>(null, {
|
|
65
61
|
private: true,
|
|
@@ -72,11 +68,6 @@ export function graphOf(mark: { readonly graph: Graph3D | null }): GraphSpace |
|
|
|
72
68
|
return mark.graph?.space() ?? null;
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
/** The graph a 3D node is drawn in: what the nearest `axes3d` above it provides, once it is in the tree. */
|
|
76
|
-
export function spaceOf(mark: Node3D): GraphSpace | null {
|
|
77
|
-
return mark.useContext(GRAPH_3D)?.space() ?? null;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
71
|
/** A unit quaternion turning the scene's +y, the way a cylinder or a cone points, onto `direction`. */
|
|
81
72
|
export function aim(direction: Vector3): { x: number; y: number; z: number; w: number } {
|
|
82
73
|
const length = Math.hypot(direction.x, direction.y, direction.z);
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
type Color,
|
|
11
11
|
type Geometry3D,
|
|
12
12
|
type Material3D,
|
|
13
|
-
type Mesh3DProps,
|
|
14
13
|
type NodeOf,
|
|
15
14
|
type NormalizedColor,
|
|
16
15
|
type Values,
|
|
@@ -26,7 +25,6 @@ import {
|
|
|
26
25
|
type Shading3D as _Shading3D,
|
|
27
26
|
type Texture3D as _Texture3D,
|
|
28
27
|
} from "@motionscript/sdk";
|
|
29
|
-
import type { Interval } from "../kit/coords";
|
|
30
28
|
import { parseSurface, surfaceParams, type SurfaceEquation } from "../kit/equation3d";
|
|
31
29
|
import type { ExpressionScope } from "../kit/expression";
|
|
32
30
|
import { PLOT_COLOR } from "../kit/furniture";
|
|
@@ -36,18 +34,6 @@ import { lerpParams, lerpSource, readSource, revisionOf, scopeFor, type PlotSour
|
|
|
36
34
|
import { domainEntry, meshEntries } from "./entries";
|
|
37
35
|
import { graphEntry, graphOf, type GraphSpace } from "./space";
|
|
38
36
|
|
|
39
|
-
export interface SurfacePlot3dProps extends Mesh3DProps {
|
|
40
|
-
expression?: string | PlotSource;
|
|
41
|
-
uDomain?: Interval | null;
|
|
42
|
-
vDomain?: Interval | null;
|
|
43
|
-
params?: ExpressionScope;
|
|
44
|
-
segments?: number;
|
|
45
|
-
colorScale?: Color[];
|
|
46
|
-
meshLines?: number;
|
|
47
|
-
meshColor?: Color;
|
|
48
|
-
floorShadow?: number;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
37
|
/** A graph point for grid coordinate `(u, v)`, both 0 to 1, written into `out`. */
|
|
52
38
|
type SurfaceSampler = (u: number, v: number, out: Vector3) => void;
|
|
53
39
|
|
|
@@ -79,7 +65,6 @@ const state = {
|
|
|
79
65
|
graph: graphEntry(),
|
|
80
66
|
};
|
|
81
67
|
|
|
82
|
-
/** What a surface is drawn from: its own entries, as its node and its helpers read them. */
|
|
83
68
|
export type SurfaceValues = Values<typeof state> & { readonly x: number; readonly y: number; readonly z: number };
|
|
84
69
|
|
|
85
70
|
/**
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
Material,
|
|
6
6
|
resolveVector3,
|
|
7
7
|
Types,
|
|
8
|
-
type Mesh3DProps,
|
|
9
8
|
type NodeOf,
|
|
10
9
|
type Values,
|
|
11
10
|
type Vector3,
|
|
@@ -26,13 +25,6 @@ import {
|
|
|
26
25
|
import { meshEntries } from "./entries";
|
|
27
26
|
import { aim, graphEntry, graphOf } from "./space";
|
|
28
27
|
|
|
29
|
-
export interface VectorArrow3dProps extends Mesh3DProps {
|
|
30
|
-
tail?: Vector3Input;
|
|
31
|
-
head?: Vector3Input;
|
|
32
|
-
thickness?: number;
|
|
33
|
-
tip?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
28
|
function point(initial: Vector3) {
|
|
37
29
|
return Types.custom<Vector3Input, Vector3>(initial, { resolve: resolveVector3, lerp: lerpVector3, kind: "vector3" });
|
|
38
30
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{H as Rt,J as Xt,K as Yt,M as Rn,a as A,b as ft,c as lt,f as Ft,h as Ct,l as L,m as _,n as pt,o as I,p as bt}from"./chunk-WMVW6ZIV.js";var $r=["fill","fillTo"],Vr=["stroke","strokeTo"],Hr=["start","end","progressTo","flash"];import{Graphics2D as er,insetsOps as or,Paint as Ee,provides as Se}from"@motionscript/sdk";import{createContext as Gn,Types as Ht}from"@motionscript/sdk";function mt(t,n="linear"){let[r,e]=t??[0,1];return(!Number.isFinite(r)||!Number.isFinite(e))&&([r,e]=[0,1]),r>e&&([r,e]=[e,r]),n==="log"&&(e>0||(e=10),r>0||(r=e/1e3)),e>r?[r,e]:[r,r+1]}function Dt(t,n,r,e="linear"){let[o,i]=t;if(e==="log"){let a=Math.log10(o),f=(r-n)/(Math.log10(i)-a);return{to:u=>n+(Math.log10(u)-a)*f,from:u=>10**(a+(u-n)/f)}}let s=(r-n)/(i-o);return{to:a=>n+(a-o)*s,from:a=>o+(a-n)/s}}function vt({xRange:t,yRange:n,area:r,xScaling:e="linear",yScaling:o="linear"}){let i=Dt(t,r.minX,r.maxX,e),s=Dt(n,r.minY,r.maxY,o);return{toPoint:(a,f,u={x:0,y:0})=>(u.x=i.to(a),u.y=s.to(f),u),toCoords:(a,f,u={x:0,y:0})=>(u.x=i.from(a),u.y=s.from(f),u),area:r,xRange:t,yRange:n,revision:[t,n,r.minX,r.minY,r.maxX,r.maxY,e,o].join("|")}}var Gr={minX:-1/0,minY:-1/0,maxX:1/0,maxY:1/0},z={toPoint:(t,n,r={x:0,y:0})=>(r.x=t,r.y=n,r),toCoords:(t,n,r={x:0,y:0})=>(r.x=t,r.y=n,r),area:Gr,xRange:[-1/0,1/0],yRange:[-1/0,1/0],revision:"pixels"},vn=[1,0,0,1];function Wr(t,n=vn){let r=Array.isArray(t)?t.flat():[];return r.length!==4||r.some(e=>typeof e!="number"||!Number.isFinite(e))?n:[r[0],r[1],r[2],r[3]]}function Qr(t,n,r){return[0,1,2,3].map(e=>t[e]+(n[e]-t[e])*r)}function Kr([t,n,r,e]){return t===1&&n===0&&r===0&&e===1}var Jr=4;function Xn([t,n]){let r=(t+n)/2,e=(n-t)/2*Jr;return[r-e,r+e]}function Zr(t,n){let[r,e,o,i]=n,s=r*i-e*o,a=Math.abs(s)<1e-9,f=(d,y,h)=>(a?(h.x=d,h.y=y):(h.x=(i*d-e*y)/s,h.y=(r*y-o*d)/s),h),u=Xn(t.xRange),c=Xn(t.yRange),l=u,p=c;if(!a){let d={x:0,y:0},y=1/0,h=1/0,E=-1/0,x=-1/0;for(let g of t.xRange)for(let m of t.yRange)f(g,m,d),y=Math.min(y,d.x),E=Math.max(E,d.x),h=Math.min(h,d.y),x=Math.max(x,d.y);l=[Math.max(y,u[0]),Math.min(E,u[1])],p=[Math.max(h,c[0]),Math.min(x,c[1])]}return{toPoint:(d,y,h={x:0,y:0})=>t.toPoint(r*d+e*y,o*d+i*y,h),toCoords:(d,y,h={x:0,y:0})=>(t.toCoords(d,y,h),f(h.x,h.y,h)),area:t.area,xRange:l,yRange:p,revision:`${t.revision}|m${n.join(",")}`,spills:!0}}function te(t,n,r){let e=(f,u,c)=>(n(f,u,c)||(c.x=f,c.y=u),c),o={x:0,y:0},i={x:0,y:0},s={x:0,y:0},a=1e-4;return{toPoint:(f,u,c={x:0,y:0})=>(e(f,u,c),t.toPoint(c.x,c.y,c)),toCoords:(f,u,c={x:0,y:0})=>{let l=t.toCoords(f,u),p=l.x,d=l.y;for(let y=0;y<8;y++){e(p,d,o);let h=o.x-l.x,E=o.y-l.y;if(Math.abs(h)+Math.abs(E)<1e-9)break;e(p+a,d,i),e(p,d+a,s);let x=(i.x-o.x)/a,g=(i.y-o.y)/a,m=(s.x-o.x)/a,M=(s.y-o.y)/a,S=x*M-m*g;if(!(Math.abs(S)>1e-12))break;p-=(M*h-m*E)/S,d-=(x*E-g*h)/S}return c.x=Number.isFinite(p)?p:l.x,c.y=Number.isFinite(d)?d:l.y,c},area:t.area,xRange:Yn(t.xRange),yRange:Yn(t.yRange),revision:`${t.revision}|w${r}`,curved:!0,spills:!0}}var ne=.3;function Yn([t,n]){let r=(n-t)*ne;return Number.isFinite(r)?[t-r,n+r]:[t,n]}var Dn=48;function xt(t,n,r,e,o){if(!t.curved)return[t.toPoint(n,r),t.toPoint(e,o)];let i=[];for(let s=0;s<=Dn;s++){let a=s/Dn;i.push(t.toPoint(n+(e-n)*a,r+(o-r)*a))}return i}import{expressionOps as oe}from"@motionscript/sdk";import{expressionOps as re}from"@motionscript/sdk";var qt={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,sqrt:Math.sqrt,cbrt:Math.cbrt,abs:Math.abs,exp:Math.exp,log:Math.log,ln:Math.log,log2:Math.log2,log10:Math.log10,floor:Math.floor,ceil:Math.ceil,round:Math.round,sign:Math.sign,trunc:Math.trunc},zt={atan2:{fn:Math.atan2,arity:[2,2]},pow:{fn:Math.pow,arity:[2,2]},mod:{fn:(t,n)=>t%n,arity:[2,2]},hypot:{fn:Math.hypot,arity:[1,1/0]},min:{fn:Math.min,arity:[1,1/0]},max:{fn:Math.max,arity:[1,1/0]}},zn={pi:Math.PI,PI:Math.PI,e:Math.E,E:Math.E,tau:Math.PI*2,phi:(1+Math.sqrt(5))/2},W={functions:{...Object.fromEntries(Object.keys(qt).map(t=>[t,{arity:[1,1]}])),...Object.fromEntries(Object.entries(zt).map(([t,{arity:n}])=>[t,{arity:n}]))},constants:zn,refs:"bare",unknownName:t=>`Unknown name '${t}'`};function ee(t){return{variables:t,functions:[...Object.keys(qt),...Object.keys(zt)].sort(),constants:["pi","e","tau","phi"]}}function Un(t,n,r=[]){for(let e of[...n,...r])if(Object.hasOwn(zn,e))throw new Error(`'${e}' is a constant, so it cannot be a variable`);return G(re.parse(t,W).root,n,r)}function G(t,n,r){switch(t.kind){case"const":{let{value:e}=t;return()=>e}case"ref":{let{name:e}=t,o=n.indexOf(e);if(o===0)return i=>i;if(o===1)return(i,s)=>s;if(r.includes(e))return(i,s,a)=>a?.[e]??NaN;throw new Error(W.unknownName(e))}case"unary":{let e=G(t.operand,n,r);return(o,i,s)=>-e(o,i,s)}case"binary":{let e=G(t.left,n,r),o=G(t.right,n,r);switch(t.op){case"+":return(i,s,a)=>e(i,s,a)+o(i,s,a);case"-":return(i,s,a)=>e(i,s,a)-o(i,s,a);case"*":return(i,s,a)=>e(i,s,a)*o(i,s,a);case"/":return(i,s,a)=>e(i,s,a)/o(i,s,a);case"%":return(i,s,a)=>e(i,s,a)%o(i,s,a);case"^":return(i,s,a)=>Math.pow(e(i,s,a),o(i,s,a))}break}case"call":{let e=t.args.map(s=>G(s,n,r)),o=qt[t.name];if(o){let[s]=e;return(a,f,u)=>o(s(a,f,u))}let{fn:i}=zt[t.name];if(e.length===2){let[s,a]=e;return(f,u,c)=>i(s(f,u,c),a(f,u,c))}return(s,a,f)=>i(...e.map(u=>u(s,a,f)))}}throw new Error("Unsupported expression")}var qn=A(256);function X(t,n,r=[]){let e=`${n.join(",")}|${r.join(",")}|${t}`,o=qn.get(e);if(o!==void 0)return o;let i;try{i=Un(t,n,r)}catch(s){i=s instanceof Error?s:new Error(String(s))}return qn.set(e,i),i}var ht={function:["x"],polar:["theta"],parametric:["t"],implicit:["x","y"]},Bn=A(256);function U(t,n=[]){let r=`${n.join(",")}|${t}`,e=Bn.get(r);if(e!==void 0)return e;let o;try{o=se(t.trim(),n)}catch(i){o=i instanceof Error?i:new Error(String(i))}return Bn.set(r,o),o}function Ut(t){if(t.trim()==="")return null;let n=U(t,k(t));return n instanceof Error?n.message:null}var ie=new Set(["r",...Object.values(ht).flat()]),jn=A(256);function B(t){let n=jn.get(t);if(n!==void 0)return n;let r=new Set,e=t.trim();try{for(let i of Y(e)??K(e,"="))Q(oe.parse(i.trim(),W).root,r)}catch{r.clear()}let o=[...r];return jn.set(t,o),o}function k(t){return B(t).filter(n=>!ie.has(n))}function Q(t,n){switch(t.kind){case"ref":n.add(t.name);return;case"unary":Q(t.operand,n);return;case"binary":Q(t.left,n),Q(t.right,n);return;case"call":for(let r of t.args)Q(r,n);return;default:}}function se(t,n){if(t==="")throw new Error("Empty equation");let r=(u,c)=>{let l=X(u.trim(),c,n);if(l instanceof Error)throw l;return l},e=Y(t);if(e?.length===2)return{kind:"parametric",x:r(e[0],["t"]),y:r(e[1],["t"])};let o=K(t,"=");if(o.length>2)throw new Error("An equation has one '='");if(o.length===1)return{kind:"function",of:"x",f:r(t,["x"])};let[i,s]=o,a=i.trim(),f=()=>{let u=r(i,["x","y"]),c=r(s,["x","y"]);return{kind:"implicit",f:(l,p,d)=>u(l,p,d)-c(l,p,d)}};if(a==="r")return{kind:"polar",f:r(s,["theta"])};if(a==="y"||a==="x"){let u=a==="y"?"x":"y";try{return{kind:"function",of:u,f:r(s,[u])}}catch(c){try{return f()}catch{throw c}}}return f()}function Y(t){if(!t.startsWith("(")||!t.endsWith(")"))return null;let n=0;for(let e=0;e<t.length-1;e++)if(t[e]==="(")n++;else if(t[e]===")"&&--n===0)return null;let r=K(t.slice(1,-1),",");return r.length>=2?r:null}function K(t,n){let r=[],e=0,o=0;for(let i=0;i<t.length;i++){let s=t[i];s==="("?e++:s===")"?e--:s===n&&e===0&&(r.push(t.slice(o,i)),o=i+1)}return r.push(t.slice(o)),r}function J(t){return typeof t=="string"?{source:t}:t??{source:""}}function Z(t,n,r){return r<=0||t.source===n.source?r<=0?t:n:r>=1?n:{source:n.source,blend:{from:t.source,t:r}}}function tt(t,n,r){return!t||!n?r<1?t:n:[t[0]+(n[0]-t[0])*r,t[1]+(n[1]-t[1])*r]}var Bt=1;function nt(t,n,r){let e={...t};for(let[o,i]of Object.entries(n)){let s=t[o]??Bt;e[o]=s+(i-s)*r}return e}function F(t,n){let r=null;for(let e of t)typeof n[e]!="number"&&((r??={...n})[e]=Bt);return r??n}function ae(t){let n=2166136261;for(let r=0;r<t.length;r++)n^=t.charCodeAt(r),n=Math.imul(n,16777619);return n>>>0}var dt=["functionPlot","tracedPath"];function ce(t,n){let{source:r,blend:e}=t.expression,o=t.graph?t:ue,i=$n(r,t.params,n-o.x)+o.y;if(!e)return i;let s=$n(e.from,t.params,n-o.x)+o.y;return s+(i-s)*e.t}function jt(t){return typeof t=="object"&&t!==null&&dt.includes(t.key??"")}var ue={x:0,y:0};function $n(t,n,r){let e=U(t,k(t));return e instanceof Error||e.kind!=="function"||e.of!=="x"?NaN:e.f(r,0,F(k(t),n))}var D=Gn(null,"mathSystem"),yt=Gn(null,"mathPlot"),Gt=Ht.custom(null,{private:!0,inherit:t=>t(D)}),Wt=Ht.custom(null,{private:!0,inherit:t=>t(yt)??t(D)}),fe=Ht.custom("",{kind:"nodeRef",nodeTypes:["functionPlot"],animatable:!1}),Wn=new Map,$t=class{map=z;curves=Wn;enclosing=null},Vt=class{parent;enclosing;constructor(n,r){this.parent=n,this.enclosing=r}get map(){return this.parent?.map??z}get curves(){return this.parent?.curves??Wn}},Vn=new WeakMap,Hn=new WeakMap;function gt(t){let n=Vn.get(t);return n||Vn.set(t,n=new $t),n}function Qt(t,n,r){t.map=n;let e=new Map;Qn(r,e),t.curves=e}function Mt(t,n){let r=Hn.get(t);return(!r||r.parent!==n)&&Hn.set(t,r=new Vt(n,t)),r}function le(t,n,r=!0){if(!t)return jt(n)?n.state:null;let e=Et(n);return(e===""?void 0:t.curves.get(e))??(r?t.enclosing:null)}function Et(t){return typeof t=="string"?t:typeof t=="object"&&t!==null&&typeof t.id=="string"?t.id:""}function Qn(t,n){for(let r of t)r.id!==""&&dt.includes(r.key)&&n.set(r.id,r.state),Qn(r.children,n)}function rt(t,n=!1){let r=[];for(let e of t)if(!(e.length<2)){r.push({type:"M",x:e[0].x,y:e[0].y});for(let o=1;o<e.length;o++)r.push({type:"L",x:e[o].x,y:e[o].y});n&&r.push({type:"Z"})}return r}function C(t){let n=1/0,r=1/0,e=-1/0,o=-1/0;for(let i of t)if(!(i.length<2))for(let s of i)s.x<n&&(n=s.x),s.x>e&&(e=s.x),s.y<r&&(r=s.y),s.y>o&&(o=s.y);return n<=e?{minX:n,minY:r,maxX:e,maxY:o}:null}function pe(t,n){return{minX:t.minX-n,minY:t.minY-n,maxX:t.maxX+n,maxY:t.maxY+n}}function v(t,n,r){return t<n?n:t>r?r:t}function me(t){let n={};if(!t)return n;for(let r of Object.keys(t))t[r]!==void 0&&(n[r]=t[r]);return n}import{Graphics2D as xe}from"@motionscript/sdk";var Kn={x:0,y:0},Jn=[];function Kt(t,n){return Jn.push({is:r=>t.is(r),trace:n}),t}function Jt(t,n,r){let e=Jn.find(i=>i.is(t));if(!e)return;let o=t.state;return e.trace(o,{map:n,shift:{x:o.x,y:o.y},plane:r})}function j(t){let n=t.graph;return n?{map:n.map,shift:{x:t.x,y:t.y},plane:n}:{map:z,shift:Kn,plane:null}}function Zt(t){let n=C(t);return n?{width:n.maxX-n.minX,height:n.maxY-n.minY}:{width:0,height:0}}function $(t){let n=C(t);return n?{x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2}:Kn}function he(t,n,r){let e=t.map.toPoint(r.x+t.shift.x,r.y+t.shift.y),o=$(n);return{x:e.x-o.x,y:e.y-o.y}}function de(t,n,r){let e=$(n),o=t.map.toCoords(r.x+e.x,r.y+e.y);return{x:o.x-t.shift.x,y:o.y-t.shift.y}}var tn=[];function Zn(t,n,r=!1){let e=C(t),o=rt(t,r);if(!e||o.length===0)return null;let i=[e.minX,e.minY,e.maxX,e.maxY];return()=>new xe().path({data:o,centerBounds:i,start:n.start??0,end:n.end??1})}function et(t,n,r,e={}){let o=Zn(r,n,e.closed),i=n.fill??tn;bt(t,()=>{o&&e.fills!==!1&&t.draw(o().shadow(n.shadow).fill(i));let s=e.ink?C(r):null;s&&e.ink?e.ink(t,s):o&&tr(t,o,n)})}function tr(t,n,r){let e=r.stroke??tn;e.length!==0&&t.draw(nr(r)?n().shadow(r.shadow).stroke(e):n().stroke(e))}function nr(t){return t.shadow.length===0?!1:!(t.fill??tn).some(n=>(n.opacity??1)>0)}var rr=[];function ye(t,n){return rr.push({is:r=>t.is(r),anchor:n}),t}function ot(t,n,r,e,o){return t.map(i=>{let s=Jt(i,n,o);if(s){let c=C(s),l=c?(c.minX+c.maxX)/2:r.x,p=c?(c.minY+c.maxY)/2:r.y;return{x:l-r.x,y:p-r.y,width:c?c.maxX-c.minX:0,height:c?c.maxY-c.minY:0,plane:Me(n,l,p)}}let a=i.measure({width:e.width,height:e.height}),f=rr.find(c=>c.is(i)),u=f?f.anchor(i.state,o):null;return{x:-r.x,y:-r.y,width:a.width,height:a.height,plane:ge(n,u)}})}function it(t,n){return{toOffset:(r,e)=>{let o=t.toPoint(r,e);return{x:o.x-n.x,y:o.y-n.y}},toCoords:(r,e)=>t.toCoords(r+n.x,e+n.y)}}function ge(t,n){let r={x:0,y:0};return{toOffset:(e,o)=>{let i=n?.(e,o);return i?t.toPoint(i.x,i.y,r):t.toPoint(e,o,r)},toCoords:(e,o)=>t.toCoords(e,o)}}function Me(t,n,r){let e={x:0,y:0};return{toOffset:()=>e,toCoords:(o,i)=>t.toCoords(n+o,r+i)}}var ir={x:0,y:0};function sr(t,n){let r=or.insetBounds(t.width,t.height,n);return{minX:r.x-r.width/2,maxX:r.x+r.width/2,minY:-r.y-r.height/2,maxY:-r.y+r.height/2}}function st(t,n,r){return r(sr(t,n.padding),n)}function nn(t){let{left:n,right:r,top:e,bottom:o}=t.padding;return{width:n+r,height:e+o}}function rn(t){return[Se(D,gt(t))]}function en(t,n,r,e){let o=st(t,n,e),i=gt(n);Qt(i,o,r);let s=or.insetBounds(t.width,t.height,n.padding);return ot(r,o,ir,s,i)}function on(t,n,r){return it(st(t,n,r),ir)}function sn(t,n,r,e){let{width:o,height:i}=t.size,{minX:s,minY:a,maxX:f,maxY:u}=r.area,c=new er().rect({x:(s+f)/2,y:(a+u)/2,width:f-s,height:u-a});t.inFront(()=>{t.draw(new er().rect({x:0,y:0,width:o,height:i}).shadow(n.shadow).fill(n.fill));let l=e(r);r.spills?t.clip(c,()=>t.draw(l)):t.draw(l)}),Ee.draw(t,n,null,{clipShape:c})}import{component2d as Fe,Graphics2D as fr,Types as O}from"@motionscript/sdk";import{niceStep as we}from"@motionscript/sdk/component";var cr=200,Ae=64;function St(t,n,r,e="linear"){let[o,i]=t;if(e==="log")return Te(o,i);let s=i-o;if(!(s>0))return{values:[],step:1};let a=n>0?n:we(Ae/Math.max(1,r)*s);return{values:Oe(o,i,a),step:a}}function Te(t,n){let r=[];for(let e=Math.ceil(Math.log10(t)-1e-9);e<=Math.floor(Math.log10(n)+1e-9)&&r.length<cr;e++)r.push(10**e);return{values:r,step:0}}function Oe(t,n,r){let e=Math.ceil(t/r-1e-9),i=Math.floor(n/r+1e-9)-e+1;if(!Number.isFinite(i)||i<=0||i>cr)return[];let s=new Array(i);for(let a=0;a<i;a++)s[a]=(e+a)*r;return s}function an(t){return Math.floor(Math.log10(t)+1e-12)}function wt(t,n){if(t===0)return"0";if(!Number.isFinite(t))return"";if(!(n>0)){let s=an(Math.abs(t));return s>=6||s<=-5?ar(t.toExponential(0)):String(Number(t.toPrecision(12)))}let r=an(Math.abs(t)),e=Math.max(1,r-an(n)+1);if((r>=6||r<=-5)&&e<=6)return ar(t.toExponential(e-1));let o=Pe(n),i=t.toFixed(o);return o>0?i.replace(/\.?0+$/,""):i}function Pe(t){for(let n=0;n<12;n++){let r=t*10**n;if(Math.abs(r-Math.round(r))<1e-9*Math.max(1,r))return n}return 12}function ar(t){let[n,r]=t.split("e");return`${n.replace(/\.?0+$/,"")}e${Number(r)}`}import{Fills as ke,Graphics2D as ur,toPathString as Ie}from"@motionscript/sdk";var At="#9ca3af",cn="#58a6ff";function un(t){return t.map(n=>({...n,startCap:void 0,endCap:void 0}))}var Ne=8,fn=/^\$([\s\S]+)\$$/;function Le(t,n){n.some(r=>fn.test(r.trim()))&&t.loader(ft,lt,{gate:"layout"})}function ln(t,n){n.some(r=>fn.test(r.trim()))&&t.task(ft,lt,{before:"layout"})}function pn(t,n){let r=[],e=ke.color(n.color),o=new ur,i=n.fontSize*Ne,s=!1;for(let a of t){let f=fn.exec(a.text.trim()),u=f?_e(f[1],a,n.fontSize):null;if(u){for(let p of u)r.push(p.fill(e));continue}let{at:c,align:l}=a;s=!0,o.text({text:a.text,fontSize:n.fontSize,...n.fontFamily===""?{}:{fontFamily:n.fontFamily},wrap:!1,width:i,textAlign:l,x:l==="center"?c.x:l==="right"?c.x-i/2:c.x+i/2,y:c.y})}return s&&r.push(o.fill(e)),r}function _e(t,{at:n,align:r},e){let o;try{o=Ct(t,e)}catch(l){return l instanceof Ft?[]:null}let[i,s,a,f]=o.bounds,u=n.x+(r==="left"?o.width/2:r==="right"?-o.width/2:0),c=[i-u,s+n.y,a-u,f+n.y];return o.tokens.map(l=>new ur().path({data:Ie(l.path),centerBounds:c}))}function mn(t,n,r){return t>=n-1e-9&&t<=r+1e-9}function xn(t,n,r){let e=r.x-n.x,o=r.y-n.y,i=e*e+o*o;return i===0?0:((t.x-n.x)*e+(t.y-n.y)*o)/i}function hn(t,n,r){return[t[0]+(n[0]-t[0])*r,t[1]+(n[1]-t[1])*r]}function dn(t,n){let[r,e]=Array.isArray(t)?t:n??[0,1];return[Number(r),Number(e)]}var lr=t=>O.custom(t,{resolve:dn,lerp:hn}),pr={...L,xRange:lr([-5,5]),yRange:lr([-3,3]),xStep:O.number(0,{min:0}),yStep:O.number(0,{min:0}),xScaling:pt(["linear","log"],"linear",{animatable:!1}),yScaling:pt(["linear","log"],"linear",{animatable:!1}),squareUnits:O.boolean(!1,{animatable:!1}),ticks:O.boolean(!0,{animatable:!1}),tickSize:O.number(10,{min:0,unit:"px"}),labels:O.boolean(!0,{animatable:!1}),labelSize:O.number(18,{min:1,unit:"px"}),labelColor:O.color(At),fontFamily:O.text("",{animatable:!1}),xLabel:O.text("",{animatable:!1}),yLabel:O.text("",{animatable:!1})},mr={..._,rangeTo:{args:["xRange","yRange"]}};function xr(t,n){n.fontFamily!==""&&t.font(n.fontFamily),ln(t,[n.xLabel,n.yLabel])}function Tt(t,n){let r=mt(n.xRange,n.xScaling),e=mt(n.yRange,n.yScaling),o=t.maxX-t.minX;if(n.squareUnits&&n.xScaling==="linear"&&n.yScaling==="linear"&&o>0){let i=(r[1]-r[0])*(t.maxY-t.minY)/o,s=(e[0]+e[1])/2;i>0&&(e=[s-i/2,s+i/2])}return vt({xRange:r,yRange:e,area:t,xScaling:n.xScaling,yScaling:n.yScaling})}function hr(t,n){let[r,e]=t.xRange,[o,i]=t.yRange,s=n.xScaling==="log"?r:v(0,r,e),a=n.yScaling==="log"?o:v(0,o,i),f=t.toPoint(r,a),u=t.toPoint(e,a),c=t.toPoint(s,o),l=t.toPoint(s,i);return[{from:f,to:u,line:xt(t,r,a,e,a),marks:St(t.xRange,n.xStep,Math.hypot(u.x-f.x,u.y-f.y),n.xScaling),crossing:s,at:p=>t.toPoint(p,a)},{from:c,to:l,line:xt(t,s,o,s,i),marks:St(t.yRange,n.yStep,Math.hypot(l.x-c.x,l.y-c.y),n.yScaling),crossing:a,at:p=>t.toPoint(s,p)}]}function dr(t,n,r=()=>[]){let e=n.stroke,{start:o,end:i}=n,[s,a]=hr(t,n),f=[...r(s,a)];if(e.length===0&&!n.labels)return f;e.length>0&&f.push(new fr().line({points:s.line,radius:0,start:o,end:i}).line({points:a.line,radius:0,start:o,end:i}).stroke(e));let u=n.tickSize/2,c=u+n.labelSize*.35,l=new fr,p=[],d=!1,y=(h,E)=>{for(let x of h.marks.values){if(Math.abs(x-h.crossing)<1e-9*Math.max(1,Math.abs(x)))continue;let g=h.at(x);mn(xn(g,h.from,h.to),o,i)&&(n.ticks&&u>0&&(l.line({points:E?[{x:g.x,y:g.y-u},{x:g.x,y:g.y+u}]:[{x:g.x-u,y:g.y},{x:g.x+u,y:g.y}],radius:0}),d=!0),n.labels&&p.push(E?{text:wt(x,h.marks.step),at:{x:g.x,y:g.y-c-n.labelSize/2},align:"center"}:{text:wt(x,h.marks.step),at:{x:g.x-c,y:g.y},align:"right"}))}};return y(s,!0),y(a,!1),d&&e.length>0&&f.push(l.stroke(un(e))),n.xLabel!==""&&i>=1&&p.push({text:n.xLabel,at:{x:s.to.x,y:s.to.y+c+n.labelSize/2},align:"right"}),n.yLabel!==""&&i>=1&&p.push({text:n.yLabel,at:{x:a.to.x+c,y:a.to.y-n.labelSize/2},align:"left"}),f.push(...pn(p,{fontSize:n.labelSize,fontFamily:n.fontFamily,color:n.labelColor})),f}var Ce=Fe({key:"axes2d",state:pr,defaults:{stroke:{weight:2,fill:At,align:"center",endCap:"triangle",capScale:5}},load:(t,n)=>xr(t,n),commands:mr,provide:t=>rn(t),measure:(t,n)=>nn(n),layout:(t,n,r)=>en(t,n,r,Tt),plane:(t,n)=>on(t,n,Tt),render:(t,n)=>sn(t,n,st(t.size,n,Tt),r=>dr(r,n))});var yr=[],Ot=0;function be(){let t=yr[Ot];return t===void 0&&(t=yn(),yr.push(t)),Ot++,t}function yn(){return{t:0,px:0,py:0,rx:0,ry:0,ok:!1}}var at={x:0,y:0};function Mn(t,n,r,e,{seeds:o=256,minStep:i=0}={}){if(!(r>n)||!Number.isFinite(n)||!Number.isFinite(r))return[];let s=new gn(e),a=0,f=(x,g)=>{let m=t(g,at);a++;let M=m&&Number.isFinite(at.x)&&Number.isFinite(at.y);return x.t=g,x.rx=M?at.x:0,x.ry=M?at.y:0,x.px=gr(x.rx),x.py=gr(x.ry),x.ok=M,x},u=x=>f(be(),x),c=(x,g)=>{let m=x,M=g.t;for(let S=0;S<60&&!(a>=4e4||Ye(m,e));S++){let w=(m.t+M)/2;if(w===m.t||w===M)break;let T=u(w);if(!T.ok){M=w;continue}let N=Math.abs(T.px-m.px)<.25&&Math.abs(T.py-m.py)<.25;if(m=T,N)break}return m},l=(x,g,m,M)=>{if(x.ok&&m.ok){M&&Xe(x,g,m,e)?s.break():s.draw(x,m);return}if(x.ok){let S=c(x,m);S.t!==x.t&&s.draw(x,S),s.break();return}if(s.break(),m.ok){let S=c(m,x);S.t!==m.t?s.draw(S,m):s.start(m)}},p=(x,g,m)=>{if(a>=4e4||s.points>=24e3){l(x,null,g,!1);return}let M=u((x.t+g.t)/2),S=m>=12||g.t-x.t<=i;if(S||Re(x,M,g)){l(x,M,g,S);return}p(x,M,m+1),p(M,g,m+1)},d=Math.max(1,Math.round(o)),y=(r-n)/d,h=[yn(),yn()],E=f(h[0],n);for(let x=1;x<=d;x++){let g=f(h[x&1],x===d?r:n+x*y);Ot=0,p(E,g,0),E=g}return Ot=0,s.finish()}function Re(t,n,r){if(t.ok!==n.ok||n.ok!==r.ok)return!1;if(!t.ok)return!0;let e=r.px-t.px,o=r.py-t.py,i=Math.hypot(e,o)||1;if(Math.abs((n.px-t.px)*o-(n.py-t.py)*e)/i>.25)return!1;let s=Math.abs(Math.atan2(n.py-t.py,n.px-t.px)-Math.atan2(r.py-n.py,r.px-n.px));return s>Math.PI&&(s=2*Math.PI-s),s<.05}function Xe(t,n,r,e){return!(t.py>e.maxY&&r.py<e.minY||t.py<e.minY&&r.py>e.maxY||t.px>e.maxX&&r.px<e.minX||t.px<e.minX&&r.px>e.maxX)||n===null?!1:n.ok?n.ry<Math.min(t.ry,r.ry)||n.ry>Math.max(t.ry,r.ry)||n.rx<Math.min(t.rx,r.rx)||n.rx>Math.max(t.rx,r.rx):!0}function Ye(t,n){return t.py>n.maxY||t.py<n.minY||t.px>n.maxX||t.px<n.minX}function gr(t){return t>16e3?16e3:t<-16e3?-16e3:t}var gn=class{clip;points=0;runs=[];open=[];cursor=null;constructor(n){this.clip=n}draw(n,r){let e=qe(n.px,n.py,r.px,r.py,this.clip);if(!e){this.break();return}let[o,i]=e;this.cursor&&De(this.cursor,o)?this.push(i):(this.break(),this.push(o),this.push(i)),this.cursor=i}start(n){this.break(),ve(n.px,n.py,this.clip)&&(this.cursor={x:n.px,y:n.py},this.push(this.cursor))}break(){this.open.length>=2&&this.runs.push(this.open),this.open=[],this.cursor=null}finish(){return this.break(),this.runs}push(n){this.open.push(n),this.points++}};function De(t,n){return Math.abs(t.x-n.x)<.1&&Math.abs(t.y-n.y)<.1}function ve(t,n,r){return t>=r.minX&&t<=r.maxX&&n>=r.minY&&n<=r.maxY}function qe(t,n,r,e,o){let i=r-t,s=e-n,a=0,f=1,u=[[-i,t-o.minX],[i,o.maxX-t],[-s,n-o.minY],[s,o.maxY-n]];for(let[c,l]of u){if(c===0){if(l<0)return null;continue}let p=l/c;if(c<0){if(p>f)return null;p>a&&(a=p)}else{if(p<a)return null;p<f&&(f=p)}}return[{x:t+a*i,y:n+a*s},{x:t+f*i,y:n+f*s}]}import{commandsFor as ze,pathOps as Ue,Types as b}from"@motionscript/sdk";function wr(t){return typeof t.partBounds=="function"||Rt(t)}function Be(t,n,r){return typeof t.partBounds=="function"?t.partBounds(n,r):Xt(t,n,r)??null}var Mr=({on:t,part:n,occurrence:r})=>({on:t,part:n,occurrence:r});function Ar(t,n,r){return r<=0||!n?r<1?t:n:{...Mr(n),from:t?Mr(t):null,t:r}}var je=b.custom("",{kind:"nodeRef",animatable:!1}),Er=b.custom("",{kind:"nodeRef",private:!0}),Tr={...I(L,"fill"),on:je,part:b.text("",{animatable:!1}),occurrence:b.number(1,{min:1,step:1,animatable:!1}),retarget:b.custom(null,{lerp:Ar}),retargetOn:Er,retargetFrom:Er},$e={...I(_,"fillTo"),...ze(Tr,{retargetTo:{args:{on:b.custom(void 0,{kind:"nodeRef"}),part:b.custom(void 0,{kind:"text"}),occurrence:b.number(1,{min:1,step:1})},run:(t,n)=>{let r=t.args,e=n.retarget??Ve(n),o={on:r.on??e.on,part:r.part??(r.on?"":e.part),occurrence:r.occurrence??1,t:1},i=n.retarget;return t.animate(s=>{let a=Ar(i,o,s);return{retarget:a,retargetOn:a?.on??"",retargetFrom:a?.from?.on??""}})}}})};function Ve(t){return{on:Et(t.on),part:t.part,occurrence:t.occurrence}}var Sr=new WeakMap;function He(t,n){if(!t)return Sr.get(n)??null;let r=t.ancestor(Yt)??t.ancestor(Rn),e=r&&wr(r.state)?r:null;return Sr.set(n,e),e}function Or(t,n){return t.on??n}function Ge(t,n){let r=t.retarget,e=()=>En(Or(t,n),t);if(!r)return e();let o=En(r.on===""?n:t.retargetOn,r),i=r.from?En(r.from.on===""?n:t.retargetFrom,r.from):e();return!i||!o||r.t>=1?o??i:We(i,o,r.t)}function En(t,n){if(!t)return null;let r=n.part&&wr(t.state)?Be(t.state,n.part,n.occurrence||1):{x:0,y:0,width:t.size.width,height:t.size.height};if(!r)return null;let e=t.frame,o=e.rotation*Math.PI/180,i=Math.cos(o),s=Math.sin(o),a=(c,l)=>({x:e.x+(i*c+s*l)*e.scale,y:e.y+(-s*c+i*l)*e.scale}),f=r.width/2,u=r.height/2;return[a(r.x-f,r.y+u),a(r.x+f,r.y+u),a(r.x+f,r.y-u),a(r.x-f,r.y-u)]}function We(t,n,r){return t.map((e,o)=>({x:e.x+(n[o].x-e.x)*r,y:e.y+(n[o].y-e.y)*r}))}function Qe(t){let n=Ue.bounds(t);return n?{x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2,width:n.maxX-n.minX,height:n.maxY-n.minY}:{x:0,y:0,width:0,height:0}}var Ke=[-1,-1,1,1],P=(t,n,r=1)=>({x:t.x+n.x*r,y:t.y+n.y*r}),Sn=(t,n,r=.5)=>({x:t.x+(n.x-t.x)*r,y:t.y+(n.y-t.y)*r});function ct(t,n){let r=n.x-t.x,e=n.y-t.y,o=Math.hypot(r,e);return{unit:o===0?{x:1,y:0}:{x:r/o,y:e/o},length:o}}function Je(t,n){let[r,e,o,i]=t,s=ct(r,e).unit,a=ct(i,r).unit;return[P(P(r,s,-n),a,n),P(P(e,s,n),a,n),P(P(o,s,n),a,-n),P(P(i,s,-n),a,-n)]}var ut=["x","y"],Ze=new Set(ut),Pr=A(128);function V(t){return B(t).filter(n=>!Ze.has(n))}function Pt(t,n=[]){let r=`${n.join(",")}|${t}`,e=Pr.get(r);if(e!==void 0)return e;let o;try{let i=t.trim();if(i==="")throw new Error("Empty equation");let s=Y(i);if(s?.length!==2)throw new Error("A field has two parts: (x, y)");let[a,f]=s.map(u=>{let c=X(u.trim(),ut,n);if(c instanceof Error)throw c;return c});o={x:a,y:f}}catch(i){o=i instanceof Error?i:new Error(String(i))}return Pr.set(r,o),o}function wn(t){if(t.trim()==="")return null;let n=Pt(t,V(t));return n instanceof Error?n.message:null}var q={height:["x","y"],surface:["u","v"],spaceCurve:["t"]},to=new Set(["x","y","z","u","v"]),no=new Set(["t"]),ro=A(128),eo=A(128);function An(t){return B(t).filter(n=>!to.has(n))}function Tn(t){return B(t).filter(n=>!no.has(n))}function kr(t,n=[]){return Fr(ro,t,n,r=>{let e=_r(n),o=Y(r);if(o){if(o.length!==3)throw new Error("A parametric surface has three parts: (x, y, z)");let[s,a,f]=o.map(u=>e(u,q.surface));return{kind:"parametric",x:s,y:a,z:f}}let i=K(r,"=");if(i.length>2)throw new Error("An equation has one '='");if(i.length===2&&i[0].trim()!=="z")throw new Error("A surface is written z = \u2026, or as three parts (x, y, z)");return{kind:"height",f:e(i[i.length-1],q.height)}})}function Ir(t,n=[]){return Fr(eo,t,n,r=>{let e=_r(n),o=Y(r);if(o?.length!==3)throw new Error("A space curve has three parts: (x, y, z)");let[i,s,a]=o.map(f=>e(f,q.spaceCurve));return{x:i,y:s,z:a}})}function Nr(t){if(t.trim()==="")return null;let n=kr(t,An(t));return n instanceof Error?n.message:null}function Lr(t){if(t.trim()==="")return null;let n=Ir(t,Tn(t));return n instanceof Error?n.message:null}function _r(t){return(n,r)=>{let e=X(n.trim(),r,t);if(e instanceof Error)throw e;return e}}function Fr(t,n,r,e){let o=`${r.join(",")}|${n}`,i=t.get(o);if(i!==void 0)return i;let s;try{let a=n.trim();if(a==="")throw new Error("Empty equation");s=e(a)}catch(a){s=a instanceof Error?a:new Error(String(a))}return t.set(o,s),s}var oo={equation:{error:Ut,params:k,variables:[...new Set(Object.values(ht).flat())]},surfaceEquation:{error:Nr,params:An,variables:[...q.height,...q.surface]},spaceCurveEquation:{error:Lr,params:Tn,variables:q.spaceCurve},fieldEquation:{error:wn,params:V,variables:ut}};import{createContext as io,Types as so}from"@motionscript/sdk";function ao(t,n,r,e){let o=On(t,e.x),i=On(n,e.y),s=On(r,e.z),a=(t[0]+t[1])/2,f=(n[0]+n[1])/2,u=(r[0]+r[1])/2;return{xRange:t,yRange:n,zRange:r,revision:[t,n,r,e.x,e.y,e.z].join("|"),toLocal:(c,l,p)=>({x:(l-f)*i,y:(p-u)*s,z:(c-a)*o}),offset:(c,l,p)=>({x:l*i,y:p*s,z:c*o})}}function On([t,n],r){let e=n-t;return e>0?r/e:0}var Pn=io(null,"math:graph3d");function co(){return so.custom(null,{private:!0,inherit:t=>t(Pn)})}function uo(t){return t.graph?.space()??null}function fo(t){return t.useContext(Pn)?.space()??null}function lo(t){let n=Math.hypot(t.x,t.y,t.z);if(!(n>0))return{x:0,y:0,z:0,w:1};let r=t.x/n,e=t.y/n,o=t.z/n;if(e<-1+1e-9)return{x:1,y:0,z:0,w:0};let i=1+e,s=Math.hypot(o,r,i);return{x:o/s,y:0,z:-r/s,w:i/s}}import{Material as po,Types as Cr}from"@motionscript/sdk";var mo={geometry:Cr.custom(void 0),...po.state};function xo(t,n){return Cr.custom(null,{lerp:tt,kind:"range",defaultMin:t,defaultMax:n})}import{Fills as ho,Graphics2D as yo,Mat as go,Tex as Mo}from"@motionscript/sdk";var kt=64,kn=96,br=A(256);function Eo(t,n){let r=`${n.fontFamily}|${JSON.stringify(n.color)}|${t}`,e=br.get(r);if(e)return e;let o=Math.min(1024,Math.max(128,Math.ceil((t.length*kt*.62+kt)/32)*32)),i=new yo().text({text:t,fontSize:kt,...n.fontFamily===""?{}:{fontFamily:n.fontFamily},wrap:!1,width:o,textAlign:"center"}).fill(ho.color(n.color)),a={texture:{...Mo.surface(i,{width:o,height:kn}),static:!0,identity:`label3d:${r}`},width:o};return br.set(r,a),a}function So(t,n,r,e){if(n===""||!(e.size>0))return;let{texture:o,width:i}=Eo(n,e),s=e.size*kn/kt;t.sprite({material:go.sprite({map:o,transparent:!0,depthWrite:!1}),position:r,scale:[s*i/kn,s,1]})}import{component2d as wo,provides as Ao,Types as Nn}from"@motionscript/sdk";function In(t,[n,r],[e,o],i,s){if(!(r>n)||!(o>e)||i<1||s<1)return[];let a=(r-n)/i,f=(o-e)/s,u=i+1,c=new Float64Array(u*(s+1));for(let m=0;m<=s;m++)for(let M=0;M<=i;M++)c[m*u+M]=t(n+M*a,e+m*f);let l=new Map,p=u*(s+1),d=(m,M,S)=>{let w=c[M*u+m],T=S?c[(M+1)*u+m]:c[M*u+m+1];if(!Number.isFinite(w)||!Number.isFinite(T)||w<0==T<0)return null;let N=(S?p:0)+M*u+m;if(!l.has(N)){let R=w/(w-T);l.set(N,S?{x:n+m*a,y:e+(M+R)*f}:{x:n+(m+R)*a,y:e+M*f})}return N},y=new Map,h=(m,M)=>{m===null||M===null||((y.get(m)??y.set(m,[]).get(m)).push(M),(y.get(M)??y.set(M,[]).get(M)).push(m))};for(let m=0;m<s;m++)for(let M=0;M<i;M++){let S=d(M,m,!1),w=d(M,m+1,!1),T=d(M,m,!0),N=d(M+1,m,!0),R=[S,N,w,T].filter(_t=>_t!==null);if(R.length===2)h(R[0],R[1]);else if(R.length===4){let _t=t(n+(M+.5)*a,e+(m+.5)*f),jr=c[m*u+M];_t<0==jr<0?(h(S,N),h(w,T)):(h(S,T),h(w,N))}}let E=[],x=new Set,g=m=>{let M=[l.get(m)];x.add(m);let S=m;for(;;){let w=(y.get(S)??[]).find(T=>!x.has(T));if(w===void 0)break;x.add(w),M.push(l.get(w)),S=w}return M};for(let[m,M]of y)M.length===1&&!x.has(m)&&E.push(g(m));for(let m of y.keys()){if(x.has(m))continue;let M=g(m);M.push(M[0]),E.push(M)}return E.filter(m=>m.length>1)}var To=Math.PI*2,Yr={...I(L,"fill"),expression:Nn.custom("",{resolve:J,lerp:Z,kind:"equation"}),domain:Nn.custom(null,{lerp:tt,kind:"range",defaultMin:-5,defaultMax:5}),params:Nn.custom({},{lerp:nt}),graph:Gt},Dr={...I(_,"fillTo"),morphTo:{args:["expression"]},paramsTo:{args:["params"]},domainTo:{args:["domain"]}},vr={weight:3,fill:cn,align:"center",cap:"round",join:"round"},Oo=Kt(wo({key:"functionPlot",state:Yr,defaults:{stroke:vr,width:"hug",height:"hug"},commands:Dr,provide:(t,n)=>[Ao(yt,Mt(t,n(D)))],measure:(t,n)=>Zt(H(n,j(n),n.domain)),layout:(t,n,r)=>{let e=j(n);return ot(r,e.map,$(H(n,e,n.domain)),t,Mt(n,n.graph))},plane:(t,n)=>{let r=j(n);return it(r.map,$(H(n,r,n.domain)))},render:(t,n)=>et(t,n,H(n,j(n),n.domain))}),(t,n)=>H(t,n,t.domain)),Rr=A(256);function H(t,n,r){let{map:e,shift:o}=n,{area:i}=e;if(!Number.isFinite(i.maxX-i.minX))return[];let{source:s,blend:a}=t.expression,f=[s,a?.from,a?.t,e.revision,r,JSON.stringify(t.params),o.x,o.y].join("|"),u=Rr.get(f);if(u)return u;let c,l=a&&a.t<.5?a.from:s;if(It(s)?.kind==="implicit"||a&&It(a.from)?.kind==="implicit")c=Po(l,t.params,e,o);else{let p=Xr(s,t.params,r,e,o);if(p&&a){let y=Xr(a.from,t.params,r,e,o);y&&(p=No(y,p,a.t))}let d=i.maxX-i.minX;c=p?Mn(p,0,1,i,{seeds:Math.min(512,Math.max(64,Math.round(d/8))),minStep:.5/Math.max(1,d)}):[]}return Rr.set(f,c),c}function It(t){let n=U(t,k(t));return n instanceof Error?null:n}function Po(t,n,r,e){let o=It(t);if(o?.kind!=="implicit")return[];let i=F(k(t),n),{area:s}=r,a=c=>Math.min(Io,Math.max(8,Math.round(c/ko))),{f}=o;return In((c,l)=>f(c-e.x,l-e.y,i),r.xRange,r.yRange,a(s.maxX-s.minX),a(s.maxY-s.minY)).map(c=>c.map(l=>r.toPoint(l.x,l.y)))}function Xr(t,n,r,e,o){let i=It(t);if(!i||i.kind==="implicit")return null;let s=F(k(t),n);switch(i.kind){case"function":{let a=i.of==="x",[f,u]=a?e.xRange:e.yRange,c=a?o.x:o.y,l=Math.max(f-c,r?.[0]??-1/0),p=Math.min(u-c,r?.[1]??1/0);if(!(p>l))return null;let{f:d}=i;return(y,h)=>{let E=l+(p-l)*y,x=d(E,0,s);return Number.isFinite(x)?(a?e.toPoint(E+o.x,x+o.y,h):e.toPoint(x+o.x,E+o.y,h),!0):!1}}case"polar":{let[a,f]=r??[0,To],{f:u}=i;return(c,l)=>{let p=a+(f-a)*c,d=u(p,0,s);return Number.isFinite(d)?(e.toPoint(d*Math.cos(p)+o.x,d*Math.sin(p)+o.y,l),!0):!1}}case"parametric":{let[a,f]=r??[0,1],{x:u,y:c}=i;return(l,p)=>{let d=a+(f-a)*l,y=u(d,0,s),h=c(d,0,s);return!Number.isFinite(y)||!Number.isFinite(h)?!1:(e.toPoint(y+o.x,h+o.y,p),!0)}}}}var ko=5,Io=220;function No(t,n,r){let e={x:0,y:0};return(o,i)=>!t(o,e)||!n(o,i)?!1:(i.x=e.x+(i.x-e.x)*r,i.y=e.y+(i.y-e.y)*r,!0)}import{Graphics2D as Co,Types as Nt}from"@motionscript/sdk";import{colorOps as Ln,fillOps as _n}from"@motionscript/sdk";function Lo(t){return(t??[]).map(n=>Ln.resolve(n))}function _o(t,n,r){return t.length!==n.length?r<1?t:n:n.map((e,o)=>Ln.lerp(t[o],e,r))}function Fo(t,n){if(t.length===1)return t[0];let r=v(n,0,1)*(t.length-1),e=Math.min(t.length-2,Math.floor(r));return Ln.lerp(t[e],t[e+1],r-e)}function Fn(t){return(Array.isArray(t)?t:[]).map(n=>_n.resolve(n??[]))}function Cn(t,n,r){return t.length!==n.length?r<1?t:n:n.map((e,o)=>_n.lerp(t[o],e,r))}function bn(t,n){if(t.length===1)return t[0];let r=v(n,0,1)*(t.length-1),e=Math.min(t.length-2,Math.floor(r));return _n.lerp(t[e],t[e+1],r-e)}var Lt=12,bo={...I(L,"fill","start","end"),expression:Nt.custom("",{resolve:J,lerp:Z,kind:"fieldEquation"}),params:Nt.custom({},{lerp:nt}),strengthFills:Nt.custom([],{resolve:Fn,lerp:Cn,kind:"vector"}),maxMagnitude:Nt.number(0,{min:0,step:.1}),graph:Wt},Ro={...I(_,"fillTo","progressTo","flash"),morphTo:{args:["expression"]},paramsTo:{args:["params"]}},qr=A(64),Xo={drawn:[],runs:[]};function Yo(t,n,r,{map:e,shift:o}){let{area:i}=e;if(!Number.isFinite(i.maxX-i.minX))return Xo;let{source:s,blend:a}=r.expression,f=[t,s,a?.from,a?.t,e.revision,JSON.stringify(r.params),o.x,o.y,n.own(r)].join("|"),u=qr.get(f);if(u)return u;let c=vo(r,o),l=c?n.strokes(r,e,c):[],p={drawn:l,runs:l.flatMap(d=>d.runs)};return qr.set(f,p),p}function Do(t,n,{drawn:r,runs:e}){let o=n.strengthFills,i=n.stroke,s=o.length>0&&i.length>0;et(t,n,e,{ink:s?(a,f)=>{let u=n.maxMagnitude>0?n.maxMagnitude:r.reduce((l,p)=>Math.max(l,p.magnitude),0),c=Array.from({length:Lt},()=>[]);for(let l of r){let p=u>0?Math.min(1,l.magnitude/u):0;c[Math.min(Lt-1,Math.floor(p*Lt))].push(...l.runs)}c.forEach((l,p)=>{if(l.length===0)return;let d=bn(o,(p+.5)/Lt);a.draw(new Co().path({data:rt(l),centerBounds:[f.minX,f.minY,f.maxX,f.maxY],start:n.start??0,end:n.end??1}).shadow(n.shadow).stroke(i.map(y=>({...y,fill:d}))))})}:void 0})}function vo(t,n){let{source:r,blend:e}=t.expression,o=zr(r,t.params,n);if(!o||!e)return o;let i=zr(e.from,t.params,n);if(!i)return o;let s={x:0,y:0};return(a,f,u)=>!i(a,f,s)||!o(a,f,u)?!1:(u.x=s.x+(u.x-s.x)*e.t,u.y=s.y+(u.y-s.y)*e.t,!0)}function zr(t,n,r){let e=V(t),o=Pt(t,e);if(o instanceof Error)return null;let i=F(e,n),{x:s,y:a}=o;return(f,u,c)=>{let l=s(f-r.x,u-r.y,i),p=a(f-r.x,u-r.y,i);return c.x=l,c.y=p,Number.isFinite(l)&&Number.isFinite(p)}}var qo=.5523;function zo(t,n,r,e){let{unit:o,length:i}=ct(t,n);if(i===0)return[];let s=Math.min(e/2,i/4),a=Sn(t,n),f=(x,g)=>P(x,r,g*s),u=(x,g)=>P(x,o,g*s),c=qo,l=(x,g,m)=>({type:"C",x1:x.x,y1:x.y,x2:g.x,y2:g.y,x:m.x,y:m.y}),p=f(u(t,1),1),d=f(u(a,-1),1),y=f(a,2),h=f(u(a,1),1),E=f(u(n,-1),1);return[{type:"M",x:t.x,y:t.y},l(f(t,c),f(u(t,1-c),1),p),{type:"L",x:d.x,y:d.y},l(f(u(a,-1+c),1),f(a,2-c),y),l(f(a,2-c),f(u(a,1-c),1),h),{type:"L",x:E.x,y:E.y},l(f(u(n,-1+c),1),f(n,c),n)]}var Uo=["circular","spring","tree","grid"];function Bo(t,n,r,e){let o=n.length;if(o===0)return new Map;if(o===1)return new Map([[n[0],{x:0,y:0}]]);switch(t){case"grid":return jo(n);case"tree":return Ur(Vo(n,r,e));case"spring":return Ur(Ho(n,r));default:return Br(n)}}function Br(t){let n=t.length;return new Map(t.map((r,e)=>{let o=Math.PI/2-2*Math.PI*e/n;return[r,{x:Math.cos(o),y:Math.sin(o)}]}))}function jo(t){let n=Math.ceil(Math.sqrt(t.length)),r=Math.ceil(t.length/n),e=(o,i)=>i===1?0:-1+2*o/(i-1);return new Map(t.map((o,i)=>[o,{x:e(i%n,n),y:-e(Math.floor(i/n),r)}]))}function $o(t,n){let r=new Map(t.map(e=>[e,[]]));for(let{from:e,to:o}of n)e===o||!r.has(e)||!r.has(o)||(r.get(e).push(o),r.get(o).push(e));return r}function Vo(t,n,r){let e=$o(t,n),o=new Map,i=0,s=(u,c,l)=>{l.add(u);let p=e.get(u).filter(h=>!l.has(h));for(let h of p)l.add(h);if(p.length===0)return o.set(u,{x:i++,y:-c}),o.get(u).x;let d=p.map(h=>s(h,c+1,l)),y=(d[0]+d[d.length-1])/2;return o.set(u,{x:y,y:-c}),y},a=new Set,f=e.has(r)?r:t[0];for(let u of[f,...t])a.has(u)||s(u,0,a);return o}function Ho(t,n){let r=t.length,e=new Map(t.map((c,l)=>[c,l])),o=Br(t),i=t.map(c=>o.get(c).x),s=t.map(c=>o.get(c).y),a=n.flatMap(({from:c,to:l})=>{let p=e.get(c),d=e.get(l);return p===void 0||d===void 0||p===d?[]:[[p,d]]}),f=Math.sqrt(4/r),u=160;for(let c=0;c<u;c++){let l=new Float64Array(r),p=new Float64Array(r);for(let y=0;y<r;y++)for(let h=y+1;h<r;h++){let E=i[y]-i[h],x=s[y]-s[h],g=Math.hypot(E,x);g<1e-6&&([E,x,g]=[.001*(y-h),.001,.001]);let m=f*f/g;l[y]+=E/g*m,p[y]+=x/g*m,l[h]-=E/g*m,p[h]-=x/g*m}for(let[y,h]of a){let E=i[y]-i[h],x=s[y]-s[h],g=Math.max(Math.hypot(E,x),1e-6),m=g*g/f;l[y]-=E/g*m,p[y]-=x/g*m,l[h]+=E/g*m,p[h]+=x/g*m}let d=.12*(1-c/u);for(let y=0;y<r;y++){let h=Math.hypot(l[y],p[y]);h>0&&(i[y]+=l[y]/h*Math.min(h,d),s[y]+=p[y]/h*Math.min(h,d))}}return new Map(t.map((c,l)=>[c,{x:i[l],y:s[l]}]))}function Ur(t){let n=1/0,r=1/0,e=-1/0,o=-1/0;for(let s of t.values())n=Math.min(n,s.x),e=Math.max(e,s.x),r=Math.min(r,s.y),o=Math.max(o,s.y);let i=(s,a,f)=>f-a<1e-9?0:-1+2*(s-a)/(f-a);return new Map([...t].map(([s,a])=>[s,{x:i(a.x,n,e),y:i(a.y,r,o)}]))}export{mt as a,Dt as b,vt as c,z as d,vn as e,Wr as f,Qr as g,Kr as h,Zr as i,te as j,xt as k,At as l,cn as m,un as n,Le as o,ln as p,pn as q,mn as r,xn as s,hn as t,dn as u,W as v,ee as w,Un as x,X as y,ht as z,U as A,Ut as B,k as C,J as D,Z as E,tt as F,Bt as G,nt as H,F as I,ae as J,dt as K,ce as L,jt as M,D as N,yt as O,Gt as P,Wt as Q,fe as R,gt as S,Qt as T,Mt as U,le as V,Et as W,rt as X,C as Y,pe as Z,v as _,me as $,Kt as aa,Jt as ba,j as ca,Zt as da,$ as ea,he as fa,de as ga,Zn as ha,et as ia,tr as ja,nr as ka,ye as la,ot as ma,it as na,sr as oa,st as pa,nn as qa,rn as ra,en as sa,on as ta,sn as ua,St as va,wt as wa,pr as xa,mr as ya,xr as za,Tt as Aa,hr as Ba,dr as Ca,Ce as Da,ut as Ea,V as Fa,Pt as Ga,wn as Ha,In as Ia,Mn as Ja,Yr as Ka,Dr as La,vr as Ma,Oo as Na,H as Oa,Tr as Pa,$e as Qa,He as Ra,Or as Sa,Ge as Ta,Qe as Ua,Ke as Va,P as Wa,Sn as Xa,ct as Ya,Je as Za,zo as _a,So as $a,ao as ab,Pn as bb,co as cb,uo as db,fo as eb,lo as fb,q as gb,An as hb,Tn as ib,kr as jb,Ir as kb,Nr as lb,Lr as mb,oo as nb,Lo as ob,_o as pb,Fo as qb,Fn as rb,Cn as sb,bn as tb,mo as ub,xo as vb,bo as wb,Ro as xb,Yo as yb,Do as zb,Uo as Ab,Bo as Bb,$r as Cb,Vr as Db,Hr as Eb};
|
|
2
|
-
//# sourceMappingURL=chunk-IRZCG6PM.js.map
|