@motionscript/math 0.0.0-stage → 0.1.0-alpha.10
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 +144 -0
- package/LICENSE +201 -0
- package/NOTICE +49 -0
- package/README.md +389 -2
- package/dist/annotate/angle-mark.d.ts +96 -0
- package/dist/annotate/angle-mark.d.ts.map +1 -0
- package/dist/annotate/angle-mark.js +97 -0
- package/dist/annotate/angle-mark.js.map +1 -0
- package/dist/annotate/curly-brace.d.ts +115 -0
- package/dist/annotate/curly-brace.d.ts.map +1 -0
- package/dist/annotate/curly-brace.js +99 -0
- package/dist/annotate/curly-brace.js.map +1 -0
- package/dist/annotate/emphasis-mark.d.ts +80 -0
- package/dist/annotate/emphasis-mark.d.ts.map +1 -0
- package/dist/annotate/emphasis-mark.js +80 -0
- package/dist/annotate/emphasis-mark.js.map +1 -0
- package/dist/browser/THIRD_PARTY_LICENSES.txt +420 -0
- package/dist/browser/chunks/chunk-IRZCG6PM.js +2 -0
- package/dist/browser/chunks/chunk-IRZCG6PM.js.map +7 -0
- package/dist/browser/chunks/chunk-WMVW6ZIV.js +2 -0
- package/dist/browser/chunks/chunk-WMVW6ZIV.js.map +7 -0
- package/dist/browser/chunks/mathjax-WV55AC2P.js +61 -0
- package/dist/browser/chunks/mathjax-WV55AC2P.js.map +7 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/browser/kit.js +2 -0
- package/dist/browser/kit.js.map +7 -0
- package/dist/browser/manifest.json +30 -0
- package/dist/browser/tex.js +2 -0
- package/dist/browser/tex.js.map +7 -0
- package/dist/engine.d.ts +71 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +45 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/kit/brace.d.ts +8 -0
- package/dist/kit/brace.d.ts.map +1 -0
- package/dist/kit/brace.js +36 -0
- package/dist/kit/brace.js.map +1 -0
- package/dist/kit/cache.d.ts +30 -0
- package/dist/kit/cache.d.ts.map +1 -0
- package/dist/kit/cache.js +53 -0
- package/dist/kit/cache.js.map +1 -0
- package/dist/kit/component.d.ts +51 -0
- package/dist/kit/component.d.ts.map +1 -0
- package/dist/kit/component.js +30 -0
- package/dist/kit/component.js.map +1 -0
- package/dist/kit/contour.d.ts +8 -0
- package/dist/kit/contour.d.ts.map +1 -0
- package/dist/kit/contour.js +93 -0
- package/dist/kit/contour.js.map +1 -0
- package/dist/kit/coords.d.ts +69 -0
- package/dist/kit/coords.d.ts.map +1 -0
- package/dist/kit/coords.js +224 -0
- package/dist/kit/coords.js.map +1 -0
- package/dist/kit/curve.d.ts +28 -0
- package/dist/kit/curve.d.ts.map +1 -0
- package/dist/kit/curve.js +29 -0
- package/dist/kit/curve.js.map +1 -0
- package/dist/kit/equation.d.ts +61 -0
- package/dist/kit/equation.d.ts.map +1 -0
- package/dist/kit/equation.js +168 -0
- package/dist/kit/equation.js.map +1 -0
- package/dist/kit/equation3d.d.ts +50 -0
- package/dist/kit/equation3d.d.ts.map +1 -0
- package/dist/kit/equation3d.js +103 -0
- package/dist/kit/equation3d.js.map +1 -0
- package/dist/kit/expression.d.ts +35 -0
- package/dist/kit/expression.d.ts.map +1 -0
- package/dist/kit/expression.js +124 -0
- package/dist/kit/expression.js.map +1 -0
- package/dist/kit/field-mark.d.ts +79 -0
- package/dist/kit/field-mark.d.ts.map +1 -0
- package/dist/kit/field-mark.js +109 -0
- package/dist/kit/field-mark.js.map +1 -0
- package/dist/kit/field.d.ts +14 -0
- package/dist/kit/field.d.ts.map +1 -0
- package/dist/kit/field.js +46 -0
- package/dist/kit/field.js.map +1 -0
- package/dist/kit/follow.d.ts +109 -0
- package/dist/kit/follow.d.ts.map +1 -0
- package/dist/kit/follow.js +163 -0
- package/dist/kit/follow.js.map +1 -0
- package/dist/kit/furniture.d.ts +32 -0
- package/dist/kit/furniture.d.ts.map +1 -0
- package/dist/kit/furniture.js +92 -0
- package/dist/kit/furniture.js.map +1 -0
- package/dist/kit/geometry.d.ts +13 -0
- package/dist/kit/geometry.d.ts.map +1 -0
- package/dist/kit/geometry.js +54 -0
- package/dist/kit/geometry.js.map +1 -0
- package/dist/kit/graph.d.ts +46 -0
- package/dist/kit/graph.d.ts.map +1 -0
- package/dist/kit/graph.js +90 -0
- package/dist/kit/graph.js.map +1 -0
- package/dist/kit/mark.d.ts +72 -0
- package/dist/kit/mark.d.ts.map +1 -0
- package/dist/kit/mark.js +87 -0
- package/dist/kit/mark.js.map +1 -0
- package/dist/kit/part-fills.d.ts +23 -0
- package/dist/kit/part-fills.d.ts.map +1 -0
- package/dist/kit/part-fills.js +46 -0
- package/dist/kit/part-fills.js.map +1 -0
- package/dist/kit/place.d.ts +20 -0
- package/dist/kit/place.d.ts.map +1 -0
- package/dist/kit/place.js +66 -0
- package/dist/kit/place.js.map +1 -0
- package/dist/kit/sampler.d.ts +17 -0
- package/dist/kit/sampler.d.ts.map +1 -0
- package/dist/kit/sampler.js +250 -0
- package/dist/kit/sampler.js.map +1 -0
- package/dist/kit/scale.d.ts +12 -0
- package/dist/kit/scale.d.ts.map +1 -0
- package/dist/kit/scale.js +37 -0
- package/dist/kit/scale.js.map +1 -0
- package/dist/kit/source.d.ts +22 -0
- package/dist/kit/source.d.ts.map +1 -0
- package/dist/kit/source.js +45 -0
- package/dist/kit/source.js.map +1 -0
- package/dist/kit/system.d.ts +31 -0
- package/dist/kit/system.d.ts.map +1 -0
- package/dist/kit/system.js +71 -0
- package/dist/kit/system.js.map +1 -0
- package/dist/kit/ticks.d.ts +19 -0
- package/dist/kit/ticks.d.ts.map +1 -0
- package/dist/kit/ticks.js +78 -0
- package/dist/kit/ticks.js.map +1 -0
- package/dist/kit/withdrawn.d.ts +9 -0
- package/dist/kit/withdrawn.d.ts.map +1 -0
- package/dist/kit/withdrawn.js +9 -0
- package/dist/kit/withdrawn.js.map +1 -0
- package/dist/marks/curve-area.d.ts +51 -0
- package/dist/marks/curve-area.d.ts.map +1 -0
- package/dist/marks/curve-area.js +59 -0
- package/dist/marks/curve-area.js.map +1 -0
- package/dist/marks/drop-lines.d.ts +57 -0
- package/dist/marks/drop-lines.d.ts.map +1 -0
- package/dist/marks/drop-lines.js +43 -0
- package/dist/marks/drop-lines.js.map +1 -0
- package/dist/marks/plot-point.d.ts +71 -0
- package/dist/marks/plot-point.d.ts.map +1 -0
- package/dist/marks/plot-point.js +71 -0
- package/dist/marks/plot-point.js.map +1 -0
- package/dist/marks/riemann-sum.d.ts +58 -0
- package/dist/marks/riemann-sum.d.ts.map +1 -0
- package/dist/marks/riemann-sum.js +63 -0
- package/dist/marks/riemann-sum.js.map +1 -0
- package/dist/marks/tangent-line.d.ts +71 -0
- package/dist/marks/tangent-line.d.ts.map +1 -0
- package/dist/marks/tangent-line.js +89 -0
- package/dist/marks/tangent-line.js.map +1 -0
- package/dist/marks/vector-arrow.d.ts +60 -0
- package/dist/marks/vector-arrow.d.ts.map +1 -0
- package/dist/marks/vector-arrow.js +67 -0
- package/dist/marks/vector-arrow.js.map +1 -0
- package/dist/nodes.d.ts +43 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +57 -0
- package/dist/nodes.js.map +1 -0
- package/dist/plots/function-plot.d.ts +159 -0
- package/dist/plots/function-plot.d.ts.map +1 -0
- package/dist/plots/function-plot.js +184 -0
- package/dist/plots/function-plot.js.map +1 -0
- package/dist/plots/points-plot.d.ts +64 -0
- package/dist/plots/points-plot.d.ts.map +1 -0
- package/dist/plots/points-plot.js +72 -0
- package/dist/plots/points-plot.js.map +1 -0
- package/dist/plots/stream-lines.d.ts +76 -0
- package/dist/plots/stream-lines.d.ts.map +1 -0
- package/dist/plots/stream-lines.js +122 -0
- package/dist/plots/stream-lines.js.map +1 -0
- package/dist/plots/traced-path.d.ts +70 -0
- package/dist/plots/traced-path.d.ts.map +1 -0
- package/dist/plots/traced-path.js +41 -0
- package/dist/plots/traced-path.js.map +1 -0
- package/dist/plots/vector-field.d.ts +60 -0
- package/dist/plots/vector-field.d.ts.map +1 -0
- package/dist/plots/vector-field.js +77 -0
- package/dist/plots/vector-field.js.map +1 -0
- package/dist/structures/graph-layout.d.ts +11 -0
- package/dist/structures/graph-layout.d.ts.map +1 -0
- package/dist/structures/graph-layout.js +135 -0
- package/dist/structures/graph-layout.js.map +1 -0
- package/dist/structures/network-graph.d.ts +174 -0
- package/dist/structures/network-graph.d.ts.map +1 -0
- package/dist/structures/network-graph.js +240 -0
- package/dist/structures/network-graph.js.map +1 -0
- package/dist/structures/sample-space.d.ts +114 -0
- package/dist/structures/sample-space.d.ts.map +1 -0
- package/dist/structures/sample-space.js +161 -0
- package/dist/structures/sample-space.js.map +1 -0
- package/dist/systems/axes2d.d.ts +197 -0
- package/dist/systems/axes2d.d.ts.map +1 -0
- package/dist/systems/axes2d.js +157 -0
- package/dist/systems/axes2d.js.map +1 -0
- package/dist/systems/number-line.d.ts +101 -0
- package/dist/systems/number-line.d.ts.map +1 -0
- package/dist/systems/number-line.js +91 -0
- package/dist/systems/number-line.js.map +1 -0
- package/dist/systems/number-plane.d.ts +168 -0
- package/dist/systems/number-plane.d.ts.map +1 -0
- package/dist/systems/number-plane.js +186 -0
- package/dist/systems/number-plane.js.map +1 -0
- package/dist/systems/polar-plane.d.ts +98 -0
- package/dist/systems/polar-plane.d.ts.map +1 -0
- package/dist/systems/polar-plane.js +139 -0
- package/dist/systems/polar-plane.js.map +1 -0
- package/dist/tex/geometry.d.ts +85 -0
- package/dist/tex/geometry.d.ts.map +1 -0
- package/dist/tex/geometry.js +632 -0
- package/dist/tex/geometry.js.map +1 -0
- package/dist/tex/index.d.ts +11 -0
- package/dist/tex/index.d.ts.map +1 -0
- package/dist/tex/index.js +10 -0
- package/dist/tex/index.js.map +1 -0
- package/dist/tex/mathjax.d.ts +33 -0
- package/dist/tex/mathjax.d.ts.map +1 -0
- package/dist/tex/mathjax.js +74 -0
- package/dist/tex/mathjax.js.map +1 -0
- package/dist/tex/matrix.d.ts +101 -0
- package/dist/tex/matrix.d.ts.map +1 -0
- package/dist/tex/matrix.js +56 -0
- package/dist/tex/matrix.js.map +1 -0
- package/dist/tex/node.d.ts +98 -0
- package/dist/tex/node.d.ts.map +1 -0
- package/dist/tex/node.js +25 -0
- package/dist/tex/node.js.map +1 -0
- package/dist/tex/tween.d.ts +50 -0
- package/dist/tex/tween.d.ts.map +1 -0
- package/dist/tex/tween.js +253 -0
- package/dist/tex/tween.js.map +1 -0
- package/dist/tex/typeset.d.ts +133 -0
- package/dist/tex/typeset.d.ts.map +1 -0
- package/dist/tex/typeset.js +403 -0
- package/dist/tex/typeset.js.map +1 -0
- package/dist/three/axes3d.d.ts +247 -0
- package/dist/three/axes3d.d.ts.map +1 -0
- package/dist/three/axes3d.js +187 -0
- package/dist/three/axes3d.js.map +1 -0
- package/dist/three/curve-plot3d.d.ts +126 -0
- package/dist/three/curve-plot3d.d.ts.map +1 -0
- package/dist/three/curve-plot3d.js +109 -0
- package/dist/three/curve-plot3d.js.map +1 -0
- package/dist/three/entries.d.ts +17 -0
- package/dist/three/entries.d.ts.map +1 -0
- package/dist/three/entries.js +15 -0
- package/dist/three/entries.js.map +1 -0
- package/dist/three/label3d.d.ts +11 -0
- package/dist/three/label3d.d.ts.map +1 -0
- package/dist/three/label3d.js +42 -0
- package/dist/three/label3d.js.map +1 -0
- package/dist/three/plot-point3d.d.ts +99 -0
- package/dist/three/plot-point3d.d.ts.map +1 -0
- package/dist/three/plot-point3d.js +34 -0
- package/dist/three/plot-point3d.js.map +1 -0
- package/dist/three/space.d.ts +43 -0
- package/dist/three/space.d.ts.map +1 -0
- package/dist/three/space.js +58 -0
- package/dist/three/space.js.map +1 -0
- package/dist/three/surface-plot3d.d.ts +207 -0
- package/dist/three/surface-plot3d.d.ts.map +1 -0
- package/dist/three/surface-plot3d.js +261 -0
- package/dist/three/surface-plot3d.js.map +1 -0
- package/dist/three/vector-arrow3d.d.ts +96 -0
- package/dist/three/vector-arrow3d.d.ts.map +1 -0
- package/dist/three/vector-arrow3d.js +53 -0
- package/dist/three/vector-arrow3d.js.map +1 -0
- package/package.json +80 -3
- package/registry.json +251 -0
- package/src/annotate/angle-mark.ts +137 -0
- package/src/annotate/curly-brace.ts +148 -0
- package/src/annotate/emphasis-mark.ts +118 -0
- package/src/engine.ts +86 -0
- package/src/index.ts +29 -0
- package/src/kit/brace.ts +37 -0
- package/src/kit/cache.ts +61 -0
- package/src/kit/component.ts +57 -0
- package/src/kit/contour.ts +94 -0
- package/src/kit/coords.ts +278 -0
- package/src/kit/curve.ts +47 -0
- package/src/kit/equation.ts +181 -0
- package/src/kit/equation3d.ts +137 -0
- package/src/kit/expression.ts +159 -0
- package/src/kit/field-mark.ts +171 -0
- package/src/kit/field.ts +50 -0
- package/src/kit/follow.ts +229 -0
- package/src/kit/furniture.ts +113 -0
- package/src/kit/geometry.ts +49 -0
- package/src/kit/graph.ts +116 -0
- package/src/kit/mark.ts +152 -0
- package/src/kit/part-fills.ts +61 -0
- package/src/kit/place.ts +77 -0
- package/src/kit/sampler.ts +281 -0
- package/src/kit/scale.ts +39 -0
- package/src/kit/source.ts +57 -0
- package/src/kit/system.ts +105 -0
- package/src/kit/ticks.ts +85 -0
- package/src/kit/withdrawn.ts +8 -0
- package/src/marks/curve-area.ts +89 -0
- package/src/marks/drop-lines.ts +71 -0
- package/src/marks/plot-point.ts +102 -0
- package/src/marks/riemann-sum.ts +99 -0
- package/src/marks/tangent-line.ts +119 -0
- package/src/marks/vector-arrow.ts +98 -0
- package/src/nodes.ts +99 -0
- package/src/plots/function-plot.ts +220 -0
- package/src/plots/points-plot.ts +103 -0
- package/src/plots/stream-lines.ts +160 -0
- package/src/plots/traced-path.ts +70 -0
- package/src/plots/vector-field.ts +107 -0
- package/src/structures/graph-layout.ts +145 -0
- package/src/structures/network-graph.ts +291 -0
- package/src/structures/sample-space.ts +210 -0
- package/src/systems/axes2d.ts +226 -0
- package/src/systems/number-line.ts +130 -0
- package/src/systems/number-plane.ts +232 -0
- package/src/systems/polar-plane.ts +177 -0
- package/src/tex/geometry.ts +703 -0
- package/src/tex/index.ts +15 -0
- package/src/tex/mathjax.ts +82 -0
- package/src/tex/matrix.ts +97 -0
- package/src/tex/node.ts +74 -0
- package/src/tex/tween.ts +308 -0
- package/src/tex/typeset.ts +461 -0
- package/src/three/axes3d.ts +267 -0
- package/src/three/curve-plot3d.ts +146 -0
- package/src/three/entries.ts +42 -0
- package/src/three/label3d.ts +52 -0
- package/src/three/plot-point3d.ts +63 -0
- package/src/three/space.ts +92 -0
- package/src/three/surface-plot3d.ts +318 -0
- package/src/three/vector-arrow3d.ts +88 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type Fill, type FillResolved, type PaintProps, type RenderContext, type StrokeResolved, type Vector2, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke } from "@motionscript/sdk";
|
|
2
|
+
import type { CoordinateMap } from "./coords.js";
|
|
3
|
+
import type { ExpressionScope } from "./expression.js";
|
|
4
|
+
import { type MarkPaint, type MarkReading } from "./mark.js";
|
|
5
|
+
import { type PlotSource } from "./source.js";
|
|
6
|
+
/**
|
|
7
|
+
* What a mark drawn from a vector field, `(P(x, y), Q(x, y))`, shares: arrows,
|
|
8
|
+
* or the lines that follow it, all in one stroke. Without strength fills it is
|
|
9
|
+
* one path in the stroke's paint; with them, what it draws is sorted by the
|
|
10
|
+
* field's strength into a few shades.
|
|
11
|
+
*/
|
|
12
|
+
export interface FieldProps extends PaintProps {
|
|
13
|
+
expression?: string | PlotSource;
|
|
14
|
+
params?: ExpressionScope;
|
|
15
|
+
strengthFills?: Fill[];
|
|
16
|
+
maxMagnitude?: number;
|
|
17
|
+
}
|
|
18
|
+
/** A field's vector at a graph point, written into `out`; `false` where it has none. */
|
|
19
|
+
export type FieldSampler = (x: number, y: number, out: Vector2) => boolean;
|
|
20
|
+
/** One thing a field draws, and how strong the field is there: what it is coloured by. */
|
|
21
|
+
export interface FieldStroke {
|
|
22
|
+
runs: Vector2[][];
|
|
23
|
+
magnitude: number;
|
|
24
|
+
}
|
|
25
|
+
/** A field mark's entries. It is only strokes, revealed its own way: it has no fill and trims no outline. */
|
|
26
|
+
export declare const FIELD_STATE: {
|
|
27
|
+
expression: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
|
|
28
|
+
/** The equation's named values: any name in it that is not `x`, `y`, a function or a constant. */
|
|
29
|
+
params: import("@motionscript/sdk").Type<Readonly<Record<string, number>>, Readonly<Record<string, number>>, false>;
|
|
30
|
+
/** Paints by the field's strength, weakest first. Empty draws everything in the stroke's own paint. */
|
|
31
|
+
strengthFills: import("@motionscript/sdk").Type<Fill[], FillResolved[][], false>;
|
|
32
|
+
/** The strength the last paint stands for; zero takes the strongest the field is where it is drawn. */
|
|
33
|
+
maxMagnitude: import("@motionscript/sdk").Type<number, number, false>;
|
|
34
|
+
graph: import("@motionscript/sdk").Type<import("./graph.js").GraphPlane | null, import("./graph.js").GraphPlane | null, true>;
|
|
35
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
|
|
36
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
37
|
+
};
|
|
38
|
+
export declare const FIELD_COMMANDS: {
|
|
39
|
+
/** Change the field, each vector turning from the one into the other. */
|
|
40
|
+
morphTo: {
|
|
41
|
+
args: readonly ["expression"];
|
|
42
|
+
};
|
|
43
|
+
/** Animate the equation's named values. */
|
|
44
|
+
paramsTo: {
|
|
45
|
+
args: readonly ["params"];
|
|
46
|
+
};
|
|
47
|
+
strokeTo: {
|
|
48
|
+
readonly args: readonly ["stroke"];
|
|
49
|
+
readonly run?: undefined;
|
|
50
|
+
};
|
|
51
|
+
shadowTo: {
|
|
52
|
+
readonly args: readonly ["shadow"];
|
|
53
|
+
readonly run?: undefined;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/** What a field mark is drawn from. */
|
|
57
|
+
export interface FieldValues {
|
|
58
|
+
readonly expression: PlotSource;
|
|
59
|
+
readonly params: ExpressionScope;
|
|
60
|
+
}
|
|
61
|
+
/** What one kind of field mark draws of `field` through `map`, and the entries of its own that change it. */
|
|
62
|
+
export interface FieldDrawing<S> {
|
|
63
|
+
strokes(s: S, map: CoordinateMap, field: FieldSampler): FieldStroke[];
|
|
64
|
+
/** The entries of its own that change what `strokes` returns, as a key. */
|
|
65
|
+
own(s: S): string;
|
|
66
|
+
}
|
|
67
|
+
interface Traced {
|
|
68
|
+
readonly drawn: FieldStroke[];
|
|
69
|
+
readonly runs: Vector2[][];
|
|
70
|
+
}
|
|
71
|
+
/** What a field mark of `kind` draws through `read`: each stroke with its strength, and all their runs. */
|
|
72
|
+
export declare function traceField<S extends FieldValues>(kind: string, drawing: FieldDrawing<S>, s: S, { map, shift }: MarkReading): Traced;
|
|
73
|
+
/** A field mark's paint: one stroke, or a shade per strength when it has strength fills. */
|
|
74
|
+
export declare function drawField(ctx: RenderContext, s: MarkPaint & {
|
|
75
|
+
readonly strengthFills: FillResolved[][];
|
|
76
|
+
readonly maxMagnitude: number;
|
|
77
|
+
}, { drawn, runs }: Traced): void;
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=field-mark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-mark.d.ts","sourceRoot":"","sources":["../../src/kit/field-mark.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,OAAO,EAEZ,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACtC,KAAK,MAAM,IAAI,OAAO,EACzB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAA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AC;CACrB;AAED,UAAU,MAAM;IACZ,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC;CAC9B;AAKD,2GAA2G;AAC3G,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,WAAW,GAAG,MAAM,CAYnI;AAED,4FAA4F;AAC5F,wBAAgB,SAAS,CACrB,GAAG,EAAE,aAAa,EAClB,CAAC,EAAE,SAAS,GAAG;IAAE,QAAQ,CAAC,aAAa,EAAE,YAAY,EAAE,EAAE,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAC1F,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,GACxB,IAAI,CA0BN"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Graphics2D, Types, } from "@motionscript/sdk";
|
|
2
|
+
import { createBoundedCache } from "./cache.js";
|
|
3
|
+
import { omit, PAINT, PAINT_COMMANDS } from "./component.js";
|
|
4
|
+
import { fieldParams, parseField } from "./field.js";
|
|
5
|
+
import { runsToPath } from "./geometry.js";
|
|
6
|
+
import { PLANE_ENTRY } from "./graph.js";
|
|
7
|
+
import { drawMark } from "./mark.js";
|
|
8
|
+
import { fillAt, lerpFillScale, readFillScale } from "./scale.js";
|
|
9
|
+
import { lerpParams, lerpSource, readSource, scopeFor } from "./source.js";
|
|
10
|
+
/** How many shades the strength fills are drawn in: each is one path. */
|
|
11
|
+
const SHADES = 12;
|
|
12
|
+
/** A field mark's entries. It is only strokes, revealed its own way: it has no fill and trims no outline. */
|
|
13
|
+
export const FIELD_STATE = {
|
|
14
|
+
...omit(PAINT, "fill", "start", "end"),
|
|
15
|
+
expression: Types.custom("", { resolve: readSource, lerp: lerpSource, kind: "fieldEquation" }),
|
|
16
|
+
/** The equation's named values: any name in it that is not `x`, `y`, a function or a constant. */
|
|
17
|
+
params: Types.custom({}, { lerp: lerpParams }),
|
|
18
|
+
/** Paints by the field's strength, weakest first. Empty draws everything in the stroke's own paint. */
|
|
19
|
+
strengthFills: Types.custom([], { resolve: readFillScale, lerp: lerpFillScale, kind: "vector" }),
|
|
20
|
+
/** The strength the last paint stands for; zero takes the strongest the field is where it is drawn. */
|
|
21
|
+
maxMagnitude: Types.number(0, { min: 0, step: 0.1 }),
|
|
22
|
+
graph: PLANE_ENTRY,
|
|
23
|
+
};
|
|
24
|
+
export const FIELD_COMMANDS = {
|
|
25
|
+
...omit(PAINT_COMMANDS, "fillTo", "progressTo", "flash"),
|
|
26
|
+
/** Change the field, each vector turning from the one into the other. */
|
|
27
|
+
morphTo: { args: ["expression"] },
|
|
28
|
+
/** Animate the equation's named values. */
|
|
29
|
+
paramsTo: { args: ["params"] },
|
|
30
|
+
};
|
|
31
|
+
const traces = createBoundedCache(64);
|
|
32
|
+
const EMPTY = { drawn: [], runs: [] };
|
|
33
|
+
/** What a field mark of `kind` draws through `read`: each stroke with its strength, and all their runs. */
|
|
34
|
+
export function traceField(kind, drawing, s, { map, shift }) {
|
|
35
|
+
const { area } = map;
|
|
36
|
+
if (!Number.isFinite(area.maxX - area.minX))
|
|
37
|
+
return EMPTY;
|
|
38
|
+
const { source, blend } = s.expression;
|
|
39
|
+
const key = [kind, source, blend?.from, blend?.t, map.revision, JSON.stringify(s.params), shift.x, shift.y, drawing.own(s)].join("|");
|
|
40
|
+
const known = traces.get(key);
|
|
41
|
+
if (known)
|
|
42
|
+
return known;
|
|
43
|
+
const field = sampler(s, shift);
|
|
44
|
+
const drawn = field ? drawing.strokes(s, map, field) : [];
|
|
45
|
+
const traced = { drawn, runs: drawn.flatMap((stroke) => stroke.runs) };
|
|
46
|
+
traces.set(key, traced);
|
|
47
|
+
return traced;
|
|
48
|
+
}
|
|
49
|
+
/** A field mark's paint: one stroke, or a shade per strength when it has strength fills. */
|
|
50
|
+
export function drawField(ctx, s, { drawn, runs }) {
|
|
51
|
+
const scale = s.strengthFills;
|
|
52
|
+
const stroke = s.stroke;
|
|
53
|
+
const shaded = scale.length > 0 && stroke.length > 0;
|
|
54
|
+
drawMark(ctx, s, runs, {
|
|
55
|
+
ink: shaded
|
|
56
|
+
? (ctx, ink) => {
|
|
57
|
+
const top = s.maxMagnitude > 0 ? s.maxMagnitude : drawn.reduce((most, d) => Math.max(most, d.magnitude), 0);
|
|
58
|
+
const shades = Array.from({ length: SHADES }, () => []);
|
|
59
|
+
for (const d of drawn) {
|
|
60
|
+
const share = top > 0 ? Math.min(1, d.magnitude / top) : 0;
|
|
61
|
+
shades[Math.min(SHADES - 1, Math.floor(share * SHADES))].push(...d.runs);
|
|
62
|
+
}
|
|
63
|
+
shades.forEach((shade, index) => {
|
|
64
|
+
if (shade.length === 0)
|
|
65
|
+
return;
|
|
66
|
+
const fill = fillAt(scale, (index + 0.5) / SHADES);
|
|
67
|
+
ctx.draw(new Graphics2D()
|
|
68
|
+
.path({ data: runsToPath(shade), centerBounds: [ink.minX, ink.minY, ink.maxX, ink.maxY], start: s.start ?? 0, end: s.end ?? 1 })
|
|
69
|
+
.shadow(s.shadow)
|
|
70
|
+
.stroke(stroke.map((layer) => ({ ...layer, fill }))));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
: undefined,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** The field at a graph point, measured from the mark's own shift, mid-morph a blend of two. */
|
|
77
|
+
function sampler(s, shift) {
|
|
78
|
+
const { source, blend } = s.expression;
|
|
79
|
+
const to = fieldOf(source, s.params, shift);
|
|
80
|
+
if (!to || !blend)
|
|
81
|
+
return to;
|
|
82
|
+
const from = fieldOf(blend.from, s.params, shift);
|
|
83
|
+
if (!from)
|
|
84
|
+
return to;
|
|
85
|
+
const start = { x: 0, y: 0 };
|
|
86
|
+
return (x, y, out) => {
|
|
87
|
+
if (!from(x, y, start) || !to(x, y, out))
|
|
88
|
+
return false;
|
|
89
|
+
out.x = start.x + (out.x - start.x) * blend.t;
|
|
90
|
+
out.y = start.y + (out.y - start.y) * blend.t;
|
|
91
|
+
return true;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function fieldOf(source, params, shift) {
|
|
95
|
+
const names = fieldParams(source);
|
|
96
|
+
const field = parseField(source, names);
|
|
97
|
+
if (field instanceof Error)
|
|
98
|
+
return null;
|
|
99
|
+
const scope = scopeFor(names, params);
|
|
100
|
+
const { x, y } = field;
|
|
101
|
+
return (gx, gy, out) => {
|
|
102
|
+
const vx = x(gx - shift.x, gy - shift.y, scope);
|
|
103
|
+
const vy = y(gx - shift.x, gy - shift.y, scope);
|
|
104
|
+
out.x = vx;
|
|
105
|
+
out.y = vy;
|
|
106
|
+
return Number.isFinite(vx) && Number.isFinite(vy);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=field-mark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-mark.js","sourceRoot":"","sources":["../../src/kit/field-mark.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,KAAK,GAWR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAoC,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,UAAU,E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AE,GAAG,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAChD,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACX,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACX,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {\n Graphics2D,\n Types,\n type Fill,\n type FillResolved,\n type PaintProps,\n type RenderContext,\n type StrokeResolved,\n type Vector2,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n} from \"@motionscript/sdk\";\nimport { createBoundedCache } from \"./cache\";\nimport { omit, PAINT, PAINT_COMMANDS } from \"./component\";\nimport type { CoordinateMap } from \"./coords\";\nimport type { ExpressionScope } from \"./expression\";\nimport { fieldParams, parseField } from \"./field\";\nimport { runsToPath } from \"./geometry\";\nimport { PLANE_ENTRY } from \"./graph\";\nimport { drawMark, type MarkPaint, type MarkReading } from \"./mark\";\nimport { fillAt, lerpFillScale, readFillScale } from \"./scale\";\nimport { lerpParams, lerpSource, readSource, scopeFor, type PlotSource } from \"./source\";\n\n/**\n * What a mark drawn from a vector field, `(P(x, y), Q(x, y))`, shares: arrows,\n * or the lines that follow it, all in one stroke. Without strength fills it is\n * one path in the stroke's paint; with them, what it draws is sorted by the\n * field's strength into a few shades.\n */\n\nexport interface FieldProps extends PaintProps {\n expression?: string | PlotSource;\n params?: ExpressionScope;\n strengthFills?: Fill[];\n maxMagnitude?: number;\n}\n\n/** A field's vector at a graph point, written into `out`; `false` where it has none. */\nexport type FieldSampler = (x: number, y: number, out: Vector2) => boolean;\n\n/** One thing a field draws, and how strong the field is there: what it is coloured by. */\nexport interface FieldStroke {\n runs: Vector2[][];\n magnitude: number;\n}\n\n/** How many shades the strength fills are drawn in: each is one path. */\nconst SHADES = 12;\n\n/** A field mark's entries. It is only strokes, revealed its own way: it has no fill and trims no outline. */\nexport const FIELD_STATE = {\n ...omit(PAINT, \"fill\", \"start\", \"end\"),\n expression: Types.custom<string | PlotSource, PlotSource>(\"\", { resolve: readSource, lerp: lerpSource, kind: \"fieldEquation\" }),\n /** The equation's named values: any name in it that is not `x`, `y`, a function or a constant. */\n params: Types.custom<ExpressionScope>({}, { lerp: lerpParams }),\n /** Paints by the field's strength, weakest first. Empty draws everything in the stroke's own paint. */\n strengthFills: Types.custom<Fill[], FillResolved[][]>([], { resolve: readFillScale, lerp: lerpFillScale, kind: \"vector\" }),\n /** The strength the last paint stands for; zero takes the strongest the field is where it is drawn. */\n maxMagnitude: Types.number(0, { min: 0, step: 0.1 }),\n graph: PLANE_ENTRY,\n};\n\nexport const FIELD_COMMANDS = {\n ...omit(PAINT_COMMANDS, \"fillTo\", \"progressTo\", \"flash\"),\n /** Change the field, each vector turning from the one into the other. */\n morphTo: { args: [\"expression\"] as const },\n /** Animate the equation's named values. */\n paramsTo: { args: [\"params\"] as const },\n};\n\n/** What a field mark is drawn from. */\nexport interface FieldValues {\n readonly expression: PlotSource;\n readonly params: ExpressionScope;\n}\n\n/** What one kind of field mark draws of `field` through `map`, and the entries of its own that change it. */\nexport interface FieldDrawing<S> {\n strokes(s: S, map: CoordinateMap, field: FieldSampler): FieldStroke[];\n /** The entries of its own that change what `strokes` returns, as a key. */\n own(s: S): string;\n}\n\ninterface Traced {\n readonly drawn: FieldStroke[];\n readonly runs: Vector2[][];\n}\n\nconst traces = createBoundedCache<Traced>(64);\nconst EMPTY: Traced = { drawn: [], runs: [] };\n\n/** What a field mark of `kind` draws through `read`: each stroke with its strength, and all their runs. */\nexport function traceField<S extends FieldValues>(kind: string, drawing: FieldDrawing<S>, s: S, { map, shift }: MarkReading): Traced {\n const { area } = map;\n if (!Number.isFinite(area.maxX - area.minX)) return EMPTY;\n const { source, blend } = s.expression;\n const key = [kind, source, blend?.from, blend?.t, map.revision, JSON.stringify(s.params), shift.x, shift.y, drawing.own(s)].join(\"|\");\n const known = traces.get(key);\n if (known) return known;\n const field = sampler(s, shift);\n const drawn = field ? drawing.strokes(s, map, field) : [];\n const traced = { drawn, runs: drawn.flatMap((stroke) => stroke.runs) };\n traces.set(key, traced);\n return traced;\n}\n\n/** A field mark's paint: one stroke, or a shade per strength when it has strength fills. */\nexport function drawField(\n ctx: RenderContext,\n s: MarkPaint & { readonly strengthFills: FillResolved[][]; readonly maxMagnitude: number },\n { drawn, runs }: Traced,\n): void {\n const scale = s.strengthFills;\n const stroke = s.stroke as StrokeResolved[];\n const shaded = scale.length > 0 && stroke.length > 0;\n drawMark(ctx, s, runs, {\n ink: shaded\n ? (ctx, ink) => {\n const top = s.maxMagnitude > 0 ? s.maxMagnitude : drawn.reduce((most, d) => Math.max(most, d.magnitude), 0);\n const shades: Vector2[][][] = Array.from({ length: SHADES }, () => []);\n for (const d of drawn) {\n const share = top > 0 ? Math.min(1, d.magnitude / top) : 0;\n shades[Math.min(SHADES - 1, Math.floor(share * SHADES))].push(...d.runs);\n }\n shades.forEach((shade, index) => {\n if (shade.length === 0) return;\n const fill = fillAt(scale, (index + 0.5) / SHADES);\n ctx.draw(\n new Graphics2D()\n .path({ data: runsToPath(shade), centerBounds: [ink.minX, ink.minY, ink.maxX, ink.maxY], start: s.start ?? 0, end: s.end ?? 1 })\n .shadow(s.shadow)\n .stroke(stroke.map((layer) => ({ ...layer, fill }))),\n );\n });\n }\n : undefined,\n });\n}\n\n/** The field at a graph point, measured from the mark's own shift, mid-morph a blend of two. */\nfunction sampler(s: FieldValues, shift: Vector2): FieldSampler | null {\n const { source, blend } = s.expression;\n const to = fieldOf(source, s.params, shift);\n if (!to || !blend) return to;\n const from = fieldOf(blend.from, s.params, shift);\n if (!from) return to;\n const start: Vector2 = { x: 0, y: 0 };\n return (x, y, out) => {\n if (!from(x, y, start) || !to(x, y, out)) return false;\n out.x = start.x + (out.x - start.x) * blend.t;\n out.y = start.y + (out.y - start.y) * blend.t;\n return true;\n };\n}\n\nfunction fieldOf(source: string, params: ExpressionScope, shift: Vector2): FieldSampler | null {\n const names = fieldParams(source);\n const field = parseField(source, names);\n if (field instanceof Error) return null;\n const scope = scopeFor(names, params);\n const { x, y } = field;\n return (gx, gy, out) => {\n const vx = x(gx - shift.x, gy - shift.y, scope);\n const vy = y(gx - shift.x, gy - shift.y, scope);\n out.x = vx;\n out.y = vy;\n return Number.isFinite(vx) && Number.isFinite(vy);\n };\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type CompiledExpression } from "./expression.js";
|
|
2
|
+
/** A vector at every point of the plane, two parts in `x` and `y`: `(-y, x)`. A warp is written the same way. */
|
|
3
|
+
export interface FieldEquation {
|
|
4
|
+
x: CompiledExpression;
|
|
5
|
+
y: CompiledExpression;
|
|
6
|
+
}
|
|
7
|
+
export declare const FIELD_VARIABLES: readonly ["x", "y"];
|
|
8
|
+
/** The named values a field's equation reads: every name that is not `x` or `y`. */
|
|
9
|
+
export declare function fieldParams(source: string): readonly string[];
|
|
10
|
+
/** `source` as a field, or the reason it is not one. Memoised, so an unchanged equation is the identical object. */
|
|
11
|
+
export declare function parseField(source: string, params?: readonly string[]): FieldEquation | Error;
|
|
12
|
+
/** Why `source` is not a field, or `null`; empty text is not an error. */
|
|
13
|
+
export declare function fieldError(source: string): string | null;
|
|
14
|
+
//# sourceMappingURL=field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/kit/field.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEhF,iHAAiH;AACjH,MAAM,WAAW,aAAa;IAC1B,CAAC,EAAE,kBAAkB,CAAC;IACtB,CAAC,EAAE,kBAAkB,CAAC;CACzB;AAED,eAAO,MAAM,eAAe,qBAAsB,CAAC;AAKnD,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAE7D;AAED,oHAAoH;AACpH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,SAAS,MAAM,EAAO,GAAG,aAAa,GAAG,KAAK,CAqBhG;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIxD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createBoundedCache } from "./cache.js";
|
|
2
|
+
import { equationNames, splitTuple } from "./equation.js";
|
|
3
|
+
import { compileExpressionCached } from "./expression.js";
|
|
4
|
+
export const FIELD_VARIABLES = ["x", "y"];
|
|
5
|
+
const NAMES = new Set(FIELD_VARIABLES);
|
|
6
|
+
const fields = createBoundedCache(128);
|
|
7
|
+
/** The named values a field's equation reads: every name that is not `x` or `y`. */
|
|
8
|
+
export function fieldParams(source) {
|
|
9
|
+
return equationNames(source).filter((name) => !NAMES.has(name));
|
|
10
|
+
}
|
|
11
|
+
/** `source` as a field, or the reason it is not one. Memoised, so an unchanged equation is the identical object. */
|
|
12
|
+
export function parseField(source, params = []) {
|
|
13
|
+
const key = `${params.join(",")}|${source}`;
|
|
14
|
+
const hit = fields.get(key);
|
|
15
|
+
if (hit !== undefined)
|
|
16
|
+
return hit;
|
|
17
|
+
let result;
|
|
18
|
+
try {
|
|
19
|
+
const text = source.trim();
|
|
20
|
+
if (text === "")
|
|
21
|
+
throw new Error("Empty equation");
|
|
22
|
+
const parts = splitTuple(text);
|
|
23
|
+
if (parts?.length !== 2)
|
|
24
|
+
throw new Error("A field has two parts: (x, y)");
|
|
25
|
+
const [x, y] = parts.map((part) => {
|
|
26
|
+
const compiled = compileExpressionCached(part.trim(), FIELD_VARIABLES, params);
|
|
27
|
+
if (compiled instanceof Error)
|
|
28
|
+
throw compiled;
|
|
29
|
+
return compiled;
|
|
30
|
+
});
|
|
31
|
+
result = { x, y };
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
result = error instanceof Error ? error : new Error(String(error));
|
|
35
|
+
}
|
|
36
|
+
fields.set(key, result);
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
/** Why `source` is not a field, or `null`; empty text is not an error. */
|
|
40
|
+
export function fieldError(source) {
|
|
41
|
+
if (source.trim() === "")
|
|
42
|
+
return null;
|
|
43
|
+
const field = parseField(source, fieldParams(source));
|
|
44
|
+
return field instanceof Error ? field.message : null;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../src/kit/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAA2B,MAAM,cAAc,CAAC;AAQhF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,CAAU,CAAC;AAEnD,MAAM,KAAK,GAAwB,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;AAC5D,MAAM,MAAM,GAAG,kBAAkB,CAAwB,GAAG,CAAC,CAAC;AAE9D,oFAAoF;AACpF,MAAM,UAAU,WAAW,CAAC,MAAc;IACtC,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,SAA4B,EAAE;IACrE,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,MAAM,EAAE,CAAC;IAC5C,MAAM,GAAG,GAAG,MAAM,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AW,CAAC,MAAM,CAAC,CAAC,CAAC;IACtD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACzD,CAAC","sourcesContent":["import { createBoundedCache } from \"./cache\";\nimport { equationNames, splitTuple } from \"./equation\";\nimport { compileExpressionCached, type CompiledExpression } from \"./expression\";\n\n/** A vector at every point of the plane, two parts in `x` and `y`: `(-y, x)`. A warp is written the same way. */\nexport interface FieldEquation {\n x: CompiledExpression;\n y: CompiledExpression;\n}\n\nexport const FIELD_VARIABLES = [\"x\", \"y\"] as const;\n\nconst NAMES: ReadonlySet<string> = new Set(FIELD_VARIABLES);\nconst fields = createBoundedCache<FieldEquation | Error>(128);\n\n/** The named values a field's equation reads: every name that is not `x` or `y`. */\nexport function fieldParams(source: string): readonly string[] {\n return equationNames(source).filter((name) => !NAMES.has(name));\n}\n\n/** `source` as a field, or the reason it is not one. Memoised, so an unchanged equation is the identical object. */\nexport function parseField(source: string, params: readonly string[] = []): FieldEquation | Error {\n const key = `${params.join(\",\")}|${source}`;\n const hit = fields.get(key);\n if (hit !== undefined) return hit;\n let result: FieldEquation | Error;\n try {\n const text = source.trim();\n if (text === \"\") throw new Error(\"Empty equation\");\n const parts = splitTuple(text);\n if (parts?.length !== 2) throw new Error(\"A field has two parts: (x, y)\");\n const [x, y] = parts.map((part) => {\n const compiled = compileExpressionCached(part.trim(), FIELD_VARIABLES, params);\n if (compiled instanceof Error) throw compiled;\n return compiled;\n });\n result = { x, y };\n } catch (error) {\n result = error instanceof Error ? error : new Error(String(error));\n }\n fields.set(key, result);\n return result;\n}\n\n/** Why `source` is not a field, or `null`; empty text is not an error. */\nexport function fieldError(source: string): string | null {\n if (source.trim() === \"\") return null;\n const field = parseField(source, fieldParams(source));\n return field instanceof Error ? field.message : null;\n}\n"]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type BoxBounds, type NodeView, type PaintProps, type PathCommand, type RenderContext, type Vector2, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
|
|
2
|
+
/** A node with parts that can be pointed at by name: a formula's terms. */
|
|
3
|
+
export interface Parted {
|
|
4
|
+
/** The box of `part`, y-up from the node's centre, or `null` when it has no such part. */
|
|
5
|
+
partBounds(part: string, occurrence?: number): BoxBounds | null;
|
|
6
|
+
}
|
|
7
|
+
/** What a mark is drawn on: a node by id, and one part of it where it has parts. */
|
|
8
|
+
export interface Target {
|
|
9
|
+
on: string;
|
|
10
|
+
part?: string;
|
|
11
|
+
occurrence?: number;
|
|
12
|
+
}
|
|
13
|
+
/** A target on its way to another: `t` of the way from `from`, or from the mark's resting target. */
|
|
14
|
+
export interface Retarget extends Target {
|
|
15
|
+
from?: Target | null;
|
|
16
|
+
t: number;
|
|
17
|
+
}
|
|
18
|
+
export interface FollowProps extends PaintProps {
|
|
19
|
+
on?: string;
|
|
20
|
+
part?: string;
|
|
21
|
+
occurrence?: number;
|
|
22
|
+
retarget?: Retarget | null;
|
|
23
|
+
}
|
|
24
|
+
/** A target's four corners in its mark's own frame, y-up: top left, top right, bottom right, bottom left. */
|
|
25
|
+
export type Quad = [Vector2, Vector2, Vector2, Vector2];
|
|
26
|
+
/**
|
|
27
|
+
* A mark drawn on another node, or on one part of a formula: a brace, a box,
|
|
28
|
+
* an underline. It has no size of its own and takes no place in a layout; it
|
|
29
|
+
* is drawn where its target is, wherever the two are in the tree, and its
|
|
30
|
+
* selection box is its ink. Its entries, and what it draws on.
|
|
31
|
+
*/
|
|
32
|
+
export declare const FOLLOW_STATE: {
|
|
33
|
+
/** The node this mark is drawn on, by id. Left empty, it is the formula the mark sits inside. */
|
|
34
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
35
|
+
/** One part of that node, by its source, where it has parts: `x^2` of a formula. */
|
|
36
|
+
part: import("@motionscript/sdk").Type<string, string, false>;
|
|
37
|
+
/** Which of the places the part is written, counted from 1. */
|
|
38
|
+
occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
39
|
+
/** Where a `retargetTo` has taken the mark, and how far along it is. Not an author's to state. */
|
|
40
|
+
retarget: import("@motionscript/sdk").Type<Retarget | null, Retarget | null, false>;
|
|
41
|
+
/** The nodes the retarget names, there and where it set out from, read as nodes. */
|
|
42
|
+
retargetOn: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
43
|
+
retargetFrom: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
44
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
45
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
46
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
47
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
48
|
+
};
|
|
49
|
+
export declare const FOLLOW_COMMANDS: {
|
|
50
|
+
retargetTo: {
|
|
51
|
+
readonly args: {
|
|
52
|
+
readonly on: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
|
|
53
|
+
readonly part: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
|
|
54
|
+
readonly occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
55
|
+
};
|
|
56
|
+
run(timeline: any, state: any, children: any): import("@motionscript/sdk").Piece;
|
|
57
|
+
};
|
|
58
|
+
strokeTo: {
|
|
59
|
+
readonly args: readonly ["stroke"];
|
|
60
|
+
readonly run?: undefined;
|
|
61
|
+
};
|
|
62
|
+
shadowTo: {
|
|
63
|
+
readonly args: readonly ["shadow"];
|
|
64
|
+
readonly run?: undefined;
|
|
65
|
+
};
|
|
66
|
+
progressTo: {
|
|
67
|
+
readonly args: readonly ["start", "end"];
|
|
68
|
+
readonly run?: undefined;
|
|
69
|
+
};
|
|
70
|
+
flash: {
|
|
71
|
+
readonly args: {
|
|
72
|
+
readonly portion: import("@motionscript/sdk").Type<number, number, false>;
|
|
73
|
+
};
|
|
74
|
+
run(timeline: any, state: any, children: any): import("@motionscript/sdk").Piece;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/** What a follow mark reads of its state. */
|
|
78
|
+
export interface FollowValues {
|
|
79
|
+
readonly on: NodeView | null;
|
|
80
|
+
readonly part: string;
|
|
81
|
+
readonly occurrence: number;
|
|
82
|
+
readonly retarget: Retarget | null;
|
|
83
|
+
readonly retargetOn: NodeView | null;
|
|
84
|
+
readonly retargetFrom: NodeView | null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The formula a follow mark sits in, as its render last found it: what a mark
|
|
88
|
+
* naming no node is drawn on. Its bounds and handles read it from there, where
|
|
89
|
+
* there is no context to ask.
|
|
90
|
+
*/
|
|
91
|
+
export declare function container(ctx: RenderContext | null, s: object): NodeView | null;
|
|
92
|
+
/** The node the mark rests on: the one `on` names, or the formula it sits in. */
|
|
93
|
+
export declare function resting(s: FollowValues, parted: NodeView | null): NodeView | null;
|
|
94
|
+
/** The target's corners now: its resting one, or part-way to where a `retargetTo` is taking it. */
|
|
95
|
+
export declare function followedQuad(s: FollowValues, parted: NodeView | null): Quad | null;
|
|
96
|
+
/** The box of an outline, as a follow mark's bounds: it has no size of its own, so its ink is what is selected. */
|
|
97
|
+
export declare function outlineBounds(outline: readonly PathCommand[]): BoxBounds;
|
|
98
|
+
/** Every drawn point's centre frame: the mark's own centre, so its outline is where it says. */
|
|
99
|
+
export declare const OWN_FRAME: [number, number, number, number];
|
|
100
|
+
export declare const add: (a: Vector2, b: Vector2, k?: number) => Vector2;
|
|
101
|
+
export declare const between: (a: Vector2, b: Vector2, t?: number) => Vector2;
|
|
102
|
+
/** The unit vector from `a` to `b`, and its length; a zero one points right. */
|
|
103
|
+
export declare function heading(a: Vector2, b: Vector2): {
|
|
104
|
+
unit: Vector2;
|
|
105
|
+
length: number;
|
|
106
|
+
};
|
|
107
|
+
/** A quad grown by `by` pixels on every side, along its own edges. */
|
|
108
|
+
export declare function grown(quad: Quad, by: number): Quad;
|
|
109
|
+
//# sourceMappingURL=follow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../../src/kit/follow.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,OAAO,EAEZ,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACtC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAO3B,2EAA2E;AAC3E,MAAM,WAAW,MAAM;IACnB,0FAA0F;IAC1F,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CACnE;AAYD,oFAAoF;AACpF,MAAM,WAAW,MAAM;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qGAAqG;AACrG,MAAM,WAAW,QAAS,SAAQ,MAAM;IACpC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC3C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC9B;AAED,6GAA6G;AAC7G,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,EA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AAC;AAI1E,eAAO,MAAM,GAAG,GAAI,GAAG,OAAO,EAAE,GAAG,OAAO,EAAE,UAAK,KAAG,OAAmD,CAAC;AACxG,eAAO,MAAM,OAAO,GAAI,GAAG,OAAO,EAAE,GAAG,OAAO,EAAE,UAAO,KAAG,OAAmE,CAAC;AAE9H,gFAAgF;AAChF,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAKjF;AAED,sEAAsE;AACtE,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAUlD"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { commandsFor, pathOps, Types, } from "@motionscript/sdk";
|
|
2
|
+
import { omit, PAINT, PAINT_COMMANDS } from "./component.js";
|
|
3
|
+
import { LatexMatrix } from "../tex/matrix.js";
|
|
4
|
+
import { Latex } from "../tex/node.js";
|
|
5
|
+
import { isFormula, latexPartBounds } from "../tex/typeset.js";
|
|
6
|
+
import { refId } from "./graph.js";
|
|
7
|
+
function isParted(node) {
|
|
8
|
+
return typeof node.partBounds === "function" || isFormula(node);
|
|
9
|
+
}
|
|
10
|
+
/** The box of `part` in `node`: its own `partBounds` answer, or a formula component's by its source. */
|
|
11
|
+
function partBoundsOf(node, part, occurrence) {
|
|
12
|
+
if (typeof node.partBounds === "function")
|
|
13
|
+
return node.partBounds(part, occurrence);
|
|
14
|
+
return latexPartBounds(node, part, occurrence) ?? null;
|
|
15
|
+
}
|
|
16
|
+
const restOf = ({ on, part, occurrence }) => ({ on, part, occurrence });
|
|
17
|
+
function lerpRetarget(from, to, t) {
|
|
18
|
+
if (t <= 0 || !to)
|
|
19
|
+
return t < 1 ? from : to;
|
|
20
|
+
return { ...restOf(to), from: from ? restOf(from) : null, t };
|
|
21
|
+
}
|
|
22
|
+
const REF = Types.custom("", { kind: "nodeRef", animatable: false });
|
|
23
|
+
const HELD_REF = Types.custom("", { kind: "nodeRef", private: true });
|
|
24
|
+
/**
|
|
25
|
+
* A mark drawn on another node, or on one part of a formula: a brace, a box,
|
|
26
|
+
* an underline. It has no size of its own and takes no place in a layout; it
|
|
27
|
+
* is drawn where its target is, wherever the two are in the tree, and its
|
|
28
|
+
* selection box is its ink. Its entries, and what it draws on.
|
|
29
|
+
*/
|
|
30
|
+
export const FOLLOW_STATE = {
|
|
31
|
+
// It is only an outline.
|
|
32
|
+
...omit(PAINT, "fill"),
|
|
33
|
+
/** The node this mark is drawn on, by id. Left empty, it is the formula the mark sits inside. */
|
|
34
|
+
on: REF,
|
|
35
|
+
/** One part of that node, by its source, where it has parts: `x^2` of a formula. */
|
|
36
|
+
part: Types.text("", { animatable: false }),
|
|
37
|
+
/** Which of the places the part is written, counted from 1. */
|
|
38
|
+
occurrence: Types.number(1, { min: 1, step: 1, animatable: false }),
|
|
39
|
+
/** Where a `retargetTo` has taken the mark, and how far along it is. Not an author's to state. */
|
|
40
|
+
retarget: Types.custom(null, { lerp: lerpRetarget }),
|
|
41
|
+
/** The nodes the retarget names, there and where it set out from, read as nodes. */
|
|
42
|
+
retargetOn: HELD_REF,
|
|
43
|
+
retargetFrom: HELD_REF,
|
|
44
|
+
};
|
|
45
|
+
export const FOLLOW_COMMANDS = {
|
|
46
|
+
...omit(PAINT_COMMANDS, "fillTo"),
|
|
47
|
+
...commandsFor(FOLLOW_STATE, {
|
|
48
|
+
/** Move the mark onto another node, or another part. */
|
|
49
|
+
retargetTo: {
|
|
50
|
+
// No defaults for the node and the part: one left out keeps the mark's own.
|
|
51
|
+
args: {
|
|
52
|
+
on: Types.custom(undefined, { kind: "nodeRef" }),
|
|
53
|
+
part: Types.custom(undefined, { kind: "text" }),
|
|
54
|
+
occurrence: Types.number(1, { min: 1, step: 1 }),
|
|
55
|
+
},
|
|
56
|
+
run: (timeline, s) => {
|
|
57
|
+
const next = timeline.args;
|
|
58
|
+
const held = s.retarget ?? restingOf(s);
|
|
59
|
+
const to = {
|
|
60
|
+
on: next.on ?? held.on,
|
|
61
|
+
part: next.part ?? (next.on ? "" : held.part),
|
|
62
|
+
occurrence: next.occurrence ?? 1,
|
|
63
|
+
t: 1,
|
|
64
|
+
};
|
|
65
|
+
const from = s.retarget;
|
|
66
|
+
return timeline.animate((t) => {
|
|
67
|
+
const retarget = lerpRetarget(from, to, t);
|
|
68
|
+
return { retarget, retargetOn: retarget?.on ?? "", retargetFrom: retarget?.from?.on ?? "" };
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
function restingOf(s) {
|
|
75
|
+
return { on: refId(s.on), part: s.part, occurrence: s.occurrence };
|
|
76
|
+
}
|
|
77
|
+
const containers = new WeakMap();
|
|
78
|
+
/**
|
|
79
|
+
* The formula a follow mark sits in, as its render last found it: what a mark
|
|
80
|
+
* naming no node is drawn on. Its bounds and handles read it from there, where
|
|
81
|
+
* there is no context to ask.
|
|
82
|
+
*/
|
|
83
|
+
export function container(ctx, s) {
|
|
84
|
+
if (!ctx)
|
|
85
|
+
return containers.get(s) ?? null;
|
|
86
|
+
const found = ctx.ancestor(Latex) ?? ctx.ancestor(LatexMatrix);
|
|
87
|
+
const parted = found && isParted(found.state) ? found : null;
|
|
88
|
+
containers.set(s, parted);
|
|
89
|
+
return parted;
|
|
90
|
+
}
|
|
91
|
+
/** The node the mark rests on: the one `on` names, or the formula it sits in. */
|
|
92
|
+
export function resting(s, parted) {
|
|
93
|
+
return s.on ?? parted;
|
|
94
|
+
}
|
|
95
|
+
/** The target's corners now: its resting one, or part-way to where a `retargetTo` is taking it. */
|
|
96
|
+
export function followedQuad(s, parted) {
|
|
97
|
+
const state = s.retarget;
|
|
98
|
+
const rest = () => quadOf(resting(s, parted), s);
|
|
99
|
+
if (!state)
|
|
100
|
+
return rest();
|
|
101
|
+
const to = quadOf(state.on === "" ? parted : s.retargetOn, state);
|
|
102
|
+
const from = state.from ? quadOf(state.from.on === "" ? parted : s.retargetFrom, state.from) : rest();
|
|
103
|
+
if (!from || !to || state.t >= 1)
|
|
104
|
+
return to ?? from;
|
|
105
|
+
return lerpQuad(from, to, state.t);
|
|
106
|
+
}
|
|
107
|
+
/** Where `target` is, as the mark sees it; `null` when it names no node or part. */
|
|
108
|
+
function quadOf(node, target) {
|
|
109
|
+
if (!node)
|
|
110
|
+
return null;
|
|
111
|
+
const box = target.part && isParted(node.state)
|
|
112
|
+
? partBoundsOf(node.state, target.part, target.occurrence || 1)
|
|
113
|
+
: { x: 0, y: 0, width: node.size.width, height: node.size.height };
|
|
114
|
+
if (!box)
|
|
115
|
+
return null;
|
|
116
|
+
const frame = node.frame;
|
|
117
|
+
const turn = (frame.rotation * Math.PI) / 180;
|
|
118
|
+
const cos = Math.cos(turn);
|
|
119
|
+
const sin = Math.sin(turn);
|
|
120
|
+
// The engine's turn is clockwise, in a y-up frame.
|
|
121
|
+
const place = (x, y) => ({
|
|
122
|
+
x: frame.x + (cos * x + sin * y) * frame.scale,
|
|
123
|
+
y: frame.y + (-sin * x + cos * y) * frame.scale,
|
|
124
|
+
});
|
|
125
|
+
const w = box.width / 2;
|
|
126
|
+
const h = box.height / 2;
|
|
127
|
+
return [place(box.x - w, box.y + h), place(box.x + w, box.y + h), place(box.x + w, box.y - h), place(box.x - w, box.y - h)];
|
|
128
|
+
}
|
|
129
|
+
function lerpQuad(a, b, t) {
|
|
130
|
+
return a.map((from, i) => ({ x: from.x + (b[i].x - from.x) * t, y: from.y + (b[i].y - from.y) * t }));
|
|
131
|
+
}
|
|
132
|
+
/** The box of an outline, as a follow mark's bounds: it has no size of its own, so its ink is what is selected. */
|
|
133
|
+
export function outlineBounds(outline) {
|
|
134
|
+
const ink = pathOps.bounds(outline);
|
|
135
|
+
if (!ink)
|
|
136
|
+
return { x: 0, y: 0, width: 0, height: 0 };
|
|
137
|
+
return { x: (ink.minX + ink.maxX) / 2, y: (ink.minY + ink.maxY) / 2, width: ink.maxX - ink.minX, height: ink.maxY - ink.minY };
|
|
138
|
+
}
|
|
139
|
+
/** Every drawn point's centre frame: the mark's own centre, so its outline is where it says. */
|
|
140
|
+
export const OWN_FRAME = [-1, -1, 1, 1];
|
|
141
|
+
// --- Geometry the marks share ---
|
|
142
|
+
export const add = (a, b, k = 1) => ({ x: a.x + b.x * k, y: a.y + b.y * k });
|
|
143
|
+
export const between = (a, b, t = 0.5) => ({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });
|
|
144
|
+
/** The unit vector from `a` to `b`, and its length; a zero one points right. */
|
|
145
|
+
export function heading(a, b) {
|
|
146
|
+
const dx = b.x - a.x;
|
|
147
|
+
const dy = b.y - a.y;
|
|
148
|
+
const length = Math.hypot(dx, dy);
|
|
149
|
+
return { unit: length === 0 ? { x: 1, y: 0 } : { x: dx / length, y: dy / length }, length };
|
|
150
|
+
}
|
|
151
|
+
/** A quad grown by `by` pixels on every side, along its own edges. */
|
|
152
|
+
export function grown(quad, by) {
|
|
153
|
+
const [tl, tr, br, bl] = quad;
|
|
154
|
+
const across = heading(tl, tr).unit;
|
|
155
|
+
const up = heading(bl, tl).unit;
|
|
156
|
+
return [
|
|
157
|
+
add(add(tl, across, -by), up, by),
|
|
158
|
+
add(add(tr, across, by), up, by),
|
|
159
|
+
add(add(br, across, by), up, -by),
|
|
160
|
+
add(add(bl, across, -by), up, -by),
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=follow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.js","sourceRoot":"","sources":["../../src/kit/follow.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,OAAO,EACP,KAAK,GAYR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,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Ops,\n Types,\n type BoxBounds,\n type NodeView,\n type PaintProps,\n type PathCommand,\n type RenderContext,\n type Vector2,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n} from \"@motionscript/sdk\";\nimport { omit, PAINT, PAINT_COMMANDS } from \"./component\";\nimport { LatexMatrix } from \"../tex/matrix\";\nimport { Latex } from \"../tex/node\";\nimport { isFormula, latexPartBounds } from \"../tex/typeset\";\nimport { refId } from \"./graph\";\n\n/** A node with parts that can be pointed at by name: a formula's terms. */\nexport interface Parted {\n /** The box of `part`, y-up from the node's centre, or `null` when it has no such part. */\n partBounds(part: string, occurrence?: number): BoxBounds | null;\n}\n\nfunction isParted(node: object): boolean {\n return typeof (node as Partial<Parted>).partBounds === \"function\" || isFormula(node);\n}\n\n/** The box of `part` in `node`: its own `partBounds` answer, or a formula component's by its source. */\nfunction partBoundsOf(node: object, part: string, occurrence: number): BoxBounds | null {\n if (typeof (node as Partial<Parted>).partBounds === \"function\") return (node as Parted).partBounds(part, occurrence);\n return latexPartBounds(node, part, occurrence) ?? null;\n}\n\n/** What a mark is drawn on: a node by id, and one part of it where it has parts. */\nexport interface Target {\n on: string;\n part?: string;\n occurrence?: number;\n}\n\n/** A target on its way to another: `t` of the way from `from`, or from the mark's resting target. */\nexport interface Retarget extends Target {\n from?: Target | null;\n t: number;\n}\n\nexport interface FollowProps extends PaintProps {\n on?: string;\n part?: string;\n occurrence?: number;\n retarget?: Retarget | null;\n}\n\n/** A target's four corners in its mark's own frame, y-up: top left, top right, bottom right, bottom left. */\nexport type Quad = [Vector2, Vector2, Vector2, Vector2];\n\nconst restOf = ({ on, part, occurrence }: Target): Target => ({ on, part, occurrence });\n\nfunction lerpRetarget(from: Retarget | null, to: Retarget | null, t: number): Retarget | null {\n if (t <= 0 || !to) return t < 1 ? from : to;\n return { ...restOf(to), from: from ? restOf(from) : null, t };\n}\n\nconst REF = Types.custom<string, NodeView | null>(\"\", { kind: \"nodeRef\", animatable: false });\nconst HELD_REF = Types.custom<string, NodeView | null, { readonly private: true }>(\"\", { kind: \"nodeRef\", private: true });\n\n/**\n * A mark drawn on another node, or on one part of a formula: a brace, a box,\n * an underline. It has no size of its own and takes no place in a layout; it\n * is drawn where its target is, wherever the two are in the tree, and its\n * selection box is its ink. Its entries, and what it draws on.\n */\nexport const FOLLOW_STATE = {\n // It is only an outline.\n ...omit(PAINT, \"fill\"),\n /** The node this mark is drawn on, by id. Left empty, it is the formula the mark sits inside. */\n on: REF,\n /** One part of that node, by its source, where it has parts: `x^2` of a formula. */\n part: Types.text(\"\", { animatable: false }),\n /** Which of the places the part is written, counted from 1. */\n occurrence: Types.number(1, { min: 1, step: 1, animatable: false }),\n /** Where a `retargetTo` has taken the mark, and how far along it is. Not an author's to state. */\n retarget: Types.custom<Retarget | null>(null, { lerp: lerpRetarget }),\n /** The nodes the retarget names, there and where it set out from, read as nodes. */\n retargetOn: HELD_REF,\n retargetFrom: HELD_REF,\n};\n\nexport const FOLLOW_COMMANDS = {\n ...omit(PAINT_COMMANDS, \"fillTo\"),\n ...commandsFor(FOLLOW_STATE, {\n /** Move the mark onto another node, or another part. */\n retargetTo: {\n // No defaults for the node and the part: one left out keeps the mark's own.\n args: {\n on: Types.custom<string | undefined>(undefined, { kind: \"nodeRef\" }),\n part: Types.custom<string | undefined>(undefined, { kind: \"text\" }),\n occurrence: Types.number(1, { min: 1, step: 1 }),\n },\n run: (timeline, s) => {\n const next = timeline.args;\n const held = s.retarget ?? restingOf(s);\n const to: Retarget = {\n on: next.on ?? held.on,\n part: next.part ?? (next.on ? \"\" : held.part),\n occurrence: next.occurrence ?? 1,\n t: 1,\n };\n const from = s.retarget;\n return timeline.animate((t) => {\n const retarget = lerpRetarget(from, to, t);\n return { retarget, retargetOn: retarget?.on ?? \"\", retargetFrom: retarget?.from?.on ?? \"\" };\n });\n },\n },\n }),\n};\n\n/** What a follow mark reads of its state. */\nexport interface FollowValues {\n readonly on: NodeView | null;\n readonly part: string;\n readonly occurrence: number;\n readonly retarget: Retarget | null;\n readonly retargetOn: NodeView | null;\n readonly retargetFrom: NodeView | null;\n}\n\nfunction restingOf(s: FollowValues): Target {\n return { on: refId(s.on), part: s.part, occurrence: s.occurrence };\n}\n\nconst containers = new WeakMap<object, NodeView | null>();\n\n/**\n * The formula a follow mark sits in, as its render last found it: what a mark\n * naming no node is drawn on. Its bounds and handles read it from there, where\n * there is no context to ask.\n */\nexport function container(ctx: RenderContext | null, s: object): NodeView | null {\n if (!ctx) return containers.get(s) ?? null;\n const found = ctx.ancestor(Latex) ?? ctx.ancestor(LatexMatrix);\n const parted = found && isParted(found.state) ? found : null;\n containers.set(s, parted);\n return parted;\n}\n\n/** The node the mark rests on: the one `on` names, or the formula it sits in. */\nexport function resting(s: FollowValues, parted: NodeView | null): NodeView | null {\n return s.on ?? parted;\n}\n\n/** The target's corners now: its resting one, or part-way to where a `retargetTo` is taking it. */\nexport function followedQuad(s: FollowValues, parted: NodeView | null): Quad | null {\n const state = s.retarget;\n const rest = (): Quad | null => quadOf(resting(s, parted), s);\n if (!state) return rest();\n const to = quadOf(state.on === \"\" ? parted : s.retargetOn, state);\n const from = state.from ? quadOf(state.from.on === \"\" ? parted : s.retargetFrom, state.from) : rest();\n if (!from || !to || state.t >= 1) return to ?? from;\n return lerpQuad(from, to, state.t);\n}\n\n/** Where `target` is, as the mark sees it; `null` when it names no node or part. */\nfunction quadOf(node: NodeView | null, target: Omit<Target, \"on\">): Quad | null {\n if (!node) return null;\n const box: BoxBounds | null =\n target.part && isParted(node.state)\n ? partBoundsOf(node.state, target.part, target.occurrence || 1)\n : { x: 0, y: 0, width: node.size.width, height: node.size.height };\n if (!box) return null;\n const frame = node.frame;\n const turn = (frame.rotation * Math.PI) / 180;\n const cos = Math.cos(turn);\n const sin = Math.sin(turn);\n // The engine's turn is clockwise, in a y-up frame.\n const place = (x: number, y: number): Vector2 => ({\n x: frame.x + (cos * x + sin * y) * frame.scale,\n y: frame.y + (-sin * x + cos * y) * frame.scale,\n });\n const w = box.width / 2;\n const h = box.height / 2;\n return [place(box.x - w, box.y + h), place(box.x + w, box.y + h), place(box.x + w, box.y - h), place(box.x - w, box.y - h)];\n}\n\nfunction lerpQuad(a: Quad, b: Quad, t: number): Quad {\n return a.map((from, i) => ({ x: from.x + (b[i].x - from.x) * t, y: from.y + (b[i].y - from.y) * t })) as Quad;\n}\n\n/** The box of an outline, as a follow mark's bounds: it has no size of its own, so its ink is what is selected. */\nexport function outlineBounds(outline: readonly PathCommand[]): BoxBounds {\n const ink = pathOps.bounds(outline as PathCommand[]);\n if (!ink) return { x: 0, y: 0, width: 0, height: 0 };\n return { x: (ink.minX + ink.maxX) / 2, y: (ink.minY + ink.maxY) / 2, width: ink.maxX - ink.minX, height: ink.maxY - ink.minY };\n}\n\n/** Every drawn point's centre frame: the mark's own centre, so its outline is where it says. */\nexport const OWN_FRAME: [number, number, number, number] = [-1, -1, 1, 1];\n\n// --- Geometry the marks share ---\n\nexport const add = (a: Vector2, b: Vector2, k = 1): Vector2 => ({ x: a.x + b.x * k, y: a.y + b.y * k });\nexport const between = (a: Vector2, b: Vector2, t = 0.5): Vector2 => ({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });\n\n/** The unit vector from `a` to `b`, and its length; a zero one points right. */\nexport function heading(a: Vector2, b: Vector2): { unit: Vector2; length: number } {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const length = Math.hypot(dx, dy);\n return { unit: length === 0 ? { x: 1, y: 0 } : { x: dx / length, y: dy / length }, length };\n}\n\n/** A quad grown by `by` pixels on every side, along its own edges. */\nexport function grown(quad: Quad, by: number): Quad {\n const [tl, tr, br, bl] = quad;\n const across = heading(tl, tr).unit;\n const up = heading(bl, tl).unit;\n return [\n add(add(tl, across, -by), up, by),\n add(add(tr, across, by), up, by),\n add(add(br, across, by), up, -by),\n add(add(bl, across, -by), up, -by),\n ];\n}\n"]}
|