@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,32 @@
|
|
|
1
|
+
import { Graphics2D, type AssetScope, type Color, type Loader, type StrokeResolved, type Vector2 } from "@motionscript/sdk";
|
|
2
|
+
import type { Interval } from "./coords.js";
|
|
3
|
+
/** Shared drawing for the systems' own furniture: axis lines, tick marks and their numbers. */
|
|
4
|
+
/** What a system draws its axes and numbers in, and a plot its curve, until told otherwise. */
|
|
5
|
+
export declare const AXIS_COLOR = "#9ca3af";
|
|
6
|
+
export declare const PLOT_COLOR = "#58a6ff";
|
|
7
|
+
/** A stroke without end markers: an axis wears a tip, its ticks do not. */
|
|
8
|
+
export declare function withoutTips(stroke: StrokeResolved[]): StrokeResolved[];
|
|
9
|
+
export interface LabelStyle {
|
|
10
|
+
fontSize: number;
|
|
11
|
+
fontFamily: string;
|
|
12
|
+
color: Color;
|
|
13
|
+
}
|
|
14
|
+
export interface Label {
|
|
15
|
+
text: string;
|
|
16
|
+
/** Where the label's box is anchored, in pixels. */
|
|
17
|
+
at: Vector2;
|
|
18
|
+
align: "left" | "center" | "right";
|
|
19
|
+
}
|
|
20
|
+
/** Ask the host for MathJax when any of `texts` is a formula, so it is there before the node is laid out. */
|
|
21
|
+
export declare function declareFormulas(assets: AssetScope, texts: readonly string[]): void;
|
|
22
|
+
/** {@link declareFormulas}, for a component's `load`. */
|
|
23
|
+
export declare function loadFormulas(loader: Loader, texts: readonly string[]): void;
|
|
24
|
+
/** What draws `labels`: text in the scene's face, and a typeset formula for each one written as such. */
|
|
25
|
+
export declare function drawLabels(labels: readonly Label[], style: LabelStyle): Graphics2D[];
|
|
26
|
+
/** Whether a mark `u` of the way along an axis is inside the part of it drawn so far. */
|
|
27
|
+
export declare function drawn(u: number, start: number, end: number): boolean;
|
|
28
|
+
/** How far along `range` a value is, 0 to 1, by pixel distance. */
|
|
29
|
+
export declare function along(at: Vector2, from: Vector2, to: Vector2): number;
|
|
30
|
+
export declare function lerpInterval(from: Interval, to: Interval, t: number): Interval;
|
|
31
|
+
export declare function readInterval(value: Interval | undefined, previous?: Interval): Interval;
|
|
32
|
+
//# sourceMappingURL=furniture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"furniture.d.ts","sourceRoot":"","sources":["../../src/kit/furniture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAgB,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjJ,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,+FAA+F;AAE/F,+FAA+F;AAC/F,eAAO,MAAM,UAAU,YAAY,CAAC;AACpC,eAAO,MAAM,UAAU,YAAY,CAAC;AAEpC,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAEtE;AAED,MAAM,WAAW,UAAU;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;CAChB;AAED,MAAM,WAAW,KAAK;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACtC;AAQD,6GAA6G;AAC7G,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAElF;AAED,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAE3E;AAED,yGAAyG;AACzG,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,CA6BpF;AAkBD,yFAAyF;AACzF,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpE;AAED,mEAAmE;AACnE,wBAAgB,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,GAAG,MAAM,CAKrE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,GAAG,QAAQ,CAE9E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAGvF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Fills, Graphics2D, toPathString } from "@motionscript/sdk";
|
|
2
|
+
import { buildLatexPath, LatexNotLoaded, loadMathJax, MATHJAX_LOADER } from "../tex/geometry.js";
|
|
3
|
+
/** Shared drawing for the systems' own furniture: axis lines, tick marks and their numbers. */
|
|
4
|
+
/** What a system draws its axes and numbers in, and a plot its curve, until told otherwise. */
|
|
5
|
+
export const AXIS_COLOR = "#9ca3af";
|
|
6
|
+
export const PLOT_COLOR = "#58a6ff";
|
|
7
|
+
/** A stroke without end markers: an axis wears a tip, its ticks do not. */
|
|
8
|
+
export function withoutTips(stroke) {
|
|
9
|
+
return stroke.map((layer) => ({ ...layer, startCap: undefined, endCap: undefined }));
|
|
10
|
+
}
|
|
11
|
+
/** How wide a label's box is, in ems: room for a long number, so alignment is by the box's edge. */
|
|
12
|
+
const LABEL_BOX_EM = 8;
|
|
13
|
+
/** A label written between dollar signs is a formula: `$\\frac{\\pi}{2}$`. */
|
|
14
|
+
const FORMULA = /^\$([\s\S]+)\$$/;
|
|
15
|
+
/** Ask the host for MathJax when any of `texts` is a formula, so it is there before the node is laid out. */
|
|
16
|
+
export function declareFormulas(assets, texts) {
|
|
17
|
+
if (texts.some((text) => FORMULA.test(text.trim())))
|
|
18
|
+
assets.loader(MATHJAX_LOADER, loadMathJax, { gate: "layout" });
|
|
19
|
+
}
|
|
20
|
+
/** {@link declareFormulas}, for a component's `load`. */
|
|
21
|
+
export function loadFormulas(loader, texts) {
|
|
22
|
+
if (texts.some((text) => FORMULA.test(text.trim())))
|
|
23
|
+
loader.task(MATHJAX_LOADER, loadMathJax, { before: "layout" });
|
|
24
|
+
}
|
|
25
|
+
/** What draws `labels`: text in the scene's face, and a typeset formula for each one written as such. */
|
|
26
|
+
export function drawLabels(labels, style) {
|
|
27
|
+
const out = [];
|
|
28
|
+
const fill = Fills.color(style.color);
|
|
29
|
+
const text = new Graphics2D();
|
|
30
|
+
const width = style.fontSize * LABEL_BOX_EM;
|
|
31
|
+
let written = false;
|
|
32
|
+
for (const label of labels) {
|
|
33
|
+
const formula = FORMULA.exec(label.text.trim());
|
|
34
|
+
const glyphs = formula ? typeset(formula[1], label, style.fontSize) : null;
|
|
35
|
+
if (glyphs) {
|
|
36
|
+
for (const glyph of glyphs)
|
|
37
|
+
out.push(glyph.fill(fill));
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const { at, align } = label;
|
|
41
|
+
written = true;
|
|
42
|
+
text.text({
|
|
43
|
+
text: label.text,
|
|
44
|
+
fontSize: style.fontSize,
|
|
45
|
+
// An empty family is left out, so the label takes the scene's own face.
|
|
46
|
+
...(style.fontFamily === "" ? {} : { fontFamily: style.fontFamily }),
|
|
47
|
+
wrap: false,
|
|
48
|
+
width,
|
|
49
|
+
textAlign: align,
|
|
50
|
+
x: align === "center" ? at.x : align === "right" ? at.x - width / 2 : at.x + width / 2,
|
|
51
|
+
y: at.y,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (written)
|
|
55
|
+
out.push(text.fill(fill));
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
// A formula's glyphs with its box anchored at the label's point; `null` for one that will not typeset, which is then
|
|
59
|
+
// drawn as written, and nothing at all while MathJax is still on its way: its source is not a stand-in for it.
|
|
60
|
+
function typeset(source, { at, align }, fontSize) {
|
|
61
|
+
let formula;
|
|
62
|
+
try {
|
|
63
|
+
formula = buildLatexPath(source, fontSize);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return error instanceof LatexNotLoaded ? [] : null;
|
|
67
|
+
}
|
|
68
|
+
const [minX, minY, maxX, maxY] = formula.bounds;
|
|
69
|
+
const dx = at.x + (align === "left" ? formula.width / 2 : align === "right" ? -formula.width / 2 : 0);
|
|
70
|
+
// Glyph paths are y-down; the frame whose centre lands on the node's is shifted the other way.
|
|
71
|
+
const frame = [minX - dx, minY + at.y, maxX - dx, maxY + at.y];
|
|
72
|
+
return formula.tokens.map((token) => new Graphics2D().path({ data: toPathString(token.path), centerBounds: frame }));
|
|
73
|
+
}
|
|
74
|
+
/** Whether a mark `u` of the way along an axis is inside the part of it drawn so far. */
|
|
75
|
+
export function drawn(u, start, end) {
|
|
76
|
+
return u >= start - 1e-9 && u <= end + 1e-9;
|
|
77
|
+
}
|
|
78
|
+
/** How far along `range` a value is, 0 to 1, by pixel distance. */
|
|
79
|
+
export function along(at, from, to) {
|
|
80
|
+
const dx = to.x - from.x;
|
|
81
|
+
const dy = to.y - from.y;
|
|
82
|
+
const length = dx * dx + dy * dy;
|
|
83
|
+
return length === 0 ? 0 : ((at.x - from.x) * dx + (at.y - from.y) * dy) / length;
|
|
84
|
+
}
|
|
85
|
+
export function lerpInterval(from, to, t) {
|
|
86
|
+
return [from[0] + (to[0] - from[0]) * t, from[1] + (to[1] - from[1]) * t];
|
|
87
|
+
}
|
|
88
|
+
export function readInterval(value, previous) {
|
|
89
|
+
const [min, max] = Array.isArray(value) ? value : (previous ?? [0, 1]);
|
|
90
|
+
return [Number(min), Number(max)];
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=furniture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"furniture.js","sourceRoot":"","sources":["../../src/kit/furniture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAA+E,MAAM,mBAAmB,CAAC;AACjJ,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAG9F,+FAA+F;AAE/F,+FAA+F;AAC/F,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AACpC,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AAEpC,2EAA2E;AAC3E,MAAM,UAAU,WAAW,CAAC,MAAwB;IAChD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACzF,CAAC;AAeD,oGAAoG;AACpG,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,8EAA8E;AAC9E,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAElC,6GAA6G;AAC7G,MAAM,UAAU,eAAe,CAAC,MAAkB,EAAE,KAAwB;IACxE,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAA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C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAc,EAAE,EAAY,EAAE,CAAS;IAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAA2B,EAAE,QAAmB;IACzE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { Fills, Graphics2D, toPathString, type AssetScope, type Color, type Loader, type StrokeResolved, type Vector2 } from \"@motionscript/sdk\";\nimport { buildLatexPath, LatexNotLoaded, loadMathJax, MATHJAX_LOADER } from \"../tex/geometry\";\nimport type { Interval } from \"./coords\";\n\n/** Shared drawing for the systems' own furniture: axis lines, tick marks and their numbers. */\n\n/** What a system draws its axes and numbers in, and a plot its curve, until told otherwise. */\nexport const AXIS_COLOR = \"#9ca3af\";\nexport const PLOT_COLOR = \"#58a6ff\";\n\n/** A stroke without end markers: an axis wears a tip, its ticks do not. */\nexport function withoutTips(stroke: StrokeResolved[]): StrokeResolved[] {\n return stroke.map((layer) => ({ ...layer, startCap: undefined, endCap: undefined }));\n}\n\nexport interface LabelStyle {\n fontSize: number;\n fontFamily: string;\n color: Color;\n}\n\nexport interface Label {\n text: string;\n /** Where the label's box is anchored, in pixels. */\n at: Vector2;\n align: \"left\" | \"center\" | \"right\";\n}\n\n/** How wide a label's box is, in ems: room for a long number, so alignment is by the box's edge. */\nconst LABEL_BOX_EM = 8;\n\n/** A label written between dollar signs is a formula: `$\\\\frac{\\\\pi}{2}$`. */\nconst FORMULA = /^\\$([\\s\\S]+)\\$$/;\n\n/** Ask the host for MathJax when any of `texts` is a formula, so it is there before the node is laid out. */\nexport function declareFormulas(assets: AssetScope, texts: readonly string[]): void {\n if (texts.some((text) => FORMULA.test(text.trim()))) assets.loader(MATHJAX_LOADER, loadMathJax, { gate: \"layout\" });\n}\n\n/** {@link declareFormulas}, for a component's `load`. */\nexport function loadFormulas(loader: Loader, texts: readonly string[]): void {\n if (texts.some((text) => FORMULA.test(text.trim()))) loader.task(MATHJAX_LOADER, loadMathJax, { before: \"layout\" });\n}\n\n/** What draws `labels`: text in the scene's face, and a typeset formula for each one written as such. */\nexport function drawLabels(labels: readonly Label[], style: LabelStyle): Graphics2D[] {\n const out: Graphics2D[] = [];\n const fill = Fills.color(style.color);\n const text = new Graphics2D();\n const width = style.fontSize * LABEL_BOX_EM;\n let written = false;\n for (const label of labels) {\n const formula = FORMULA.exec(label.text.trim());\n const glyphs = formula ? typeset(formula[1], label, style.fontSize) : null;\n if (glyphs) {\n for (const glyph of glyphs) out.push(glyph.fill(fill));\n continue;\n }\n const { at, align } = label;\n written = true;\n text.text({\n text: label.text,\n fontSize: style.fontSize,\n // An empty family is left out, so the label takes the scene's own face.\n ...(style.fontFamily === \"\" ? {} : { fontFamily: style.fontFamily }),\n wrap: false,\n width,\n textAlign: align,\n x: align === \"center\" ? at.x : align === \"right\" ? at.x - width / 2 : at.x + width / 2,\n y: at.y,\n });\n }\n if (written) out.push(text.fill(fill));\n return out;\n}\n\n// A formula's glyphs with its box anchored at the label's point; `null` for one that will not typeset, which is then\n// drawn as written, and nothing at all while MathJax is still on its way: its source is not a stand-in for it.\nfunction typeset(source: string, { at, align }: Label, fontSize: number): Graphics2D[] | null {\n let formula: ReturnType<typeof buildLatexPath>;\n try {\n formula = buildLatexPath(source, fontSize);\n } catch (error) {\n return error instanceof LatexNotLoaded ? [] : null;\n }\n const [minX, minY, maxX, maxY] = formula.bounds;\n const dx = at.x + (align === \"left\" ? formula.width / 2 : align === \"right\" ? -formula.width / 2 : 0);\n // Glyph paths are y-down; the frame whose centre lands on the node's is shifted the other way.\n const frame: [number, number, number, number] = [minX - dx, minY + at.y, maxX - dx, maxY + at.y];\n return formula.tokens.map((token) => new Graphics2D().path({ data: toPathString(token.path), centerBounds: frame }));\n}\n\n/** Whether a mark `u` of the way along an axis is inside the part of it drawn so far. */\nexport function drawn(u: number, start: number, end: number): boolean {\n return u >= start - 1e-9 && u <= end + 1e-9;\n}\n\n/** How far along `range` a value is, 0 to 1, by pixel distance. */\nexport function along(at: Vector2, from: Vector2, to: Vector2): number {\n const dx = to.x - from.x;\n const dy = to.y - from.y;\n const length = dx * dx + dy * dy;\n return length === 0 ? 0 : ((at.x - from.x) * dx + (at.y - from.y) * dy) / length;\n}\n\nexport function lerpInterval(from: Interval, to: Interval, t: number): Interval {\n return [from[0] + (to[0] - from[0]) * t, from[1] + (to[1] - from[1]) * t];\n}\n\nexport function readInterval(value: Interval | undefined, previous?: Interval): Interval {\n const [min, max] = Array.isArray(value) ? value : (previous ?? [0, 1]);\n return [Number(min), Number(max)];\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Extents, PathCommand, Vector2 } from "@motionscript/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Runs of pixel points as path commands. Commands are y-up like every other
|
|
4
|
+
* `Graphics2D` op (only an SVG `d` string is y-down), so nothing is flipped here.
|
|
5
|
+
*/
|
|
6
|
+
export declare function runsToPath(runs: readonly (readonly Vector2[])[], closed?: boolean): PathCommand[];
|
|
7
|
+
export declare function boundsOfRuns(runs: readonly (readonly Vector2[])[]): Extents | null;
|
|
8
|
+
/** `area` grown by `margin` on every side. */
|
|
9
|
+
export declare function inflate(area: Extents, margin: number): Extents;
|
|
10
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
11
|
+
/** `data` without the arguments a command was not given, which arrive as `undefined` and are not destinations. */
|
|
12
|
+
export declare function stated<T extends object>(data: T | undefined): Partial<T>;
|
|
13
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/kit/geometry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEvE;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,UAAQ,GAAG,WAAW,EAAE,CAS/F;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,GAAG,OAAO,GAAG,IAAI,CAYlF;AAED,8CAA8C;AAC9C,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,kHAAkH;AAClH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAOxE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs of pixel points as path commands. Commands are y-up like every other
|
|
3
|
+
* `Graphics2D` op (only an SVG `d` string is y-down), so nothing is flipped here.
|
|
4
|
+
*/
|
|
5
|
+
export function runsToPath(runs, closed = false) {
|
|
6
|
+
const out = [];
|
|
7
|
+
for (const run of runs) {
|
|
8
|
+
if (run.length < 2)
|
|
9
|
+
continue;
|
|
10
|
+
out.push({ type: "M", x: run[0].x, y: run[0].y });
|
|
11
|
+
for (let i = 1; i < run.length; i++)
|
|
12
|
+
out.push({ type: "L", x: run[i].x, y: run[i].y });
|
|
13
|
+
if (closed)
|
|
14
|
+
out.push({ type: "Z" });
|
|
15
|
+
}
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
export function boundsOfRuns(runs) {
|
|
19
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
20
|
+
for (const run of runs) {
|
|
21
|
+
if (run.length < 2)
|
|
22
|
+
continue;
|
|
23
|
+
for (const p of run) {
|
|
24
|
+
if (p.x < minX)
|
|
25
|
+
minX = p.x;
|
|
26
|
+
if (p.x > maxX)
|
|
27
|
+
maxX = p.x;
|
|
28
|
+
if (p.y < minY)
|
|
29
|
+
minY = p.y;
|
|
30
|
+
if (p.y > maxY)
|
|
31
|
+
maxY = p.y;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return minX <= maxX ? { minX, minY, maxX, maxY } : null;
|
|
35
|
+
}
|
|
36
|
+
/** `area` grown by `margin` on every side. */
|
|
37
|
+
export function inflate(area, margin) {
|
|
38
|
+
return { minX: area.minX - margin, minY: area.minY - margin, maxX: area.maxX + margin, maxY: area.maxY + margin };
|
|
39
|
+
}
|
|
40
|
+
export function clamp(value, min, max) {
|
|
41
|
+
return value < min ? min : value > max ? max : value;
|
|
42
|
+
}
|
|
43
|
+
/** `data` without the arguments a command was not given, which arrive as `undefined` and are not destinations. */
|
|
44
|
+
export function stated(data) {
|
|
45
|
+
const out = {};
|
|
46
|
+
if (!data)
|
|
47
|
+
return out;
|
|
48
|
+
for (const key of Object.keys(data)) {
|
|
49
|
+
if (data[key] !== undefined)
|
|
50
|
+
out[key] = data[key];
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/kit/geometry.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAqC,EAAE,MAAM,GAAG,KAAK;IAC5E,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;YAAE,SAAS;QAC7B,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACvF,IAAI,MAAM;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAqC;IAC9D,IAAI,IAAI,GAAG,QAAQ,EAAE,IAAI,GAAG,QAAQ,EAAE,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC;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AM,GAAG,GAAe,EAAE,CAAC;IAC3B,IAAI,CAAC,IAAI;QAAE,OAAO,GAAG,CAAC;IACtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAgB,EAAE,CAAC;QACjD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import type { Extents, PathCommand, Vector2 } from \"@motionscript/sdk\";\n\n/**\n * Runs of pixel points as path commands. Commands are y-up like every other\n * `Graphics2D` op (only an SVG `d` string is y-down), so nothing is flipped here.\n */\nexport function runsToPath(runs: readonly (readonly Vector2[])[], closed = false): PathCommand[] {\n const out: PathCommand[] = [];\n for (const run of runs) {\n if (run.length < 2) continue;\n out.push({ type: \"M\", x: run[0].x, y: run[0].y });\n for (let i = 1; i < run.length; i++) out.push({ type: \"L\", x: run[i].x, y: run[i].y });\n if (closed) out.push({ type: \"Z\" });\n }\n return out;\n}\n\nexport function boundsOfRuns(runs: readonly (readonly Vector2[])[]): Extents | null {\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (const run of runs) {\n if (run.length < 2) continue;\n for (const p of run) {\n if (p.x < minX) minX = p.x;\n if (p.x > maxX) maxX = p.x;\n if (p.y < minY) minY = p.y;\n if (p.y > maxY) maxY = p.y;\n }\n }\n return minX <= maxX ? { minX, minY, maxX, maxY } : null;\n}\n\n/** `area` grown by `margin` on every side. */\nexport function inflate(area: Extents, margin: number): Extents {\n return { minX: area.minX - margin, minY: area.minY - margin, maxX: area.maxX + margin, maxY: area.maxY + margin };\n}\n\nexport function clamp(value: number, min: number, max: number): number {\n return value < min ? min : value > max ? max : value;\n}\n\n/** `data` without the arguments a command was not given, which arrive as `undefined` and are not destinations. */\nexport function stated<T extends object>(data: T | undefined): Partial<T> {\n const out: Partial<T> = {};\n if (!data) return out;\n for (const key of Object.keys(data) as (keyof T)[]) {\n if (data[key] !== undefined) out[key] = data[key];\n }\n return out;\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ChildView, type NodeView, type Context as _Context } from "@motionscript/sdk";
|
|
2
|
+
import { type CoordinateMap } from "./coords.js";
|
|
3
|
+
import { type CurveValues } from "./curve.js";
|
|
4
|
+
/**
|
|
5
|
+
* What a coordinate system hands the plots and marks inside it: the map it was
|
|
6
|
+
* last laid out on, the curves it holds by id, and, under a plot, that plot.
|
|
7
|
+
* Inherited once, so it is a live object the system's layout keeps current.
|
|
8
|
+
*/
|
|
9
|
+
export interface GraphPlane {
|
|
10
|
+
readonly map: CoordinateMap;
|
|
11
|
+
readonly curves: ReadonlyMap<string, CurveValues>;
|
|
12
|
+
/** The curve a mark rides when it names none: the plot it sits in. */
|
|
13
|
+
readonly enclosing: CurveValues | null;
|
|
14
|
+
}
|
|
15
|
+
/** The plane of the nearest coordinate system: what a plot is laid out on. */
|
|
16
|
+
export declare const SYSTEM: _Context<GraphPlane | null>;
|
|
17
|
+
/** The plane under a plot: the system's, riding that plot. */
|
|
18
|
+
export declare const PLOT: _Context<GraphPlane | null>;
|
|
19
|
+
/** A plot's plane: the system it sits in, `null` outside one. */
|
|
20
|
+
export declare const SYSTEM_ENTRY: import("@motionscript/sdk").Type<GraphPlane | null, GraphPlane | null, true>;
|
|
21
|
+
/** A mark's plane: the plot or the system that lays it out, `null` outside both. */
|
|
22
|
+
export declare const PLANE_ENTRY: import("@motionscript/sdk").Type<GraphPlane | null, GraphPlane | null, true>;
|
|
23
|
+
/** A reference to the plot a mark reads, by id: a host offers the plots. */
|
|
24
|
+
export declare const PLOT_REF: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
25
|
+
declare class SystemPlane implements GraphPlane {
|
|
26
|
+
map: CoordinateMap;
|
|
27
|
+
curves: ReadonlyMap<string, CurveValues>;
|
|
28
|
+
readonly enclosing: null;
|
|
29
|
+
}
|
|
30
|
+
/** The plane a system provides, one per system: its `layout` writes the map and the curves into it. */
|
|
31
|
+
export declare function systemPlane(state: object): SystemPlane;
|
|
32
|
+
/** Lay `plane` out on `map`, holding the curves among `children`. */
|
|
33
|
+
export declare function settle(plane: SystemPlane, map: CoordinateMap, children: readonly ChildView[]): void;
|
|
34
|
+
/** The plane a plot provides the marks inside it, one per plot and system. */
|
|
35
|
+
export declare function plotPlane(plot: CurveValues, parent: GraphPlane | null): GraphPlane;
|
|
36
|
+
/**
|
|
37
|
+
* The curve a mark reads: the one `on` names in its system, or, naming none or
|
|
38
|
+
* one the system does not hold, the plot it sits in. `on` as the mark's own
|
|
39
|
+
* fields read a reference (a view) or its holder's layout does (an id). Outside
|
|
40
|
+
* any system a named curve is read wherever it is.
|
|
41
|
+
*/
|
|
42
|
+
export declare function curveFor(plane: GraphPlane | null, on: unknown, enclosing?: boolean): CurveValues | null;
|
|
43
|
+
/** The id a reference holds, read as an id or as a view of the node. */
|
|
44
|
+
export declare function refId(on: unknown): string;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/kit/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,SAAS,EAEd,KAAK,QAAQ,EAEb,KAAK,OAAO,IAAI,QAAQ,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAClD,sEAAsE;IACtE,QAAQ,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;CAC1C;AAED,8EAA8E;AAC9E,eAAO,MAAM,MAAM,6BAAuD,CAAC;AAC3E,8DAA8D;AAC9D,eAAO,MAAM,IAAI,6BAAqD,CAAC;AAIvE,iEAAiE;AACjE,eAAO,MAAM,YAAY,8EAGvB,CAAC;AAEH,oFAAoF;AACpF,eAAO,MAAM,WAAW,8EAGtB,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,QAAQ,iIAA2K,CAAC;AAIjM,cAAM,WAAY,YAAW,UAAU;IACnC,GAAG,EAAE,aAAa,CAAa;IAC/B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAa;IACrD,QAAQ,CAAC,SAAS,OAAQ;CAC7B;AAiBD,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAItD;AAED,qEAAqE;AACrE,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CAKnG;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,UAAU,CAIlF;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,UAAO,GAAG,WAAW,GAAG,IAAI,CAIpG;AAED,wEAAwE;AACxE,wBAAgB,KAAK,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAIzC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createContext, Types, } from "@motionscript/sdk";
|
|
2
|
+
import { PIXEL_MAP } from "./coords.js";
|
|
3
|
+
import { CURVE_KEYS, isCurve } from "./curve.js";
|
|
4
|
+
/** The plane of the nearest coordinate system: what a plot is laid out on. */
|
|
5
|
+
export const SYSTEM = createContext(null, "mathSystem");
|
|
6
|
+
/** The plane under a plot: the system's, riding that plot. */
|
|
7
|
+
export const PLOT = createContext(null, "mathPlot");
|
|
8
|
+
/** A plot's plane: the system it sits in, `null` outside one. */
|
|
9
|
+
export const SYSTEM_ENTRY = Types.custom(null, {
|
|
10
|
+
private: true,
|
|
11
|
+
inherit: (use) => use(SYSTEM),
|
|
12
|
+
});
|
|
13
|
+
/** A mark's plane: the plot or the system that lays it out, `null` outside both. */
|
|
14
|
+
export const PLANE_ENTRY = Types.custom(null, {
|
|
15
|
+
private: true,
|
|
16
|
+
inherit: (use) => use(PLOT) ?? use(SYSTEM),
|
|
17
|
+
});
|
|
18
|
+
/** A reference to the plot a mark reads, by id: a host offers the plots. */
|
|
19
|
+
export const PLOT_REF = Types.custom("", { kind: "nodeRef", nodeTypes: ["functionPlot"], animatable: false });
|
|
20
|
+
const NO_CURVES = new Map();
|
|
21
|
+
class SystemPlane {
|
|
22
|
+
map = PIXEL_MAP;
|
|
23
|
+
curves = NO_CURVES;
|
|
24
|
+
enclosing = null;
|
|
25
|
+
}
|
|
26
|
+
class PlotPlane {
|
|
27
|
+
parent;
|
|
28
|
+
enclosing;
|
|
29
|
+
constructor(parent, enclosing) {
|
|
30
|
+
this.parent = parent;
|
|
31
|
+
this.enclosing = enclosing;
|
|
32
|
+
}
|
|
33
|
+
get map() {
|
|
34
|
+
return this.parent?.map ?? PIXEL_MAP;
|
|
35
|
+
}
|
|
36
|
+
get curves() {
|
|
37
|
+
return this.parent?.curves ?? NO_CURVES;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const systems = new WeakMap();
|
|
41
|
+
const plots = new WeakMap();
|
|
42
|
+
/** The plane a system provides, one per system: its `layout` writes the map and the curves into it. */
|
|
43
|
+
export function systemPlane(state) {
|
|
44
|
+
let plane = systems.get(state);
|
|
45
|
+
if (!plane)
|
|
46
|
+
systems.set(state, (plane = new SystemPlane()));
|
|
47
|
+
return plane;
|
|
48
|
+
}
|
|
49
|
+
/** Lay `plane` out on `map`, holding the curves among `children`. */
|
|
50
|
+
export function settle(plane, map, children) {
|
|
51
|
+
plane.map = map;
|
|
52
|
+
const curves = new Map();
|
|
53
|
+
collectCurves(children, curves);
|
|
54
|
+
plane.curves = curves;
|
|
55
|
+
}
|
|
56
|
+
/** The plane a plot provides the marks inside it, one per plot and system. */
|
|
57
|
+
export function plotPlane(plot, parent) {
|
|
58
|
+
let plane = plots.get(plot);
|
|
59
|
+
if (!plane || plane.parent !== parent)
|
|
60
|
+
plots.set(plot, (plane = new PlotPlane(parent, plot)));
|
|
61
|
+
return plane;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The curve a mark reads: the one `on` names in its system, or, naming none or
|
|
65
|
+
* one the system does not hold, the plot it sits in. `on` as the mark's own
|
|
66
|
+
* fields read a reference (a view) or its holder's layout does (an id). Outside
|
|
67
|
+
* any system a named curve is read wherever it is.
|
|
68
|
+
*/
|
|
69
|
+
export function curveFor(plane, on, enclosing = true) {
|
|
70
|
+
if (!plane)
|
|
71
|
+
return isCurve(on) ? on.state : null;
|
|
72
|
+
const id = refId(on);
|
|
73
|
+
return (id === "" ? undefined : plane.curves.get(id)) ?? (enclosing ? plane.enclosing : null);
|
|
74
|
+
}
|
|
75
|
+
/** The id a reference holds, read as an id or as a view of the node. */
|
|
76
|
+
export function refId(on) {
|
|
77
|
+
if (typeof on === "string")
|
|
78
|
+
return on;
|
|
79
|
+
if (typeof on === "object" && on !== null && typeof on.id === "string")
|
|
80
|
+
return on.id;
|
|
81
|
+
return "";
|
|
82
|
+
}
|
|
83
|
+
function collectCurves(children, into) {
|
|
84
|
+
for (const child of children) {
|
|
85
|
+
if (child.id !== "" && CURVE_KEYS.includes(child.key))
|
|
86
|
+
into.set(child.id, child.state);
|
|
87
|
+
collectCurves(child.children, into);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -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AAI,CAAC,CAAC;IACxC,CAAC;AACL,CAAC","sourcesContent":["import {\n createContext,\n Types,\n type ChildView,\n type EntryOptions,\n type NodeView,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Context as _Context,\n} from \"@motionscript/sdk\";\nimport { PIXEL_MAP, type CoordinateMap } from \"./coords\";\nimport { CURVE_KEYS, isCurve, type CurveValues } from \"./curve\";\n\n/**\n * What a coordinate system hands the plots and marks inside it: the map it was\n * last laid out on, the curves it holds by id, and, under a plot, that plot.\n * Inherited once, so it is a live object the system's layout keeps current.\n */\nexport interface GraphPlane {\n readonly map: CoordinateMap;\n readonly curves: ReadonlyMap<string, CurveValues>;\n /** The curve a mark rides when it names none: the plot it sits in. */\n readonly enclosing: CurveValues | null;\n}\n\n/** The plane of the nearest coordinate system: what a plot is laid out on. */\nexport const SYSTEM = createContext<GraphPlane | null>(null, \"mathSystem\");\n/** The plane under a plot: the system's, riding that plot. */\nexport const PLOT = createContext<GraphPlane | null>(null, \"mathPlot\");\n\ntype Inherited = { readonly private: true };\n\n/** A plot's plane: the system it sits in, `null` outside one. */\nexport const SYSTEM_ENTRY = Types.custom<GraphPlane | null, GraphPlane | null, Inherited>(null, {\n private: true,\n inherit: (use) => use(SYSTEM),\n});\n\n/** A mark's plane: the plot or the system that lays it out, `null` outside both. */\nexport const PLANE_ENTRY = Types.custom<GraphPlane | null, GraphPlane | null, Inherited>(null, {\n private: true,\n inherit: (use) => use(PLOT) ?? use(SYSTEM),\n});\n\n/** A reference to the plot a mark reads, by id: a host offers the plots. */\nexport const PLOT_REF = Types.custom<string, NodeView | null, EntryOptions & { readonly nodeTypes: readonly string[] }>(\"\", { kind: \"nodeRef\", nodeTypes: [\"functionPlot\"], animatable: false });\n\nconst NO_CURVES: ReadonlyMap<string, CurveValues> = new Map();\n\nclass SystemPlane implements GraphPlane {\n map: CoordinateMap = PIXEL_MAP;\n curves: ReadonlyMap<string, CurveValues> = NO_CURVES;\n readonly enclosing = null;\n}\n\nclass PlotPlane implements GraphPlane {\n constructor(readonly parent: GraphPlane | null, readonly enclosing: CurveValues) { }\n\n get map(): CoordinateMap {\n return this.parent?.map ?? PIXEL_MAP;\n }\n\n get curves(): ReadonlyMap<string, CurveValues> {\n return this.parent?.curves ?? NO_CURVES;\n }\n}\n\nconst systems = new WeakMap<object, SystemPlane>();\nconst plots = new WeakMap<object, PlotPlane>();\n\n/** The plane a system provides, one per system: its `layout` writes the map and the curves into it. */\nexport function systemPlane(state: object): SystemPlane {\n let plane = systems.get(state);\n if (!plane) systems.set(state, (plane = new SystemPlane()));\n return plane;\n}\n\n/** Lay `plane` out on `map`, holding the curves among `children`. */\nexport function settle(plane: SystemPlane, map: CoordinateMap, children: readonly ChildView[]): void {\n plane.map = map;\n const curves = new Map<string, CurveValues>();\n collectCurves(children, curves);\n plane.curves = curves;\n}\n\n/** The plane a plot provides the marks inside it, one per plot and system. */\nexport function plotPlane(plot: CurveValues, parent: GraphPlane | null): GraphPlane {\n let plane = plots.get(plot);\n if (!plane || plane.parent !== parent) plots.set(plot, (plane = new PlotPlane(parent, plot)));\n return plane;\n}\n\n/**\n * The curve a mark reads: the one `on` names in its system, or, naming none or\n * one the system does not hold, the plot it sits in. `on` as the mark's own\n * fields read a reference (a view) or its holder's layout does (an id). Outside\n * any system a named curve is read wherever it is.\n */\nexport function curveFor(plane: GraphPlane | null, on: unknown, enclosing = true): CurveValues | null {\n if (!plane) return isCurve(on) ? on.state : null;\n const id = refId(on);\n return (id === \"\" ? undefined : plane.curves.get(id)) ?? (enclosing ? plane.enclosing : null);\n}\n\n/** The id a reference holds, read as an id or as a view of the node. */\nexport function refId(on: unknown): string {\n if (typeof on === \"string\") return on;\n if (typeof on === \"object\" && on !== null && typeof (on as { id?: unknown }).id === \"string\") return (on as { id: string }).id;\n return \"\";\n}\n\nfunction collectCurves(children: readonly ChildView[], into: Map<string, CurveValues>): void {\n for (const child of children) {\n if (child.id !== \"\" && CURVE_KEYS.includes(child.key)) into.set(child.id, child.state as unknown as CurveValues);\n collectCurves(child.children, into);\n }\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Graphics2D, type ChildView, type Extents, type Fill, type RenderContext, type Shadow, type Size2D, type Stroke, type Vector2 } from "@motionscript/sdk";
|
|
2
|
+
import { type CoordinateMap } from "./coords.js";
|
|
3
|
+
import type { GraphPlane } from "./graph.js";
|
|
4
|
+
/**
|
|
5
|
+
* A mark is a node drawn in graph coordinates: a plot, an area, an arrow
|
|
6
|
+
* between two graph points. It answers with runs of pixel points and is
|
|
7
|
+
* otherwise a shape, so its box is the tight box of its ink.
|
|
8
|
+
*
|
|
9
|
+
* Inside a coordinate system (or a plot) the holder lays it out on that ink,
|
|
10
|
+
* calling the mark's own trace with its map, and the mark's `x`/`y` are a shift
|
|
11
|
+
* in graph units. Outside one a graph unit is a pixel and `x`/`y` are the usual
|
|
12
|
+
* offset.
|
|
13
|
+
*/
|
|
14
|
+
/** What a mark is traced through: the map, its own `x`/`y` as a shift, and the plane it reads curves from. */
|
|
15
|
+
export interface MarkReading {
|
|
16
|
+
readonly map: CoordinateMap;
|
|
17
|
+
/** Zero outside a system, where `x`/`y` are pixels. */
|
|
18
|
+
readonly shift: Vector2;
|
|
19
|
+
readonly plane: GraphPlane | null;
|
|
20
|
+
}
|
|
21
|
+
/** The runs a mark draws, in pixels, y-up from the system's centre. */
|
|
22
|
+
export type Tracer<V> = (state: V, read: MarkReading) => Vector2[][];
|
|
23
|
+
/** What every mark's state reads: its place, and the plane it is laid out on. */
|
|
24
|
+
export interface MarkState {
|
|
25
|
+
readonly x: number;
|
|
26
|
+
readonly y: number;
|
|
27
|
+
readonly graph: GraphPlane | null;
|
|
28
|
+
}
|
|
29
|
+
/** `component`, declared a mark: a holder lays it out on the ink `trace` draws. Hand back the component. */
|
|
30
|
+
export declare function traced<C extends {
|
|
31
|
+
is(child: ChildView): boolean;
|
|
32
|
+
}>(component: C, trace: Tracer<never>): C;
|
|
33
|
+
/** The runs `child` draws on `plane`, or `undefined` for a child that is no mark. */
|
|
34
|
+
export declare function markRuns(child: ChildView, map: CoordinateMap, plane: GraphPlane): Vector2[][] | undefined;
|
|
35
|
+
/** How a mark's own fields read it: through its plane's map when one lays it out, through pixels when none does. */
|
|
36
|
+
export declare function reading(state: MarkState): MarkReading;
|
|
37
|
+
/** The size of a mark's ink: its box when a node other than a system lays it out. */
|
|
38
|
+
export declare function inkSize(runs: readonly (readonly Vector2[])[]): Size2D;
|
|
39
|
+
/** The centre of `runs`' ink in the map's pixels: where a mark's children are placed from. */
|
|
40
|
+
export declare function inkCentre(runs: readonly (readonly Vector2[])[]): Vector2;
|
|
41
|
+
/** A graph point in a mark's own frame, where a handle on it sits. */
|
|
42
|
+
export declare function ownPoint(read: MarkReading, runs: readonly (readonly Vector2[])[], point: Vector2): Vector2;
|
|
43
|
+
/** The graph point at `at` in a mark's own frame: {@link ownPoint} undone. */
|
|
44
|
+
export declare function graphPoint(read: MarkReading, runs: readonly (readonly Vector2[])[], at: Vector2): Vector2;
|
|
45
|
+
/** What a mark paints with: a shape's paints, any it withdrew left out. */
|
|
46
|
+
export interface MarkPaint {
|
|
47
|
+
readonly fill?: Fill;
|
|
48
|
+
readonly stroke?: Stroke;
|
|
49
|
+
readonly shadow: Shadow;
|
|
50
|
+
readonly start?: number;
|
|
51
|
+
readonly end?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface MarkOptions {
|
|
54
|
+
/** Whether each run is closed into an outline. */
|
|
55
|
+
readonly closed?: boolean;
|
|
56
|
+
/** Whether the fill is painted: a mark whose ink has no inside yet (an open line) says no. */
|
|
57
|
+
readonly fills?: boolean;
|
|
58
|
+
/** The stroke along the ink, when it is not the plain one. */
|
|
59
|
+
readonly ink?: (ctx: RenderContext, ink: Extents) => void;
|
|
60
|
+
}
|
|
61
|
+
/** One mark's outline, the same commands for each paint. */
|
|
62
|
+
export declare function markShape(runs: readonly (readonly Vector2[])[], s: MarkPaint, closed?: boolean): (() => Graphics2D) | null;
|
|
63
|
+
/**
|
|
64
|
+
* A mark's paint: the fill under the stroke along its ink, both before its
|
|
65
|
+
* children, so a point or a tangent riding a plot sits on the curve.
|
|
66
|
+
*/
|
|
67
|
+
export declare function drawMark(ctx: RenderContext, s: MarkPaint, runs: readonly (readonly Vector2[])[], options?: MarkOptions): void;
|
|
68
|
+
/** The stroke along a shape, casting the shadow when nothing fills it. */
|
|
69
|
+
export declare function strokeShape(ctx: RenderContext, shape: () => Graphics2D, s: MarkPaint): void;
|
|
70
|
+
/** A shadow is cast by the stroke when nothing visible fills the shape. */
|
|
71
|
+
export declare function castsShadow(s: MarkPaint): boolean;
|
|
72
|
+
//# sourceMappingURL=mark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark.d.ts","sourceRoot":"","sources":["../../src/kit/mark.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,MAAM,EAEX,KAAK,OAAO,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;GASG;AAEH,8GAA8G;AAC9G,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;IAC5B,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CACrC;AAED,uEAAuE;AACvE,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,EAAE,EAAE,CAAC;AAErE,iFAAiF;AACjF,MAAM,WAAW,SAAS;IACtB,QAAQ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C,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IACxB,kDAAkD;IAClD,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,8DAA8D;IAC9D,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7D;AAID,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,UAAQ,GAAG,CAAC,MAAM,UAAU,CAAC,GAAG,IAAI,CAMxH;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,aAAa,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CASjI;AAED,0EAA0E;AAC1E,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,UAAU,EAAE,CAAC,EAAE,SAAS,GAAG,IAAI,CAI3F;AAED,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,OAAO,CAGjD"}
|
package/dist/kit/mark.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Graphics2D, } from "@motionscript/sdk";
|
|
2
|
+
import { painted } from "./component.js";
|
|
3
|
+
import { PIXEL_MAP } from "./coords.js";
|
|
4
|
+
import { boundsOfRuns, runsToPath } from "./geometry.js";
|
|
5
|
+
const NO_SHIFT = { x: 0, y: 0 };
|
|
6
|
+
const tracers = [];
|
|
7
|
+
/** `component`, declared a mark: a holder lays it out on the ink `trace` draws. Hand back the component. */
|
|
8
|
+
export function traced(component, trace) {
|
|
9
|
+
tracers.push({ is: (child) => component.is(child), trace });
|
|
10
|
+
return component;
|
|
11
|
+
}
|
|
12
|
+
/** The runs `child` draws on `plane`, or `undefined` for a child that is no mark. */
|
|
13
|
+
export function markRuns(child, map, plane) {
|
|
14
|
+
const mark = tracers.find((entry) => entry.is(child));
|
|
15
|
+
if (!mark)
|
|
16
|
+
return undefined;
|
|
17
|
+
const state = child.state;
|
|
18
|
+
return mark.trace(state, { map, shift: { x: state.x, y: state.y }, plane });
|
|
19
|
+
}
|
|
20
|
+
/** How a mark's own fields read it: through its plane's map when one lays it out, through pixels when none does. */
|
|
21
|
+
export function reading(state) {
|
|
22
|
+
const plane = state.graph;
|
|
23
|
+
return plane ? { map: plane.map, shift: { x: state.x, y: state.y }, plane } : { map: PIXEL_MAP, shift: NO_SHIFT, plane: null };
|
|
24
|
+
}
|
|
25
|
+
/** The size of a mark's ink: its box when a node other than a system lays it out. */
|
|
26
|
+
export function inkSize(runs) {
|
|
27
|
+
const ink = boundsOfRuns(runs);
|
|
28
|
+
return ink ? { width: ink.maxX - ink.minX, height: ink.maxY - ink.minY } : { width: 0, height: 0 };
|
|
29
|
+
}
|
|
30
|
+
/** The centre of `runs`' ink in the map's pixels: where a mark's children are placed from. */
|
|
31
|
+
export function inkCentre(runs) {
|
|
32
|
+
const ink = boundsOfRuns(runs);
|
|
33
|
+
return ink ? { x: (ink.minX + ink.maxX) / 2, y: (ink.minY + ink.maxY) / 2 } : NO_SHIFT;
|
|
34
|
+
}
|
|
35
|
+
/** A graph point in a mark's own frame, where a handle on it sits. */
|
|
36
|
+
export function ownPoint(read, runs, point) {
|
|
37
|
+
const at = read.map.toPoint(point.x + read.shift.x, point.y + read.shift.y);
|
|
38
|
+
const centre = inkCentre(runs);
|
|
39
|
+
return { x: at.x - centre.x, y: at.y - centre.y };
|
|
40
|
+
}
|
|
41
|
+
/** The graph point at `at` in a mark's own frame: {@link ownPoint} undone. */
|
|
42
|
+
export function graphPoint(read, runs, at) {
|
|
43
|
+
const centre = inkCentre(runs);
|
|
44
|
+
const point = read.map.toCoords(at.x + centre.x, at.y + centre.y);
|
|
45
|
+
return { x: point.x - read.shift.x, y: point.y - read.shift.y };
|
|
46
|
+
}
|
|
47
|
+
const NONE = [];
|
|
48
|
+
/** One mark's outline, the same commands for each paint. */
|
|
49
|
+
export function markShape(runs, s, closed = false) {
|
|
50
|
+
const ink = boundsOfRuns(runs);
|
|
51
|
+
const data = runsToPath(runs, closed);
|
|
52
|
+
if (!ink || data.length === 0)
|
|
53
|
+
return null;
|
|
54
|
+
const centerBounds = [ink.minX, ink.minY, ink.maxX, ink.maxY];
|
|
55
|
+
return () => new Graphics2D().path({ data, centerBounds, start: s.start ?? 0, end: s.end ?? 1 });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A mark's paint: the fill under the stroke along its ink, both before its
|
|
59
|
+
* children, so a point or a tangent riding a plot sits on the curve.
|
|
60
|
+
*/
|
|
61
|
+
export function drawMark(ctx, s, runs, options = {}) {
|
|
62
|
+
const shape = markShape(runs, s, options.closed);
|
|
63
|
+
const fill = s.fill ?? NONE;
|
|
64
|
+
painted(ctx, () => {
|
|
65
|
+
if (shape && options.fills !== false)
|
|
66
|
+
ctx.draw(shape().shadow(s.shadow).fill(fill));
|
|
67
|
+
const ink = options.ink ? boundsOfRuns(runs) : null;
|
|
68
|
+
if (ink && options.ink)
|
|
69
|
+
options.ink(ctx, ink);
|
|
70
|
+
else if (shape)
|
|
71
|
+
strokeShape(ctx, shape, s);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** The stroke along a shape, casting the shadow when nothing fills it. */
|
|
75
|
+
export function strokeShape(ctx, shape, s) {
|
|
76
|
+
const stroke = (s.stroke ?? NONE);
|
|
77
|
+
if (stroke.length === 0)
|
|
78
|
+
return;
|
|
79
|
+
ctx.draw(castsShadow(s) ? shape().shadow(s.shadow).stroke(stroke) : shape().stroke(stroke));
|
|
80
|
+
}
|
|
81
|
+
/** A shadow is cast by the stroke when nothing visible fills the shape. */
|
|
82
|
+
export function castsShadow(s) {
|
|
83
|
+
if (s.shadow.length === 0)
|
|
84
|
+
return false;
|
|
85
|
+
return !(s.fill ?? NONE).some((layer) => (layer.opacity ?? 1) > 0);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=mark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark.js","sourceRoot":"","sources":["../../src/kit/mark.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,GAUb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAsB,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAgCtD,MAAM,QAAQ,GAAY,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAEzC,MAAM,OAAO,GAAoF,EAAE,CAAC;AAEpG,4GAA4G;AAC5G,MAAM,UAAU,MAAM,CAA8C,SAAY,EAAE,KAAoB;IAClG,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,QAAQ,CAAC,KAAgB,EAAE,GAAkB,EAAE,KAAiB;IAC5E,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,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AE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;aACzC,IAAI,KAAK;YAAE,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACP,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,WAAW,CAAC,GAAkB,EAAE,KAAuB,EAAE,CAAY;IACjF,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAqB,CAAC;IACtD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAChC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAChG,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,WAAW,CAAC,CAAY;IACpC,IAAK,CAAC,CAAC,MAAoB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvD,OAAO,CAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAA4B,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACnG,CAAC","sourcesContent":["import {\n Graphics2D,\n type ChildView,\n type Extents,\n type Fill,\n type RenderContext,\n type Shadow,\n type Size2D,\n type Stroke,\n type StrokeResolved,\n type Vector2,\n} from \"@motionscript/sdk\";\nimport { painted } from \"./component\";\nimport { PIXEL_MAP, type CoordinateMap } from \"./coords\";\nimport { boundsOfRuns, runsToPath } from \"./geometry\";\nimport type { GraphPlane } from \"./graph\";\n\n/**\n * A mark is a node drawn in graph coordinates: a plot, an area, an arrow\n * between two graph points. It answers with runs of pixel points and is\n * otherwise a shape, so its box is the tight box of its ink.\n *\n * Inside a coordinate system (or a plot) the holder lays it out on that ink,\n * calling the mark's own trace with its map, and the mark's `x`/`y` are a shift\n * in graph units. Outside one a graph unit is a pixel and `x`/`y` are the usual\n * offset.\n */\n\n/** What a mark is traced through: the map, its own `x`/`y` as a shift, and the plane it reads curves from. */\nexport interface MarkReading {\n readonly map: CoordinateMap;\n /** Zero outside a system, where `x`/`y` are pixels. */\n readonly shift: Vector2;\n readonly plane: GraphPlane | null;\n}\n\n/** The runs a mark draws, in pixels, y-up from the system's centre. */\nexport type Tracer<V> = (state: V, read: MarkReading) => Vector2[][];\n\n/** What every mark's state reads: its place, and the plane it is laid out on. */\nexport interface MarkState {\n readonly x: number;\n readonly y: number;\n readonly graph: GraphPlane | null;\n}\n\nconst NO_SHIFT: Vector2 = { x: 0, y: 0 };\n\nconst tracers: { readonly is: (child: ChildView) => boolean; readonly trace: Tracer<never> }[] = [];\n\n/** `component`, declared a mark: a holder lays it out on the ink `trace` draws. Hand back the component. */\nexport function traced<C extends { is(child: ChildView): boolean }>(component: C, trace: Tracer<never>): C {\n tracers.push({ is: (child) => component.is(child), trace });\n return component;\n}\n\n/** The runs `child` draws on `plane`, or `undefined` for a child that is no mark. */\nexport function markRuns(child: ChildView, map: CoordinateMap, plane: GraphPlane): Vector2[][] | undefined {\n const mark = tracers.find((entry) => entry.is(child));\n if (!mark) return undefined;\n const state = child.state as unknown as MarkState;\n return (mark.trace as Tracer<MarkState>)(state, { map, shift: { x: state.x, y: state.y }, plane });\n}\n\n/** How a mark's own fields read it: through its plane's map when one lays it out, through pixels when none does. */\nexport function reading(state: MarkState): MarkReading {\n const plane = state.graph;\n return plane ? { map: plane.map, shift: { x: state.x, y: state.y }, plane } : { map: PIXEL_MAP, shift: NO_SHIFT, plane: null };\n}\n\n/** The size of a mark's ink: its box when a node other than a system lays it out. */\nexport function inkSize(runs: readonly (readonly Vector2[])[]): Size2D {\n const ink = boundsOfRuns(runs);\n return ink ? { width: ink.maxX - ink.minX, height: ink.maxY - ink.minY } : { width: 0, height: 0 };\n}\n\n/** The centre of `runs`' ink in the map's pixels: where a mark's children are placed from. */\nexport function inkCentre(runs: readonly (readonly Vector2[])[]): Vector2 {\n const ink = boundsOfRuns(runs);\n return ink ? { x: (ink.minX + ink.maxX) / 2, y: (ink.minY + ink.maxY) / 2 } : NO_SHIFT;\n}\n\n/** A graph point in a mark's own frame, where a handle on it sits. */\nexport function ownPoint(read: MarkReading, runs: readonly (readonly Vector2[])[], point: Vector2): Vector2 {\n const at = read.map.toPoint(point.x + read.shift.x, point.y + read.shift.y);\n const centre = inkCentre(runs);\n return { x: at.x - centre.x, y: at.y - centre.y };\n}\n\n/** The graph point at `at` in a mark's own frame: {@link ownPoint} undone. */\nexport function graphPoint(read: MarkReading, runs: readonly (readonly Vector2[])[], at: Vector2): Vector2 {\n const centre = inkCentre(runs);\n const point = read.map.toCoords(at.x + centre.x, at.y + centre.y);\n return { x: point.x - read.shift.x, y: point.y - read.shift.y };\n}\n\n/** What a mark paints with: a shape's paints, any it withdrew left out. */\nexport interface MarkPaint {\n readonly fill?: Fill;\n readonly stroke?: Stroke;\n readonly shadow: Shadow;\n readonly start?: number;\n readonly end?: number;\n}\n\nexport interface MarkOptions {\n /** Whether each run is closed into an outline. */\n readonly closed?: boolean;\n /** Whether the fill is painted: a mark whose ink has no inside yet (an open line) says no. */\n readonly fills?: boolean;\n /** The stroke along the ink, when it is not the plain one. */\n readonly ink?: (ctx: RenderContext, ink: Extents) => void;\n}\n\nconst NONE: never[] = [];\n\n/** One mark's outline, the same commands for each paint. */\nexport function markShape(runs: readonly (readonly Vector2[])[], s: MarkPaint, closed = false): (() => Graphics2D) | null {\n const ink = boundsOfRuns(runs);\n const data = runsToPath(runs, closed);\n if (!ink || data.length === 0) return null;\n const centerBounds: [number, number, number, number] = [ink.minX, ink.minY, ink.maxX, ink.maxY];\n return () => new Graphics2D().path({ data, centerBounds, start: s.start ?? 0, end: s.end ?? 1 });\n}\n\n/**\n * A mark's paint: the fill under the stroke along its ink, both before its\n * children, so a point or a tangent riding a plot sits on the curve.\n */\nexport function drawMark(ctx: RenderContext, s: MarkPaint, runs: readonly (readonly Vector2[])[], options: MarkOptions = {}): void {\n const shape = markShape(runs, s, options.closed);\n const fill = s.fill ?? NONE;\n painted(ctx, () => {\n if (shape && options.fills !== false) ctx.draw(shape().shadow(s.shadow).fill(fill));\n const ink = options.ink ? boundsOfRuns(runs) : null;\n if (ink && options.ink) options.ink(ctx, ink);\n else if (shape) strokeShape(ctx, shape, s);\n });\n}\n\n/** The stroke along a shape, casting the shadow when nothing fills it. */\nexport function strokeShape(ctx: RenderContext, shape: () => Graphics2D, s: MarkPaint): void {\n const stroke = (s.stroke ?? NONE) as StrokeResolved[];\n if (stroke.length === 0) return;\n ctx.draw(castsShadow(s) ? shape().shadow(s.shadow).stroke(stroke) : shape().stroke(stroke));\n}\n\n/** A shadow is cast by the stroke when nothing visible fills the shape. */\nexport function castsShadow(s: MarkPaint): boolean {\n if ((s.shadow as unknown[]).length === 0) return false;\n return !((s.fill ?? NONE) as { opacity?: number }[]).some((layer) => (layer.opacity ?? 1) > 0);\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Fill, type FillResolved } from "@motionscript/sdk";
|
|
2
|
+
/** A paint for one part of a node, named the way the node names its parts: a formula's term, a graph's vertex or edge. */
|
|
3
|
+
export interface PartFill {
|
|
4
|
+
part: string;
|
|
5
|
+
fill: Fill;
|
|
6
|
+
/** Which of the places the part is written, counted from 1; 0 is all of them. */
|
|
7
|
+
occurrence?: number;
|
|
8
|
+
/** How far from the node's own paint to `fill`, 0 to 1. A tween's state: an author leaves it out. */
|
|
9
|
+
mix?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PartFillResolved {
|
|
12
|
+
part: string;
|
|
13
|
+
fill: FillResolved[];
|
|
14
|
+
occurrence: number;
|
|
15
|
+
mix: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function readPartFills(value: readonly PartFill[] | null | undefined): PartFillResolved[];
|
|
18
|
+
export declare function lerpPartFills(from: PartFillResolved[], to: PartFillResolved[], t: number): PartFillResolved[];
|
|
19
|
+
/** Each part fill with its own key, the one in place of an earlier one for the same part and occurrence. */
|
|
20
|
+
export declare function withPartFill(fills: readonly PartFillResolved[], entry: PartFill): PartFill[];
|
|
21
|
+
/** `base` with a part's fill laid over it while it arrives, in place of it once it has. */
|
|
22
|
+
export declare function partPaint(base: FillResolved[], entry: PartFillResolved | undefined): FillResolved[];
|
|
23
|
+
//# sourceMappingURL=part-fills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"part-fills.d.ts","sourceRoot":"","sources":["../../src/kit/part-fills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,IAAI,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtF,0HAA0H;AAC1H,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qGAAqG;IACrG,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACf;AAID,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,gBAAgB,EAAE,CAQ/F;AAKD,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAa7G;AAED,4GAA4G;AAC5G,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,EAAE,KAAK,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAG5F;AAED,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,gBAAgB,GAAG,SAAS,GAAG,YAAY,EAAE,CAInG"}
|