@motionscript/math 0.1.0-alpha.5 → 0.1.0-alpha.7
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 +28 -0
- package/README.md +39 -33
- package/dist/annotate/angle-mark.d.ts +77 -27
- package/dist/annotate/angle-mark.d.ts.map +1 -1
- package/dist/annotate/angle-mark.js +80 -115
- package/dist/annotate/angle-mark.js.map +1 -1
- package/dist/annotate/curly-brace.d.ts +94 -25
- package/dist/annotate/curly-brace.d.ts.map +1 -1
- package/dist/annotate/curly-brace.js +85 -100
- package/dist/annotate/curly-brace.js.map +1 -1
- package/dist/annotate/emphasis-mark.d.ts +69 -9
- package/dist/annotate/emphasis-mark.d.ts.map +1 -1
- package/dist/annotate/emphasis-mark.js +33 -34
- package/dist/annotate/emphasis-mark.js.map +1 -1
- package/dist/browser/chunks/chunk-ABYBW64J.js +2 -0
- package/dist/browser/chunks/chunk-ABYBW64J.js.map +7 -0
- package/dist/browser/chunks/chunk-K77KLQX4.js +2 -0
- package/dist/browser/chunks/chunk-K77KLQX4.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/tex.js +1 -1
- package/dist/browser/tex.js.map +2 -2
- package/dist/engine.d.ts +26 -19
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +17 -14
- package/dist/engine.js.map +1 -1
- 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/curve.d.ts +22 -11
- package/dist/kit/curve.d.ts.map +1 -1
- package/dist/kit/curve.js +25 -18
- package/dist/kit/curve.js.map +1 -1
- package/dist/kit/field-mark.d.ts +56 -35
- package/dist/kit/field-mark.d.ts.map +1 -1
- package/dist/kit/field-mark.js +100 -120
- package/dist/kit/field-mark.js.map +1 -1
- package/dist/kit/follow.d.ts +67 -29
- package/dist/kit/follow.d.ts.map +1 -1
- package/dist/kit/follow.js +114 -110
- package/dist/kit/follow.js.map +1 -1
- package/dist/kit/furniture.d.ts +3 -1
- package/dist/kit/furniture.d.ts.map +1 -1
- package/dist/kit/furniture.js +5 -0
- package/dist/kit/furniture.js.map +1 -1
- 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 +64 -39
- package/dist/kit/mark.d.ts.map +1 -1
- package/dist/kit/mark.js +80 -96
- package/dist/kit/mark.js.map +1 -1
- package/dist/kit/place.d.ts +10 -8
- package/dist/kit/place.d.ts.map +1 -1
- package/dist/kit/place.js +28 -30
- package/dist/kit/place.js.map +1 -1
- package/dist/kit/system.d.ts +27 -29
- package/dist/kit/system.d.ts.map +1 -1
- package/dist/kit/system.js +62 -58
- package/dist/kit/system.js.map +1 -1
- package/dist/kit/withdrawn.d.ts +3 -3
- package/dist/kit/withdrawn.js +3 -3
- package/dist/kit/withdrawn.js.map +1 -1
- package/dist/marks/curve-area.d.ts +37 -18
- package/dist/marks/curve-area.d.ts.map +1 -1
- package/dist/marks/curve-area.js +50 -73
- package/dist/marks/curve-area.js.map +1 -1
- package/dist/marks/drop-lines.d.ts +45 -10
- package/dist/marks/drop-lines.d.ts.map +1 -1
- package/dist/marks/drop-lines.js +37 -52
- package/dist/marks/drop-lines.js.map +1 -1
- package/dist/marks/plot-point.d.ts +56 -20
- package/dist/marks/plot-point.d.ts.map +1 -1
- package/dist/marks/plot-point.js +65 -91
- package/dist/marks/plot-point.js.map +1 -1
- package/dist/marks/riemann-sum.d.ts +47 -26
- package/dist/marks/riemann-sum.d.ts.map +1 -1
- package/dist/marks/riemann-sum.js +57 -85
- package/dist/marks/riemann-sum.js.map +1 -1
- package/dist/marks/tangent-line.d.ts +58 -14
- package/dist/marks/tangent-line.d.ts.map +1 -1
- package/dist/marks/tangent-line.js +73 -87
- package/dist/marks/tangent-line.js.map +1 -1
- package/dist/marks/vector-arrow.d.ts +48 -20
- package/dist/marks/vector-arrow.d.ts.map +1 -1
- package/dist/marks/vector-arrow.js +58 -78
- package/dist/marks/vector-arrow.js.map +1 -1
- package/dist/nodes.d.ts +13 -5
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -6
- package/dist/nodes.js.map +1 -1
- package/dist/plots/function-plot.d.ts +135 -43
- package/dist/plots/function-plot.d.ts.map +1 -1
- package/dist/plots/function-plot.js +146 -177
- package/dist/plots/function-plot.js.map +1 -1
- package/dist/plots/points-plot.d.ts +55 -19
- package/dist/plots/points-plot.d.ts.map +1 -1
- package/dist/plots/points-plot.js +31 -58
- package/dist/plots/points-plot.js.map +1 -1
- package/dist/plots/stream-lines.d.ts +60 -19
- package/dist/plots/stream-lines.d.ts.map +1 -1
- package/dist/plots/stream-lines.js +60 -79
- package/dist/plots/stream-lines.js.map +1 -1
- package/dist/plots/traced-path.d.ts +54 -15
- package/dist/plots/traced-path.d.ts.map +1 -1
- package/dist/plots/traced-path.js +33 -48
- package/dist/plots/traced-path.js.map +1 -1
- package/dist/plots/vector-field.d.ts +48 -11
- package/dist/plots/vector-field.d.ts.map +1 -1
- package/dist/plots/vector-field.js +50 -64
- package/dist/plots/vector-field.js.map +1 -1
- package/dist/structures/network-graph.d.ts +140 -49
- package/dist/structures/network-graph.d.ts.map +1 -1
- package/dist/structures/network-graph.js +168 -217
- package/dist/structures/network-graph.js.map +1 -1
- package/dist/structures/sample-space.d.ts +90 -38
- package/dist/structures/sample-space.d.ts.map +1 -1
- package/dist/structures/sample-space.js +132 -170
- package/dist/structures/sample-space.js.map +1 -1
- package/dist/systems/axes2d.d.ts +159 -37
- package/dist/systems/axes2d.d.ts.map +1 -1
- package/dist/systems/axes2d.js +147 -183
- package/dist/systems/axes2d.js.map +1 -1
- package/dist/systems/number-line.d.ts +80 -28
- package/dist/systems/number-line.d.ts.map +1 -1
- package/dist/systems/number-line.js +82 -118
- package/dist/systems/number-line.js.map +1 -1
- package/dist/systems/number-plane.d.ts +140 -31
- package/dist/systems/number-plane.d.ts.map +1 -1
- package/dist/systems/number-plane.js +142 -149
- package/dist/systems/number-plane.js.map +1 -1
- package/dist/systems/polar-plane.d.ts +76 -26
- package/dist/systems/polar-plane.d.ts.map +1 -1
- package/dist/systems/polar-plane.js +107 -133
- package/dist/systems/polar-plane.js.map +1 -1
- package/dist/tex/index.d.ts.map +1 -1
- package/dist/tex/index.js +1 -0
- package/dist/tex/index.js.map +1 -1
- package/dist/tex/matrix.d.ts +88 -18
- package/dist/tex/matrix.d.ts.map +1 -1
- package/dist/tex/matrix.js +33 -50
- package/dist/tex/matrix.js.map +1 -1
- package/dist/tex/node.d.ts +84 -201
- package/dist/tex/node.d.ts.map +1 -1
- package/dist/tex/node.js +23 -593
- package/dist/tex/node.js.map +1 -1
- 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 +214 -54
- package/dist/three/axes3d.d.ts.map +1 -1
- package/dist/three/axes3d.js +163 -204
- package/dist/three/axes3d.js.map +1 -1
- package/dist/three/curve-plot3d.d.ts +108 -42
- package/dist/three/curve-plot3d.d.ts.map +1 -1
- package/dist/three/curve-plot3d.js +97 -132
- package/dist/three/curve-plot3d.js.map +1 -1
- 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/plot-point3d.d.ts +85 -12
- package/dist/three/plot-point3d.d.ts.map +1 -1
- package/dist/three/plot-point3d.js +27 -53
- package/dist/three/plot-point3d.js.map +1 -1
- package/dist/three/space.d.ts +17 -2
- package/dist/three/space.d.ts.map +1 -1
- package/dist/three/space.js +19 -8
- package/dist/three/space.js.map +1 -1
- package/dist/three/surface-plot3d.d.ts +176 -49
- package/dist/three/surface-plot3d.d.ts.map +1 -1
- package/dist/three/surface-plot3d.js +227 -261
- package/dist/three/surface-plot3d.js.map +1 -1
- package/dist/three/vector-arrow3d.d.ts +87 -16
- package/dist/three/vector-arrow3d.d.ts.map +1 -1
- package/dist/three/vector-arrow3d.js +48 -67
- package/dist/three/vector-arrow3d.js.map +1 -1
- package/package.json +4 -4
- package/src/annotate/angle-mark.ts +95 -105
- package/src/annotate/curly-brace.ts +107 -85
- package/src/annotate/emphasis-mark.ts +55 -26
- package/src/engine.ts +35 -21
- package/src/kit/component.ts +57 -0
- package/src/kit/curve.ts +38 -20
- package/src/kit/field-mark.ts +124 -108
- package/src/kit/follow.ts +146 -120
- package/src/kit/furniture.ts +6 -1
- package/src/kit/graph.ts +116 -0
- package/src/kit/mark.ts +135 -114
- package/src/kit/place.ts +32 -56
- package/src/kit/system.ts +77 -71
- package/src/kit/withdrawn.ts +3 -3
- package/src/marks/curve-area.ts +65 -65
- package/src/marks/drop-lines.ts +50 -42
- package/src/marks/plot-point.ts +77 -82
- package/src/marks/riemann-sum.ts +73 -72
- package/src/marks/tangent-line.ts +87 -71
- package/src/marks/vector-arrow.ts +73 -73
- package/src/nodes.ts +41 -5
- package/src/plots/function-plot.ts +155 -171
- package/src/plots/points-plot.ts +46 -50
- package/src/plots/stream-lines.ts +75 -66
- package/src/plots/traced-path.ts +51 -33
- package/src/plots/vector-field.ts +68 -49
- package/src/structures/network-graph.ts +168 -185
- package/src/structures/sample-space.ts +149 -148
- package/src/systems/axes2d.ts +165 -156
- package/src/systems/number-line.ts +91 -92
- package/src/systems/number-plane.ts +149 -120
- package/src/systems/polar-plane.ts +117 -116
- package/src/tex/index.ts +2 -1
- package/src/tex/matrix.ts +62 -40
- package/src/tex/node.ts +54 -621
- package/src/tex/typeset.ts +461 -0
- package/src/three/axes3d.ts +187 -160
- package/src/three/curve-plot3d.ts +107 -110
- package/src/three/entries.ts +42 -0
- package/src/three/plot-point3d.ts +42 -45
- package/src/three/space.ts +34 -9
- package/src/three/surface-plot3d.ts +312 -323
- package/src/three/vector-arrow3d.ts +65 -54
- package/dist/browser/chunks/chunk-3GJB6AVO.js +0 -2
- package/dist/browser/chunks/chunk-3GJB6AVO.js.map +0 -7
- package/dist/browser/chunks/chunk-D5WHCVBC.js +0 -2
- package/dist/browser/chunks/chunk-D5WHCVBC.js.map +0 -7
- package/dist/browser/chunks/chunk-WL4KEX7Y.js +0 -2
- package/dist/browser/chunks/chunk-WL4KEX7Y.js.map +0 -7
- package/src/kit/placement.ts +0 -8
package/dist/kit/system.js
CHANGED
|
@@ -1,67 +1,71 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Graphics2D, insetsOps, Paint, provides, } from "@motionscript/sdk";
|
|
2
|
+
import { settle, SYSTEM, systemPlane } from "./graph.js";
|
|
2
3
|
import { openPlane, placeOnMap } from "./place.js";
|
|
3
|
-
const NO_CONTENT = { width: 0, height: 0 };
|
|
4
|
-
const CENTRE = { x: 0, y: 0 };
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
* the system's units and the child keeps
|
|
8
|
-
* on a graph: a dot, a label, an image. A
|
|
9
|
-
* system's map instead and laid out on its ink.
|
|
5
|
+
* What a coordinate system shares: a node whose children sit in its graph
|
|
6
|
+
* coordinates. A child's `x`/`y` are in the system's units and the child keeps
|
|
7
|
+
* its own size, so anything can be put on a graph: a dot, a label, an image. A
|
|
8
|
+
* mark is drawn through the system's map instead and laid out on its ink.
|
|
10
9
|
*
|
|
11
10
|
* The system's `stroke` is its axis line (so `endCap` is the tip) and its `fill`
|
|
12
11
|
* the backdrop. Ticks, grid and labels are drawing ops, never child nodes: a
|
|
13
12
|
* document's children would otherwise share their indices with them.
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
14
|
+
const CENTRE = { x: 0, y: 0 };
|
|
15
|
+
/** The plot area: the box less its padding, y-up from the box's centre. */
|
|
16
|
+
export function plotArea(size, padding) {
|
|
17
|
+
const inner = insetsOps.insetBounds(size.width, size.height, padding);
|
|
18
|
+
return {
|
|
19
|
+
minX: inner.x - inner.width / 2,
|
|
20
|
+
maxX: inner.x + inner.width / 2,
|
|
21
|
+
minY: -inner.y - inner.height / 2,
|
|
22
|
+
maxY: -inner.y + inner.height / 2,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** A system's map at a laid-out `size`. */
|
|
26
|
+
export function systemMap(size, state, mapFor) {
|
|
27
|
+
return mapFor(plotArea(size, state.padding), state);
|
|
28
|
+
}
|
|
29
|
+
/** A system is the size it is given: its children are placed in it, not measured into it. */
|
|
30
|
+
export function systemSize(state) {
|
|
31
|
+
const { left, right, top, bottom } = state.padding;
|
|
32
|
+
return { width: left + right, height: top + bottom };
|
|
33
|
+
}
|
|
34
|
+
/** What a system hands its subtree: its plane, which its layout keeps current. */
|
|
35
|
+
export function systemProvides(state) {
|
|
36
|
+
return [provides(SYSTEM, systemPlane(state))];
|
|
37
|
+
}
|
|
38
|
+
/** Lay a system's children out on its map. */
|
|
39
|
+
export function systemLayout(size, state, children, mapFor) {
|
|
40
|
+
const map = systemMap(size, state, mapFor);
|
|
41
|
+
const plane = systemPlane(state);
|
|
42
|
+
settle(plane, map, children);
|
|
43
|
+
const inner = insetsOps.insetBounds(size.width, size.height, state.padding);
|
|
44
|
+
return placeOnMap(children, map, CENTRE, inner, plane);
|
|
45
|
+
}
|
|
46
|
+
/** Where a child dropped on a system would sit. */
|
|
47
|
+
export function systemOpenPlane(size, state, mapFor) {
|
|
48
|
+
return openPlane(systemMap(size, state, mapFor), CENTRE);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A system's paint: the backdrop, then the furniture under its children, kept
|
|
52
|
+
* in the plot area where the map spills from it, then the children, confined
|
|
53
|
+
* to the plot area when `clip` is set. The stroke is the axis line, drawn with
|
|
54
|
+
* the furniture: painted after the children it would land over them.
|
|
55
|
+
*/
|
|
56
|
+
export function drawSystem(ctx, state, map, furniture) {
|
|
57
|
+
const { width, height } = ctx.size;
|
|
58
|
+
const { minX, minY, maxX, maxY } = map.area;
|
|
59
|
+
const area = new Graphics2D().rect({ x: (minX + maxX) / 2, y: (minY + maxY) / 2, width: maxX - minX, height: maxY - minY });
|
|
60
|
+
ctx.inFront(() => {
|
|
61
|
+
ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width, height }).shadow(state.shadow).fill(state.fill));
|
|
62
|
+
const parts = furniture(map);
|
|
63
|
+
if (map.spills)
|
|
64
|
+
ctx.clip(area, () => ctx.draw(parts));
|
|
65
|
+
else
|
|
66
|
+
ctx.draw(parts);
|
|
67
|
+
});
|
|
68
|
+
// No shape of its own to paint here; the plot area is what clips the children and what picking tests.
|
|
69
|
+
Paint.draw(ctx, state, null, { clipShape: area });
|
|
66
70
|
}
|
|
67
71
|
//# sourceMappingURL=system.js.map
|
package/dist/kit/system.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/kit/system.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,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;IAC5H,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE;QACb,GAAG,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACrG,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,GAAG,CAAC,MAAM;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;;YACjD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,sGAAsG;IACtG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,KAAoC,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACrF,CAAC","sourcesContent":["import {\r\n Graphics2D,\r\n insetsOps,\r\n Paint,\r\n provides,\r\n type ChildPlane,\r\n type ChildView,\r\n type Extents,\r\n type InsetsResolved,\r\n type Placement2D,\r\n type Provided,\r\n type RenderContext,\r\n type Shadow,\r\n type Fill,\r\n type Size2D,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport type { CoordinateMap } from \"./coords\";\r\nimport { settle, SYSTEM, systemPlane } from \"./graph\";\r\nimport { openPlane, placeOnMap } from \"./place\";\r\n\r\n/**\r\n * What a coordinate system shares: a node whose children sit in its graph\r\n * coordinates. A child's `x`/`y` are in the system's units and the child keeps\r\n * its own size, so anything can be put on a graph: a dot, a label, an image. A\r\n * mark is drawn through the system's map instead and laid out on its ink.\r\n *\r\n * The system's `stroke` is its axis line (so `endCap` is the tip) and its `fill`\r\n * the backdrop. Ticks, grid and labels are drawing ops, never child nodes: a\r\n * document's children would otherwise share their indices with them.\r\n */\r\n\r\nconst CENTRE: Vector2 = { x: 0, y: 0 };\r\n\r\n/** What a system's helpers read of its state. */\r\nexport interface SystemState {\r\n readonly padding: InsetsResolved;\r\n readonly fill: Fill;\r\n readonly shadow: Shadow;\r\n readonly clip: boolean;\r\n}\r\n\r\n/** How a system's graph values land on its plot area. */\r\nexport type MapFor<S> = (area: Extents, state: S) => CoordinateMap;\r\n\r\n/** The plot area: the box less its padding, y-up from the box's centre. */\r\nexport function plotArea(size: Size2D, padding: InsetsResolved): Extents {\r\n const inner = insetsOps.insetBounds(size.width, size.height, padding);\r\n return {\r\n minX: inner.x - inner.width / 2,\r\n maxX: inner.x + inner.width / 2,\r\n minY: -inner.y - inner.height / 2,\r\n maxY: -inner.y + inner.height / 2,\r\n };\r\n}\r\n\r\n/** A system's map at a laid-out `size`. */\r\nexport function systemMap<S extends SystemState>(size: Size2D, state: S, mapFor: MapFor<S>): CoordinateMap {\r\n return mapFor(plotArea(size, state.padding), state);\r\n}\r\n\r\n/** A system is the size it is given: its children are placed in it, not measured into it. */\r\nexport function systemSize(state: SystemState): Size2D {\r\n const { left, right, top, bottom } = state.padding;\r\n return { width: left + right, height: top + bottom };\r\n}\r\n\r\n/** What a system hands its subtree: its plane, which its layout keeps current. */\r\nexport function systemProvides(state: object): readonly Provided[] {\r\n return [provides(SYSTEM, systemPlane(state))];\r\n}\r\n\r\n/** Lay a system's children out on its map. */\r\nexport function systemLayout<S extends SystemState>(size: Size2D, state: S, children: readonly ChildView[], mapFor: MapFor<S>): Placement2D[] {\r\n const map = systemMap(size, state, mapFor);\r\n const plane = systemPlane(state);\r\n settle(plane, map, children);\r\n const inner = insetsOps.insetBounds(size.width, size.height, state.padding);\r\n return placeOnMap(children, map, CENTRE, inner, plane);\r\n}\r\n\r\n/** Where a child dropped on a system would sit. */\r\nexport function systemOpenPlane<S extends SystemState>(size: Size2D, state: S, mapFor: MapFor<S>): ChildPlane {\r\n return openPlane(systemMap(size, state, mapFor), CENTRE);\r\n}\r\n\r\n/**\r\n * A system's paint: the backdrop, then the furniture under its children, kept\r\n * in the plot area where the map spills from it, then the children, confined\r\n * to the plot area when `clip` is set. The stroke is the axis line, drawn with\r\n * the furniture: painted after the children it would land over them.\r\n */\r\nexport function drawSystem(ctx: RenderContext, state: SystemState, map: CoordinateMap, furniture: (map: CoordinateMap) => Graphics2D[]): void {\r\n const { width, height } = ctx.size;\r\n const { minX, minY, maxX, maxY } = map.area;\r\n const area = new Graphics2D().rect({ x: (minX + maxX) / 2, y: (minY + maxY) / 2, width: maxX - minX, height: maxY - minY });\r\n ctx.inFront(() => {\r\n ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width, height }).shadow(state.shadow).fill(state.fill));\r\n const parts = furniture(map);\r\n if (map.spills) ctx.clip(area, () => ctx.draw(parts));\r\n else ctx.draw(parts);\r\n });\r\n // No shape of its own to paint here; the plot area is what clips the children and what picking tests.\r\n Paint.draw(ctx, state as unknown as Paint.PaintState, null, { clipShape: area });\r\n}\r\n"]}
|
package/dist/kit/withdrawn.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The paint entries and commands a math node may have no use for: a node that
|
|
3
|
+
* is only a line has no fill, an area no outline, and one that reveals itself
|
|
4
|
+
* in its own way no outline trim.
|
|
5
5
|
*/
|
|
6
6
|
export declare const FILL_PAINT: readonly ["fill", "fillTo"];
|
|
7
7
|
export declare const STROKE_PAINT: readonly ["stroke", "strokeTo"];
|
package/dist/kit/withdrawn.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The paint entries and commands a math node may have no use for: a node that
|
|
3
|
+
* is only a line has no fill, an area no outline, and one that reveals itself
|
|
4
|
+
* in its own way no outline trim.
|
|
5
5
|
*/
|
|
6
6
|
export const FILL_PAINT = ["fill", "fillTo"];
|
|
7
7
|
export const STROKE_PAINT = ["stroke", "strokeTo"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withdrawn.js","sourceRoot":"","sources":["../../src/kit/withdrawn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAU,CAAC;AAC5D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAU,CAAC","sourcesContent":["/**\r\n *
|
|
1
|
+
{"version":3,"file":"withdrawn.js","sourceRoot":"","sources":["../../src/kit/withdrawn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAU,CAAC;AAC5D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAU,CAAC","sourcesContent":["/**\r\n * The paint entries and commands a math node may have no use for: a node that\r\n * is only a line has no fill, an area no outline, and one that reveals itself\r\n * in its own way no outline trim.\r\n */\r\nexport const FILL_PAINT = [\"fill\", \"fillTo\"] as const;\r\nexport const STROKE_PAINT = [\"stroke\", \"strokeTo\"] as const;\r\nexport const OUTLINE_TRIM = [\"start\", \"end\", \"progressTo\", \"flash\"] as const;\r\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type {
|
|
3
|
-
import { Mark } from "../kit/mark.js";
|
|
1
|
+
import { type NodeOf, type NodeView, type PaintProps, type Fill as _Fill, type FillResolved as _FillResolved, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved } from "@motionscript/sdk";
|
|
2
|
+
import type { Interval } from "../kit/coords.js";
|
|
4
3
|
export interface CurveAreaProps extends PaintProps {
|
|
5
4
|
on?: string;
|
|
6
5
|
under?: string;
|
|
@@ -12,21 +11,41 @@ export interface CurveAreaProps extends PaintProps {
|
|
|
12
11
|
* two, and it has a life of its own on the timeline, swept open or kept while
|
|
13
12
|
* a curve changes.
|
|
14
13
|
*/
|
|
15
|
-
export declare
|
|
14
|
+
export declare const CurveArea: import("@motionscript/sdk").Component<"curveArea", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
16
15
|
/** The plot that bounds the area, by id. */
|
|
17
|
-
on: string
|
|
16
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
18
17
|
/** A second plot to fill down to, in place of the x axis. */
|
|
19
|
-
under: string
|
|
20
|
-
domain: Interval
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
under: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
19
|
+
domain: import("@motionscript/sdk").Type<Interval, Interval, false>;
|
|
20
|
+
graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
|
|
21
|
+
fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
|
|
22
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
23
|
+
}>, {
|
|
24
|
+
readonly domainTo: readonly ["domain"];
|
|
25
|
+
readonly fillTo: readonly ["fill"];
|
|
26
|
+
readonly shadowTo: readonly ["shadow"];
|
|
27
|
+
}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
28
|
+
/** The plot that bounds the area, by id. */
|
|
29
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
30
|
+
/** A second plot to fill down to, in place of the x axis. */
|
|
31
|
+
under: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
32
|
+
domain: import("@motionscript/sdk").Type<Interval, Interval, false>;
|
|
33
|
+
graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
|
|
34
|
+
fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
|
|
35
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
36
|
+
}>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
37
|
+
/** The plot that bounds the area, by id. */
|
|
38
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
39
|
+
/** A second plot to fill down to, in place of the x axis. */
|
|
40
|
+
under: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
41
|
+
domain: import("@motionscript/sdk").Type<Interval, Interval, false>;
|
|
42
|
+
graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
|
|
43
|
+
fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
|
|
44
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
45
|
+
}>, {
|
|
46
|
+
readonly domainTo: readonly ["domain"];
|
|
47
|
+
readonly fillTo: readonly ["fill"];
|
|
48
|
+
readonly shadowTo: readonly ["shadow"];
|
|
49
|
+
}, _Node2D<_Node2DProps>>>>;
|
|
50
|
+
export type CurveArea = NodeOf<typeof CurveArea>;
|
|
32
51
|
//# sourceMappingURL=curve-area.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curve-area.d.ts","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"curve-area.d.ts","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,UAAU,EAGf,KAAK,IAAI,IAAI,KAAK,EAClB,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAO9C,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,QAAQ,CAAC;CACrB;AAmBD;;;;;GAKG;AACH,eAAO,MAAM,SAAS;IApBlB,4CAA4C;;IAE5C,6DAA6D;;;;;;;;;;;IAF7D,4CAA4C;;IAE5C,6DAA6D;;;;;;;IAF7D,4CAA4C;;IAE5C,6DAA6D;;;;;;;;;;2BA6BnD,CAAC;AAEf,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
package/dist/marks/curve-area.js
CHANGED
|
@@ -1,82 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { command, fillProperty, node, property, withdraw, } from "@motionscript/sdk";
|
|
8
|
-
import { clamp, stated } from "../kit/geometry.js";
|
|
9
|
-
import { Mark } from "../kit/mark.js";
|
|
10
|
-
import { curveNamed, curveOf } from "../kit/curve.js";
|
|
1
|
+
import { component2d, Types, } from "@motionscript/sdk";
|
|
2
|
+
import { omit, PAINT, PAINT_COMMANDS } from "../kit/component.js";
|
|
3
|
+
import { curveValue } from "../kit/curve.js";
|
|
11
4
|
import { lerpInterval, PLOT_COLOR, readInterval } from "../kit/furniture.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
5
|
+
import { clamp } from "../kit/geometry.js";
|
|
6
|
+
import { curveFor, PLANE_ENTRY, PLOT_REF } from "../kit/graph.js";
|
|
7
|
+
import { drawMark, inkSize, reading, traced } from "../kit/mark.js";
|
|
8
|
+
const state = {
|
|
9
|
+
// An area is only its fill, and has no outline to trim.
|
|
10
|
+
...omit(PAINT, "stroke", "start", "end"),
|
|
11
|
+
/** The plot that bounds the area, by id. */
|
|
12
|
+
on: PLOT_REF,
|
|
13
|
+
/** A second plot to fill down to, in place of the x axis. */
|
|
14
|
+
under: PLOT_REF,
|
|
15
|
+
domain: Types.custom([0, 1], { resolve: readInterval, lerp: lerpInterval }),
|
|
16
|
+
graph: PLANE_ENTRY,
|
|
17
|
+
};
|
|
14
18
|
/**
|
|
15
19
|
* The region between a plot and the x axis, or between two plots, over a span
|
|
16
20
|
* of x. It sits beside the plots it reads rather than inside one: it may read
|
|
17
21
|
* two, and it has a life of its own on the timeline, swept open or kept while
|
|
18
22
|
* a curve changes.
|
|
19
23
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
export const CurveArea = traced(component2d({
|
|
25
|
+
key: "curveArea",
|
|
26
|
+
state,
|
|
27
|
+
defaults: { fill: { type: "solid", color: PLOT_COLOR, opacity: 0.35 }, width: "hug", height: "hug" },
|
|
28
|
+
commands: {
|
|
29
|
+
...omit(PAINT_COMMANDS, "strokeTo", "progressTo", "flash"),
|
|
30
|
+
/** Animate the span of x that is filled: sweep an area open, or slide it along. */
|
|
31
|
+
domainTo: { args: ["domain"] },
|
|
32
|
+
},
|
|
33
|
+
measure: (_measurer, s) => inkSize(traceArea(s, reading(s))),
|
|
34
|
+
render: (ctx, s) => drawMark(ctx, s, traceArea(s, reading(s)), { closed: true }),
|
|
35
|
+
}), traceArea);
|
|
36
|
+
function traceArea(s, { map, plane }) {
|
|
37
|
+
const top = curveFor(plane, s.on);
|
|
38
|
+
if (!top)
|
|
39
|
+
return [];
|
|
40
|
+
const floor = curveFor(plane, s.under, false);
|
|
41
|
+
const [yMin, yMax] = map.yRange;
|
|
42
|
+
const a = Math.max(s.domain[0], map.xRange[0]);
|
|
43
|
+
const b = Math.min(s.domain[1], map.xRange[1]);
|
|
44
|
+
if (!(b > a))
|
|
45
|
+
return [];
|
|
46
|
+
const width = Math.abs(map.toPoint(b, 0).x - map.toPoint(a, 0).x);
|
|
47
|
+
const steps = Math.max(8, Math.min(600, Math.round(width / 2)));
|
|
48
|
+
// Held inside the system's range, and at the axis where a curve has no value.
|
|
49
|
+
const height = (value) => (Number.isFinite(value) ? clamp(value, yMin, yMax) : clamp(0, yMin, yMax));
|
|
50
|
+
const upper = [];
|
|
51
|
+
const lower = [];
|
|
52
|
+
for (let i = 0; i <= steps; i++) {
|
|
53
|
+
const x = a + ((b - a) * i) / steps;
|
|
54
|
+
upper.push(map.toPoint(x, height(curveValue(top, x))));
|
|
55
|
+
lower.push(map.toPoint(x, height(floor ? curveValue(floor, x) : 0)));
|
|
27
56
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
trace(map) {
|
|
32
|
-
const top = curveOf(this, this.on);
|
|
33
|
-
if (!top)
|
|
34
|
-
return [];
|
|
35
|
-
const floor = curveNamed(this, this.under);
|
|
36
|
-
const [yMin, yMax] = map.yRange;
|
|
37
|
-
const a = Math.max(this.domain[0], map.xRange[0]);
|
|
38
|
-
const b = Math.min(this.domain[1], map.xRange[1]);
|
|
39
|
-
if (!(b > a))
|
|
40
|
-
return [];
|
|
41
|
-
const width = Math.abs(map.toPoint(b, 0).x - map.toPoint(a, 0).x);
|
|
42
|
-
const steps = Math.max(8, Math.min(600, Math.round(width / 2)));
|
|
43
|
-
// Held inside the system's range, and at the axis where a curve has no value.
|
|
44
|
-
const height = (value) => (Number.isFinite(value) ? clamp(value, yMin, yMax) : clamp(0, yMin, yMax));
|
|
45
|
-
const upper = [];
|
|
46
|
-
const lower = [];
|
|
47
|
-
for (let i = 0; i <= steps; i++) {
|
|
48
|
-
const x = a + ((b - a) * i) / steps;
|
|
49
|
-
upper.push(map.toPoint(x, height(top.valueAt(x))));
|
|
50
|
-
lower.push(map.toPoint(x, height(floor ? floor.valueAt(x) : 0)));
|
|
51
|
-
}
|
|
52
|
-
return [[...upper, ...lower.reverse()]];
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
__decorate([
|
|
56
|
-
property({ default: "", kind: "nodeRef", nodeTypes: ["functionPlot"], animatable: false })
|
|
57
|
-
], CurveArea.prototype, "on", void 0);
|
|
58
|
-
__decorate([
|
|
59
|
-
property({ default: "", kind: "nodeRef", nodeTypes: ["functionPlot"], animatable: false })
|
|
60
|
-
], CurveArea.prototype, "under", void 0);
|
|
61
|
-
__decorate([
|
|
62
|
-
property({ default: [0, 1], mapper: readInterval, tween: lerpInterval })
|
|
63
|
-
], CurveArea.prototype, "domain", void 0);
|
|
64
|
-
__decorate([
|
|
65
|
-
fillProperty({ default: { type: "solid", color: PLOT_COLOR, opacity: 0.35 } })
|
|
66
|
-
], CurveArea.prototype, "fill", void 0);
|
|
67
|
-
__decorate([
|
|
68
|
-
command({ args: ["domain"] })
|
|
69
|
-
], CurveArea.prototype, "domainTo", null);
|
|
70
|
-
CurveArea = __decorate([
|
|
71
|
-
node({
|
|
72
|
-
key: "curveArea",
|
|
73
|
-
within: SYSTEMS,
|
|
74
|
-
beside: ["functionPlot"],
|
|
75
|
-
parentKey: "shape",
|
|
76
|
-
forkable: true,
|
|
77
|
-
layout: { children: "freeform", defaultWidthMode: "hug", defaultHeightMode: "hug", acceptsChildren: false },
|
|
78
|
-
}),
|
|
79
|
-
withdraw(...STROKE_PAINT, ...OUTLINE_TRIM)
|
|
80
|
-
], CurveArea);
|
|
81
|
-
export { CurveArea };
|
|
57
|
+
return [[...upper, ...lower.reverse()]];
|
|
58
|
+
}
|
|
82
59
|
//# sourceMappingURL=curve-area.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curve-area.js","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"curve-area.js","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAYR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,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,KAAa,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7G,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import {\r\n component2d,\r\n Types,\r\n type NodeOf,\r\n type NodeView,\r\n type PaintProps,\r\n type Vector2,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Fill as _Fill,\r\n type FillResolved as _FillResolved,\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n type Shadow as _Shadow,\r\n type ShadowResolved as _ShadowResolved,\r\n} from \"@motionscript/sdk\";\r\nimport { omit, PAINT, PAINT_COMMANDS } from \"../kit/component\";\r\nimport type { Interval } from \"../kit/coords\";\r\nimport { curveValue } from \"../kit/curve\";\r\nimport { lerpInterval, PLOT_COLOR, readInterval } from \"../kit/furniture\";\r\nimport { clamp } from \"../kit/geometry\";\r\nimport { curveFor, PLANE_ENTRY, PLOT_REF } from \"../kit/graph\";\r\nimport { drawMark, inkSize, reading, traced, type MarkReading } from \"../kit/mark\";\r\n\r\nexport interface CurveAreaProps extends PaintProps {\r\n on?: string;\r\n under?: string;\r\n domain?: Interval;\r\n}\r\n\r\nconst state = {\r\n // An area is only its fill, and has no outline to trim.\r\n ...omit(PAINT, \"stroke\", \"start\", \"end\"),\r\n /** The plot that bounds the area, by id. */\r\n on: PLOT_REF,\r\n /** A second plot to fill down to, in place of the x axis. */\r\n under: PLOT_REF,\r\n domain: Types.custom<Interval>([0, 1], { resolve: readInterval, lerp: lerpInterval }),\r\n graph: PLANE_ENTRY,\r\n};\r\n\r\ninterface AreaValues {\r\n readonly on: NodeView | null;\r\n readonly under: NodeView | null;\r\n readonly domain: Interval;\r\n}\r\n\r\n/**\r\n * The region between a plot and the x axis, or between two plots, over a span\r\n * of x. It sits beside the plots it reads rather than inside one: it may read\r\n * two, and it has a life of its own on the timeline, swept open or kept while\r\n * a curve changes.\r\n */\r\nexport const CurveArea = traced(component2d({\r\n key: \"curveArea\",\r\n state,\r\n defaults: { fill: { type: \"solid\", color: PLOT_COLOR, opacity: 0.35 }, width: \"hug\", height: \"hug\" },\r\n commands: {\r\n ...omit(PAINT_COMMANDS, \"strokeTo\", \"progressTo\", \"flash\"),\r\n /** Animate the span of x that is filled: sweep an area open, or slide it along. */\r\n domainTo: { args: [\"domain\"] },\r\n },\r\n measure: (_measurer, s) => inkSize(traceArea(s, reading(s))),\r\n render: (ctx, s) => drawMark(ctx, s, traceArea(s, reading(s)), { closed: true }),\r\n}), traceArea);\r\n\r\nexport type CurveArea = NodeOf<typeof CurveArea>;\r\n\r\nfunction traceArea(s: AreaValues, { map, plane }: MarkReading): Vector2[][] {\r\n const top = curveFor(plane, s.on);\r\n if (!top) return [];\r\n const floor = curveFor(plane, s.under, false);\r\n const [yMin, yMax] = map.yRange;\r\n const a = Math.max(s.domain[0], map.xRange[0]);\r\n const b = Math.min(s.domain[1], map.xRange[1]);\r\n if (!(b > a)) return [];\r\n\r\n const width = Math.abs(map.toPoint(b, 0).x - map.toPoint(a, 0).x);\r\n const steps = Math.max(8, Math.min(600, Math.round(width / 2)));\r\n // Held inside the system's range, and at the axis where a curve has no value.\r\n const height = (value: number) => (Number.isFinite(value) ? clamp(value, yMin, yMax) : clamp(0, yMin, yMax));\r\n const upper: Vector2[] = [];\r\n const lower: Vector2[] = [];\r\n for (let i = 0; i <= steps; i++) {\r\n const x = a + ((b - a) * i) / steps;\r\n upper.push(map.toPoint(x, height(curveValue(top, x))));\r\n lower.push(map.toPoint(x, height(floor ? curveValue(floor, x) : 0)));\r\n }\r\n return [[...upper, ...lower.reverse()]];\r\n}\r\n"]}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { CoordinateMap } from "../kit/coords.js";
|
|
3
|
-
import { Mark } from "../kit/mark.js";
|
|
1
|
+
import { type NodeOf, type NodeView, type PaintProps, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
|
|
4
2
|
export type DropAxis = "x" | "y" | "both";
|
|
5
3
|
export interface DropLinesProps extends PaintProps {
|
|
6
4
|
on?: string;
|
|
@@ -10,13 +8,50 @@ export interface DropLinesProps extends PaintProps {
|
|
|
10
8
|
* Guide lines from a graph point to the axes, reading its coordinates off them.
|
|
11
9
|
* The point is this node's `x`/`y`, or the point of a plot above its `x`.
|
|
12
10
|
*/
|
|
13
|
-
export declare
|
|
11
|
+
export declare const DropLines: import("@motionscript/sdk").Component<"dropLines", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
14
12
|
/** A plot to take the point's height from, by id. */
|
|
15
|
-
on: string
|
|
13
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
16
14
|
/** Which axis to drop to: `x` draws the vertical line, `y` the horizontal one. */
|
|
17
|
-
axis:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
axis: import("@motionscript/sdk").Type<"x" | "y" | "both", "x" | "y" | "both", false>;
|
|
16
|
+
graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
|
|
17
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
18
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
19
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
20
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
21
|
+
}>, {
|
|
22
|
+
strokeTo: readonly ["stroke"];
|
|
23
|
+
shadowTo: readonly ["shadow"];
|
|
24
|
+
progressTo: readonly ["start", "end"];
|
|
25
|
+
flash: {
|
|
26
|
+
readonly portion: import("@motionscript/sdk").Type<number, number, false>;
|
|
27
|
+
};
|
|
28
|
+
}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
29
|
+
/** A plot to take the point's height from, by id. */
|
|
30
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
31
|
+
/** Which axis to drop to: `x` draws the vertical line, `y` the horizontal one. */
|
|
32
|
+
axis: import("@motionscript/sdk").Type<"x" | "y" | "both", "x" | "y" | "both", false>;
|
|
33
|
+
graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
|
|
34
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
35
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
36
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
37
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
38
|
+
}>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
39
|
+
/** A plot to take the point's height from, by id. */
|
|
40
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
41
|
+
/** Which axis to drop to: `x` draws the vertical line, `y` the horizontal one. */
|
|
42
|
+
axis: import("@motionscript/sdk").Type<"x" | "y" | "both", "x" | "y" | "both", false>;
|
|
43
|
+
graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
|
|
44
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
45
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
46
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
47
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
48
|
+
}>, {
|
|
49
|
+
strokeTo: readonly ["stroke"];
|
|
50
|
+
shadowTo: readonly ["shadow"];
|
|
51
|
+
progressTo: readonly ["start", "end"];
|
|
52
|
+
flash: {
|
|
53
|
+
readonly portion: import("@motionscript/sdk").Type<number, number, false>;
|
|
54
|
+
};
|
|
55
|
+
}, _Node2D<_Node2DProps>>>>;
|
|
56
|
+
export type DropLines = NodeOf<typeof DropLines>;
|
|
22
57
|
//# sourceMappingURL=drop-lines.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop-lines.d.ts","sourceRoot":"","sources":["../../src/marks/drop-lines.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"drop-lines.d.ts","sourceRoot":"","sources":["../../src/marks/drop-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,UAAU,EAGf,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACtC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;AAE1C,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,QAAQ,CAAC;CACnB;AAkBD;;;GAGG;AACH,eAAO,MAAM,SAAS;IAlBlB,qDAAqD;;IAErD,kFAAkF;;;;;;;;;;;;;;;IAFlF,qDAAqD;;IAErD,kFAAkF;;;;;;;;IAFlF,qDAAqD;;IAErD,kFAAkF;;;;;;;;;;;;;;2BAuBvE,CAAC;AAEhB,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC"}
|