@motionscript/math 0.1.0-alpha.8 → 0.1.0-alpha.9
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 +2 -0
- package/LICENSE +201 -201
- package/NOTICE +49 -49
- package/README.md +390 -391
- package/dist/annotate/angle-mark.js.map +1 -1
- package/dist/annotate/curly-brace.js.map +1 -1
- package/dist/annotate/emphasis-mark.js.map +1 -1
- package/dist/browser/chunks/{chunk-FETQZEN2.js → chunk-IRZCG6PM.js} +2 -2
- package/dist/browser/chunks/chunk-IRZCG6PM.js.map +7 -0
- package/dist/browser/chunks/{chunk-K77KLQX4.js → chunk-WMVW6ZIV.js} +2 -2
- package/dist/browser/chunks/chunk-WMVW6ZIV.js.map +7 -0
- package/dist/browser/chunks/{mathjax-DNP3YRES.js → mathjax-WV55AC2P.js} +1 -1
- package/dist/browser/chunks/{mathjax-DNP3YRES.js.map → mathjax-WV55AC2P.js.map} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/kit.js +1 -1
- package/dist/browser/tex.js +1 -1
- package/dist/browser/tex.js.map +1 -1
- package/dist/engine.d.ts +1 -1
- package/dist/engine.js +1 -1
- package/dist/engine.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kit/brace.js.map +1 -1
- package/dist/kit/cache.js.map +1 -1
- package/dist/kit/component.d.ts.map +1 -1
- package/dist/kit/component.js.map +1 -1
- package/dist/kit/contour.js.map +1 -1
- package/dist/kit/coords.js.map +1 -1
- package/dist/kit/curve.js.map +1 -1
- package/dist/kit/equation.js.map +1 -1
- package/dist/kit/equation3d.js.map +1 -1
- package/dist/kit/expression.js.map +1 -1
- package/dist/kit/field-mark.d.ts.map +1 -1
- package/dist/kit/field-mark.js.map +1 -1
- package/dist/kit/field.js.map +1 -1
- package/dist/kit/follow.d.ts.map +1 -1
- package/dist/kit/follow.js.map +1 -1
- package/dist/kit/furniture.js.map +1 -1
- package/dist/kit/geometry.js.map +1 -1
- package/dist/kit/graph.js.map +1 -1
- package/dist/kit/mark.js.map +1 -1
- package/dist/kit/part-fills.js.map +1 -1
- package/dist/kit/place.js.map +1 -1
- package/dist/kit/sampler.js.map +1 -1
- package/dist/kit/scale.js.map +1 -1
- package/dist/kit/source.js.map +1 -1
- package/dist/kit/system.js.map +1 -1
- package/dist/kit/ticks.js.map +1 -1
- package/dist/kit/withdrawn.js.map +1 -1
- package/dist/marks/curve-area.js.map +1 -1
- package/dist/marks/drop-lines.js.map +1 -1
- package/dist/marks/plot-point.js.map +1 -1
- package/dist/marks/riemann-sum.js.map +1 -1
- package/dist/marks/tangent-line.js.map +1 -1
- package/dist/marks/vector-arrow.js.map +1 -1
- package/dist/nodes.js.map +1 -1
- package/dist/plots/function-plot.d.ts.map +1 -1
- package/dist/plots/function-plot.js.map +1 -1
- package/dist/plots/points-plot.js.map +1 -1
- package/dist/plots/stream-lines.js.map +1 -1
- package/dist/plots/traced-path.js.map +1 -1
- package/dist/plots/vector-field.js.map +1 -1
- package/dist/structures/graph-layout.js.map +1 -1
- package/dist/structures/network-graph.js.map +1 -1
- package/dist/structures/sample-space.js.map +1 -1
- package/dist/systems/axes2d.d.ts.map +1 -1
- package/dist/systems/axes2d.js.map +1 -1
- package/dist/systems/number-line.js.map +1 -1
- package/dist/systems/number-plane.js.map +1 -1
- package/dist/systems/polar-plane.js.map +1 -1
- package/dist/tex/geometry.js.map +1 -1
- package/dist/tex/index.js.map +1 -1
- package/dist/tex/mathjax.js.map +1 -1
- package/dist/tex/matrix.js.map +1 -1
- package/dist/tex/node.js.map +1 -1
- package/dist/tex/tween.js.map +1 -1
- package/dist/tex/typeset.d.ts.map +1 -1
- package/dist/tex/typeset.js.map +1 -1
- package/dist/three/axes3d.js.map +1 -1
- package/dist/three/curve-plot3d.js.map +1 -1
- package/dist/three/entries.js.map +1 -1
- package/dist/three/label3d.js.map +1 -1
- package/dist/three/plot-point3d.js.map +1 -1
- package/dist/three/space.js.map +1 -1
- package/dist/three/surface-plot3d.js.map +1 -1
- package/dist/three/vector-arrow3d.js.map +1 -1
- package/package.json +4 -4
- package/registry.json +251 -251
- package/src/annotate/angle-mark.ts +137 -137
- package/src/annotate/curly-brace.ts +148 -148
- package/src/annotate/emphasis-mark.ts +118 -118
- package/src/engine.ts +86 -86
- package/src/index.ts +29 -29
- package/src/kit/brace.ts +37 -37
- package/src/kit/cache.ts +61 -61
- package/src/kit/component.ts +57 -57
- package/src/kit/contour.ts +94 -94
- package/src/kit/coords.ts +278 -278
- package/src/kit/curve.ts +47 -47
- package/src/kit/equation.ts +181 -181
- package/src/kit/equation3d.ts +137 -137
- package/src/kit/expression.ts +159 -159
- package/src/kit/field-mark.ts +171 -171
- package/src/kit/field.ts +50 -50
- package/src/kit/follow.ts +229 -229
- package/src/kit/furniture.ts +113 -113
- package/src/kit/geometry.ts +49 -49
- package/src/kit/graph.ts +116 -116
- package/src/kit/mark.ts +152 -152
- package/src/kit/part-fills.ts +61 -61
- package/src/kit/place.ts +77 -77
- package/src/kit/sampler.ts +281 -281
- package/src/kit/scale.ts +39 -39
- package/src/kit/source.ts +57 -57
- package/src/kit/system.ts +105 -105
- package/src/kit/ticks.ts +85 -85
- package/src/kit/withdrawn.ts +8 -8
- package/src/marks/curve-area.ts +89 -89
- package/src/marks/drop-lines.ts +71 -71
- package/src/marks/plot-point.ts +102 -102
- package/src/marks/riemann-sum.ts +99 -99
- package/src/marks/tangent-line.ts +119 -119
- package/src/marks/vector-arrow.ts +98 -98
- package/src/nodes.ts +99 -99
- package/src/plots/function-plot.ts +220 -220
- package/src/plots/points-plot.ts +103 -103
- package/src/plots/stream-lines.ts +160 -160
- package/src/plots/traced-path.ts +70 -70
- package/src/plots/vector-field.ts +107 -107
- package/src/structures/graph-layout.ts +145 -145
- package/src/structures/network-graph.ts +291 -291
- package/src/structures/sample-space.ts +210 -210
- package/src/systems/axes2d.ts +226 -226
- package/src/systems/number-line.ts +130 -130
- package/src/systems/number-plane.ts +232 -232
- package/src/systems/polar-plane.ts +177 -177
- package/src/tex/geometry.ts +703 -703
- package/src/tex/index.ts +15 -15
- package/src/tex/mathjax.ts +82 -82
- package/src/tex/matrix.ts +97 -97
- package/src/tex/node.ts +74 -74
- package/src/tex/tween.ts +308 -308
- package/src/tex/typeset.ts +461 -461
- package/src/three/axes3d.ts +267 -267
- package/src/three/curve-plot3d.ts +146 -146
- package/src/three/entries.ts +42 -42
- package/src/three/label3d.ts +52 -52
- package/src/three/plot-point3d.ts +63 -63
- package/src/three/space.ts +92 -92
- package/src/three/surface-plot3d.ts +318 -318
- package/src/three/vector-arrow3d.ts +88 -88
- package/dist/browser/chunks/chunk-FETQZEN2.js.map +0 -7
- package/dist/browser/chunks/chunk-K77KLQX4.js.map +0 -7
- package/dist/kit/placement.d.ts +0 -8
- package/dist/kit/placement.d.ts.map +0 -1
- package/dist/kit/placement.js +0 -8
- package/dist/kit/placement.js.map +0 -1
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
import {
|
|
2
|
-
component2d,
|
|
3
|
-
Graphics2D,
|
|
4
|
-
Types,
|
|
5
|
-
type NodeOf,
|
|
6
|
-
type NodeView,
|
|
7
|
-
type PathCommand,
|
|
8
|
-
type Vector2,
|
|
9
|
-
// Named so the emitted declaration reaches these through the sdk, not core.
|
|
10
|
-
type Node2D as _Node2D,
|
|
11
|
-
type Node2DProps as _Node2DProps,
|
|
12
|
-
type Shadow as _Shadow,
|
|
13
|
-
type ShadowResolved as _ShadowResolved,
|
|
14
|
-
type Stroke as _Stroke,
|
|
15
|
-
type StrokeResolved as _StrokeResolved,
|
|
16
|
-
} from "@motionscript/sdk";
|
|
17
|
-
import { listed, painted } from "../kit/component";
|
|
18
|
-
import {
|
|
19
|
-
add, between, container, FOLLOW_COMMANDS, FOLLOW_STATE, followedQuad, grown, heading, outlineBounds, OWN_FRAME, type FollowProps, type FollowValues, type Quad,
|
|
20
|
-
} from "../kit/follow";
|
|
21
|
-
import { strokeShape } from "../kit/mark";
|
|
22
|
-
|
|
23
|
-
export type EmphasisShape = "box" | "circle" | "underline" | "cross";
|
|
24
|
-
|
|
25
|
-
export interface EmphasisMarkProps extends FollowProps {
|
|
26
|
-
shape?: EmphasisShape;
|
|
27
|
-
clearance?: number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** How far a cubic's handle reaches to draw a quarter of an ellipse. */
|
|
31
|
-
const QUARTER = 0.5523;
|
|
32
|
-
|
|
33
|
-
const line = (a: Vector2, b: Vector2): PathCommand[] => [
|
|
34
|
-
{ type: "M", x: a.x, y: a.y },
|
|
35
|
-
{ type: "L", x: b.x, y: b.y },
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
const SHAPES: Record<EmphasisShape, (quad: Quad, gap: number) => PathCommand[]> = {
|
|
39
|
-
box: (quad, gap) => {
|
|
40
|
-
const [tl, tr, br, bl] = grown(quad, gap);
|
|
41
|
-
return [{ type: "M", x: tl.x, y: tl.y }, ...[tr, br, bl].map((p): PathCommand => ({ type: "L", x: p.x, y: p.y })), { type: "Z" }];
|
|
42
|
-
},
|
|
43
|
-
// The ellipse through the grown box's corners.
|
|
44
|
-
circle: (quad, gap) => {
|
|
45
|
-
const [tl, tr, br, bl] = grown(quad, gap);
|
|
46
|
-
const centre = between(tl, br);
|
|
47
|
-
const across = { x: ((tr.x - tl.x) / 2) * Math.SQRT2, y: ((tr.y - tl.y) / 2) * Math.SQRT2 };
|
|
48
|
-
const up = { x: ((tl.x - bl.x) / 2) * Math.SQRT2, y: ((tl.y - bl.y) / 2) * Math.SQRT2 };
|
|
49
|
-
const at = (a: number, u: number) => add(add(centre, across, a), up, u);
|
|
50
|
-
const arc = (c1: Vector2, c2: Vector2, end: Vector2): PathCommand => ({
|
|
51
|
-
type: "C", x1: c1.x, y1: c1.y, x2: c2.x, y2: c2.y, x: end.x, y: end.y,
|
|
52
|
-
});
|
|
53
|
-
const k = QUARTER;
|
|
54
|
-
const start = at(0, 1);
|
|
55
|
-
return [
|
|
56
|
-
{ type: "M", x: start.x, y: start.y },
|
|
57
|
-
arc(at(k, 1), at(1, k), at(1, 0)),
|
|
58
|
-
arc(at(1, -k), at(k, -1), at(0, -1)),
|
|
59
|
-
arc(at(-k, -1), at(-1, -k), at(-1, 0)),
|
|
60
|
-
arc(at(-1, k), at(-k, 1), start),
|
|
61
|
-
{ type: "Z" },
|
|
62
|
-
];
|
|
63
|
-
},
|
|
64
|
-
underline: (quad, gap) => {
|
|
65
|
-
const [, , br, bl] = quad;
|
|
66
|
-
const down = heading(quad[0], bl).unit;
|
|
67
|
-
return line(add(bl, down, gap), add(br, down, gap));
|
|
68
|
-
},
|
|
69
|
-
cross: (quad, gap) => {
|
|
70
|
-
const [tl, tr, br, bl] = grown(quad, gap);
|
|
71
|
-
return [...line(tl, br), ...line(bl, tr)];
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const state = {
|
|
76
|
-
...FOLLOW_STATE,
|
|
77
|
-
shape: listed(["box", "circle", "underline", "cross"], "box", { animatable: false }),
|
|
78
|
-
/** The room between the target and the mark. (`gap` is a layout's.) */
|
|
79
|
-
clearance: Types.number(10, { unit: "px" }),
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
interface EmphasisValues extends FollowValues {
|
|
83
|
-
readonly shape: EmphasisShape;
|
|
84
|
-
readonly clearance: number;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function outline(s: EmphasisValues, parted: NodeView | null): PathCommand[] {
|
|
88
|
-
const quad = followedQuad(s, parted);
|
|
89
|
-
return quad ? SHAPES[s.shape](quad, s.clearance) : [];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* A box, a circle, an underline or a cross drawn on a node, or on one part of
|
|
94
|
-
* a formula. `progressTo` draws it on, and `retargetTo` slides it to another.
|
|
95
|
-
*/
|
|
96
|
-
export const EmphasisMark = component2d({
|
|
97
|
-
key: "emphasisMark",
|
|
98
|
-
state,
|
|
99
|
-
defaults: { stroke: { weight: 3, fill: "#facc15", align: "center", cap: "round", join: "round" }, width: "hug", height: "hug" },
|
|
100
|
-
commands: FOLLOW_COMMANDS,
|
|
101
|
-
measure: () => ({ width: 0, height: 0 }),
|
|
102
|
-
bounds: (_size, s) => outlineBounds(outline(s, container(null, s))),
|
|
103
|
-
render: (ctx, s) => {
|
|
104
|
-
const data = outline(s, container(ctx, s));
|
|
105
|
-
const shape = data.length > 0 ? () => new Graphics2D().path({ data, centerBounds: OWN_FRAME, start: s.start, end: s.end }) : null;
|
|
106
|
-
painted(
|
|
107
|
-
ctx,
|
|
108
|
-
() => {
|
|
109
|
-
if (shape) ctx.draw(shape().shadow(s.shadow).fill([]));
|
|
110
|
-
},
|
|
111
|
-
() => {
|
|
112
|
-
if (shape) strokeShape(ctx, shape, s);
|
|
113
|
-
},
|
|
114
|
-
);
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
export type EmphasisMark = NodeOf<typeof EmphasisMark>;
|
|
1
|
+
import {
|
|
2
|
+
component2d,
|
|
3
|
+
Graphics2D,
|
|
4
|
+
Types,
|
|
5
|
+
type NodeOf,
|
|
6
|
+
type NodeView,
|
|
7
|
+
type PathCommand,
|
|
8
|
+
type Vector2,
|
|
9
|
+
// Named so the emitted declaration reaches these through the sdk, not core.
|
|
10
|
+
type Node2D as _Node2D,
|
|
11
|
+
type Node2DProps as _Node2DProps,
|
|
12
|
+
type Shadow as _Shadow,
|
|
13
|
+
type ShadowResolved as _ShadowResolved,
|
|
14
|
+
type Stroke as _Stroke,
|
|
15
|
+
type StrokeResolved as _StrokeResolved,
|
|
16
|
+
} from "@motionscript/sdk";
|
|
17
|
+
import { listed, painted } from "../kit/component";
|
|
18
|
+
import {
|
|
19
|
+
add, between, container, FOLLOW_COMMANDS, FOLLOW_STATE, followedQuad, grown, heading, outlineBounds, OWN_FRAME, type FollowProps, type FollowValues, type Quad,
|
|
20
|
+
} from "../kit/follow";
|
|
21
|
+
import { strokeShape } from "../kit/mark";
|
|
22
|
+
|
|
23
|
+
export type EmphasisShape = "box" | "circle" | "underline" | "cross";
|
|
24
|
+
|
|
25
|
+
export interface EmphasisMarkProps extends FollowProps {
|
|
26
|
+
shape?: EmphasisShape;
|
|
27
|
+
clearance?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** How far a cubic's handle reaches to draw a quarter of an ellipse. */
|
|
31
|
+
const QUARTER = 0.5523;
|
|
32
|
+
|
|
33
|
+
const line = (a: Vector2, b: Vector2): PathCommand[] => [
|
|
34
|
+
{ type: "M", x: a.x, y: a.y },
|
|
35
|
+
{ type: "L", x: b.x, y: b.y },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const SHAPES: Record<EmphasisShape, (quad: Quad, gap: number) => PathCommand[]> = {
|
|
39
|
+
box: (quad, gap) => {
|
|
40
|
+
const [tl, tr, br, bl] = grown(quad, gap);
|
|
41
|
+
return [{ type: "M", x: tl.x, y: tl.y }, ...[tr, br, bl].map((p): PathCommand => ({ type: "L", x: p.x, y: p.y })), { type: "Z" }];
|
|
42
|
+
},
|
|
43
|
+
// The ellipse through the grown box's corners.
|
|
44
|
+
circle: (quad, gap) => {
|
|
45
|
+
const [tl, tr, br, bl] = grown(quad, gap);
|
|
46
|
+
const centre = between(tl, br);
|
|
47
|
+
const across = { x: ((tr.x - tl.x) / 2) * Math.SQRT2, y: ((tr.y - tl.y) / 2) * Math.SQRT2 };
|
|
48
|
+
const up = { x: ((tl.x - bl.x) / 2) * Math.SQRT2, y: ((tl.y - bl.y) / 2) * Math.SQRT2 };
|
|
49
|
+
const at = (a: number, u: number) => add(add(centre, across, a), up, u);
|
|
50
|
+
const arc = (c1: Vector2, c2: Vector2, end: Vector2): PathCommand => ({
|
|
51
|
+
type: "C", x1: c1.x, y1: c1.y, x2: c2.x, y2: c2.y, x: end.x, y: end.y,
|
|
52
|
+
});
|
|
53
|
+
const k = QUARTER;
|
|
54
|
+
const start = at(0, 1);
|
|
55
|
+
return [
|
|
56
|
+
{ type: "M", x: start.x, y: start.y },
|
|
57
|
+
arc(at(k, 1), at(1, k), at(1, 0)),
|
|
58
|
+
arc(at(1, -k), at(k, -1), at(0, -1)),
|
|
59
|
+
arc(at(-k, -1), at(-1, -k), at(-1, 0)),
|
|
60
|
+
arc(at(-1, k), at(-k, 1), start),
|
|
61
|
+
{ type: "Z" },
|
|
62
|
+
];
|
|
63
|
+
},
|
|
64
|
+
underline: (quad, gap) => {
|
|
65
|
+
const [, , br, bl] = quad;
|
|
66
|
+
const down = heading(quad[0], bl).unit;
|
|
67
|
+
return line(add(bl, down, gap), add(br, down, gap));
|
|
68
|
+
},
|
|
69
|
+
cross: (quad, gap) => {
|
|
70
|
+
const [tl, tr, br, bl] = grown(quad, gap);
|
|
71
|
+
return [...line(tl, br), ...line(bl, tr)];
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const state = {
|
|
76
|
+
...FOLLOW_STATE,
|
|
77
|
+
shape: listed(["box", "circle", "underline", "cross"], "box", { animatable: false }),
|
|
78
|
+
/** The room between the target and the mark. (`gap` is a layout's.) */
|
|
79
|
+
clearance: Types.number(10, { unit: "px" }),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
interface EmphasisValues extends FollowValues {
|
|
83
|
+
readonly shape: EmphasisShape;
|
|
84
|
+
readonly clearance: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function outline(s: EmphasisValues, parted: NodeView | null): PathCommand[] {
|
|
88
|
+
const quad = followedQuad(s, parted);
|
|
89
|
+
return quad ? SHAPES[s.shape](quad, s.clearance) : [];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A box, a circle, an underline or a cross drawn on a node, or on one part of
|
|
94
|
+
* a formula. `progressTo` draws it on, and `retargetTo` slides it to another.
|
|
95
|
+
*/
|
|
96
|
+
export const EmphasisMark = component2d({
|
|
97
|
+
key: "emphasisMark",
|
|
98
|
+
state,
|
|
99
|
+
defaults: { stroke: { weight: 3, fill: "#facc15", align: "center", cap: "round", join: "round" }, width: "hug", height: "hug" },
|
|
100
|
+
commands: FOLLOW_COMMANDS,
|
|
101
|
+
measure: () => ({ width: 0, height: 0 }),
|
|
102
|
+
bounds: (_size, s) => outlineBounds(outline(s, container(null, s))),
|
|
103
|
+
render: (ctx, s) => {
|
|
104
|
+
const data = outline(s, container(ctx, s));
|
|
105
|
+
const shape = data.length > 0 ? () => new Graphics2D().path({ data, centerBounds: OWN_FRAME, start: s.start, end: s.end }) : null;
|
|
106
|
+
painted(
|
|
107
|
+
ctx,
|
|
108
|
+
() => {
|
|
109
|
+
if (shape) ctx.draw(shape().shadow(s.shadow).fill([]));
|
|
110
|
+
},
|
|
111
|
+
() => {
|
|
112
|
+
if (shape) strokeShape(ctx, shape, s);
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
export type EmphasisMark = NodeOf<typeof EmphasisMark>;
|
package/src/engine.ts
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The math **kit**: what the nodes share, and what a copied one does not copy.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* these to `@motionscript/math`, so MathJax, the morph and every shared module
|
|
6
|
-
* stay a real dependency with one identity.
|
|
7
|
-
*/
|
|
8
|
-
export {
|
|
9
|
-
blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER,
|
|
10
|
-
} from './tex/geometry';
|
|
11
|
-
export type { LatexPart, LatexToken, LatexPathResult } from './tex/geometry';
|
|
12
|
-
export { defaultLatexMorph } from './tex/tween';
|
|
13
|
-
export type { AnimatedToken, LatexMorphStrategy } from './tex/tween';
|
|
14
|
-
export { Latex } from './tex/node';
|
|
15
|
-
export type { LatexProps, LatexStrategies } from './tex/node';
|
|
16
|
-
export {
|
|
17
|
-
drawFormula, formula, formulaFrame, formulaOf, isFormula, latexPartBounds, layoutFormula, lerpMorph, loadFormula, measureFormula, Morph, morphOf,
|
|
18
|
-
partBoundsIn, settled, TYPESET, TYPESET_COMMANDS,
|
|
19
|
-
} from './tex/typeset';
|
|
20
|
-
export type { FormulaFrame, Morphing, TypesetValues } from './tex/typeset';
|
|
21
|
-
export { lerpPartFills, partPaint, readPartFills, withPartFill } from './kit/part-fills';
|
|
22
|
-
export type { PartFill, PartFillResolved } from './kit/part-fills';
|
|
23
|
-
export { FILL_PAINT, OUTLINE_TRIM, STROKE_PAINT } from './kit/withdrawn';
|
|
24
|
-
export { createBoundedCache } from './kit/cache';
|
|
25
|
-
export { listed, omit, PAINT, PAINT_COMMANDS, painted } from './kit/component';
|
|
26
|
-
export type { BoundedCache } from './kit/cache';
|
|
27
|
-
|
|
28
|
-
export { drawSystem, plotArea, systemLayout, systemMap, systemOpenPlane, systemProvides, systemSize } from './kit/system';
|
|
29
|
-
export type { MapFor, SystemState } from './kit/system';
|
|
30
|
-
// A number plane is axes with a grid, so a copied one builds on these rather than a copy of them.
|
|
31
|
-
export { Axes2d, AXES, AXES_COMMANDS, axesFurniture, axesMap, axesOf, loadAxes } from './systems/axes2d';
|
|
32
|
-
export type { Axes2dProps, AxesValues, AxisLayout } from './systems/axes2d';
|
|
33
|
-
export type { Anchor } from './kit/place';
|
|
34
|
-
export { anchored, openPlane, placeOnMap } from './kit/place';
|
|
35
|
-
export {
|
|
36
|
-
castsShadow, drawMark, graphPoint, inkCentre, inkSize, markRuns, markShape, ownPoint, reading, strokeShape, traced,
|
|
37
|
-
} from './kit/mark';
|
|
38
|
-
export type { MarkOptions, MarkPaint, MarkReading, MarkState, Tracer } from './kit/mark';
|
|
39
|
-
export { curveFor, PLANE_ENTRY, PLOT, PLOT_REF, plotPlane, refId, settle, SYSTEM, SYSTEM_ENTRY, systemPlane } from './kit/graph';
|
|
40
|
-
export type { GraphPlane } from './kit/graph';
|
|
41
|
-
export { axisScale, cartesianMap, resolveInterval, PIXEL_MAP } from './kit/coords';
|
|
42
|
-
export type { AxisScale, AxisScaling, CartesianOptions, CoordinateMap, Interval } from './kit/coords';
|
|
43
|
-
export { compileExpression, compileExpressionCached, expressionVocabulary, MATH_DIALECT } from './kit/expression';
|
|
44
|
-
export type { CompiledExpression, ExpressionScope, ExpressionVocabulary } from './kit/expression';
|
|
45
|
-
export { equationError, equationParams, parseEquation, EQUATION_VARIABLES } from './kit/equation';
|
|
46
|
-
export type { Equation } from './kit/equation';
|
|
47
|
-
export { lerpDomain, lerpParams, lerpSource, readSource, revisionOf, scopeFor, UNSET_PARAM } from './kit/source';
|
|
48
|
-
export type { PlotSource } from './kit/source';
|
|
49
|
-
export { sampleCurve } from './kit/sampler';
|
|
50
|
-
export type { CurveProjection, SampleOptions } from './kit/sampler';
|
|
51
|
-
export { formatTick, ticksFor } from './kit/ticks';
|
|
52
|
-
export type { Ticks } from './kit/ticks';
|
|
53
|
-
export { boundsOfRuns, clamp, inflate, runsToPath, stated } from './kit/geometry';
|
|
54
|
-
export { CURVE_KEYS, curveValue, isCurve } from './kit/curve';
|
|
55
|
-
export type { CurveValues } from './kit/curve';
|
|
56
|
-
export { along, AXIS_COLOR, declareFormulas, drawLabels, drawn, lerpInterval, loadFormulas, PLOT_COLOR, readInterval, withoutTips } from './kit/furniture';
|
|
57
|
-
export type { Label, LabelStyle } from './kit/furniture';
|
|
58
|
-
export {
|
|
59
|
-
add, between, container, FOLLOW_COMMANDS, FOLLOW_STATE, followedQuad, grown, heading, outlineBounds, OWN_FRAME, resting,
|
|
60
|
-
} from './kit/follow';
|
|
61
|
-
export type { FollowProps, FollowValues, Parted, Quad, Retarget, Target } from './kit/follow';
|
|
62
|
-
export {
|
|
63
|
-
parseSpaceCurve, parseSurface, spaceCurveError, spaceCurveParams, surfaceError, surfaceParams, EQUATION_KINDS, EQUATION_VARIABLES_3D,
|
|
64
|
-
} from './kit/equation3d';
|
|
65
|
-
export type { EquationLanguage, SpaceCurveEquation, SurfaceEquation } from './kit/equation3d';
|
|
66
|
-
export { aim, graphEntry, graphOf, graphSpace, spaceOf, GRAPH_3D } from './three/space';
|
|
67
|
-
export type { Graph3D, GraphSpace } from './three/space';
|
|
68
|
-
export { domainEntry, meshEntries } from './three/entries';
|
|
69
|
-
export { drawLabel3D } from './three/label3d';
|
|
70
|
-
export type { LabelStyle3D } from './three/label3d';
|
|
71
|
-
// A traced path is a plot whose span follows a value, so a copied one builds on these rather than a copy of them.
|
|
72
|
-
export { FunctionPlot, PLOT_COMMANDS, PLOT_STATE, PLOT_STROKE, tracePlot } from './plots/function-plot';
|
|
73
|
-
export type { FunctionPlotProps, PlotValues } from './plots/function-plot';
|
|
74
|
-
export { drawField, FIELD_COMMANDS, FIELD_STATE, traceField } from './kit/field-mark';
|
|
75
|
-
export type { FieldDrawing, FieldProps, FieldSampler, FieldStroke, FieldValues } from './kit/field-mark';
|
|
76
|
-
export { fieldError, fieldParams, parseField, FIELD_VARIABLES } from './kit/field';
|
|
77
|
-
export type { FieldEquation } from './kit/field';
|
|
78
|
-
export { traceContour } from './kit/contour';
|
|
79
|
-
export { colorAt, fillAt, lerpFillScale, lerpScale, readFillScale, readScale } from './kit/scale';
|
|
80
|
-
export {
|
|
81
|
-
IDENTITY_MATRIX, isIdentityMatrix, lerpMatrix, lineThrough, readMatrix, transformedMap, warpedMap,
|
|
82
|
-
} from './kit/coords';
|
|
83
|
-
export type { Matrix2, Warp } from './kit/coords';
|
|
84
|
-
export { braceOutline } from './kit/brace';
|
|
85
|
-
export { GRAPH_LAYOUTS, layOut } from './structures/graph-layout';
|
|
86
|
-
export type { GraphEdge, GraphLayout } from './structures/graph-layout';
|
|
1
|
+
/**
|
|
2
|
+
* The math **kit**: what the nodes share, and what a copied one does not copy.
|
|
3
|
+
*
|
|
4
|
+
* A copy takes a node's own files into a project and rewrites its reach for
|
|
5
|
+
* these to `@motionscript/math`, so MathJax, the morph and every shared module
|
|
6
|
+
* stay a real dependency with one identity.
|
|
7
|
+
*/
|
|
8
|
+
export {
|
|
9
|
+
blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER,
|
|
10
|
+
} from './tex/geometry';
|
|
11
|
+
export type { LatexPart, LatexToken, LatexPathResult } from './tex/geometry';
|
|
12
|
+
export { defaultLatexMorph } from './tex/tween';
|
|
13
|
+
export type { AnimatedToken, LatexMorphStrategy } from './tex/tween';
|
|
14
|
+
export { Latex } from './tex/node';
|
|
15
|
+
export type { LatexProps, LatexStrategies } from './tex/node';
|
|
16
|
+
export {
|
|
17
|
+
drawFormula, formula, formulaFrame, formulaOf, isFormula, latexPartBounds, layoutFormula, lerpMorph, loadFormula, measureFormula, Morph, morphOf,
|
|
18
|
+
partBoundsIn, settled, TYPESET, TYPESET_COMMANDS,
|
|
19
|
+
} from './tex/typeset';
|
|
20
|
+
export type { FormulaFrame, Morphing, TypesetValues } from './tex/typeset';
|
|
21
|
+
export { lerpPartFills, partPaint, readPartFills, withPartFill } from './kit/part-fills';
|
|
22
|
+
export type { PartFill, PartFillResolved } from './kit/part-fills';
|
|
23
|
+
export { FILL_PAINT, OUTLINE_TRIM, STROKE_PAINT } from './kit/withdrawn';
|
|
24
|
+
export { createBoundedCache } from './kit/cache';
|
|
25
|
+
export { listed, omit, PAINT, PAINT_COMMANDS, painted } from './kit/component';
|
|
26
|
+
export type { BoundedCache } from './kit/cache';
|
|
27
|
+
|
|
28
|
+
export { drawSystem, plotArea, systemLayout, systemMap, systemOpenPlane, systemProvides, systemSize } from './kit/system';
|
|
29
|
+
export type { MapFor, SystemState } from './kit/system';
|
|
30
|
+
// A number plane is axes with a grid, so a copied one builds on these rather than a copy of them.
|
|
31
|
+
export { Axes2d, AXES, AXES_COMMANDS, axesFurniture, axesMap, axesOf, loadAxes } from './systems/axes2d';
|
|
32
|
+
export type { Axes2dProps, AxesValues, AxisLayout } from './systems/axes2d';
|
|
33
|
+
export type { Anchor } from './kit/place';
|
|
34
|
+
export { anchored, openPlane, placeOnMap } from './kit/place';
|
|
35
|
+
export {
|
|
36
|
+
castsShadow, drawMark, graphPoint, inkCentre, inkSize, markRuns, markShape, ownPoint, reading, strokeShape, traced,
|
|
37
|
+
} from './kit/mark';
|
|
38
|
+
export type { MarkOptions, MarkPaint, MarkReading, MarkState, Tracer } from './kit/mark';
|
|
39
|
+
export { curveFor, PLANE_ENTRY, PLOT, PLOT_REF, plotPlane, refId, settle, SYSTEM, SYSTEM_ENTRY, systemPlane } from './kit/graph';
|
|
40
|
+
export type { GraphPlane } from './kit/graph';
|
|
41
|
+
export { axisScale, cartesianMap, resolveInterval, PIXEL_MAP } from './kit/coords';
|
|
42
|
+
export type { AxisScale, AxisScaling, CartesianOptions, CoordinateMap, Interval } from './kit/coords';
|
|
43
|
+
export { compileExpression, compileExpressionCached, expressionVocabulary, MATH_DIALECT } from './kit/expression';
|
|
44
|
+
export type { CompiledExpression, ExpressionScope, ExpressionVocabulary } from './kit/expression';
|
|
45
|
+
export { equationError, equationParams, parseEquation, EQUATION_VARIABLES } from './kit/equation';
|
|
46
|
+
export type { Equation } from './kit/equation';
|
|
47
|
+
export { lerpDomain, lerpParams, lerpSource, readSource, revisionOf, scopeFor, UNSET_PARAM } from './kit/source';
|
|
48
|
+
export type { PlotSource } from './kit/source';
|
|
49
|
+
export { sampleCurve } from './kit/sampler';
|
|
50
|
+
export type { CurveProjection, SampleOptions } from './kit/sampler';
|
|
51
|
+
export { formatTick, ticksFor } from './kit/ticks';
|
|
52
|
+
export type { Ticks } from './kit/ticks';
|
|
53
|
+
export { boundsOfRuns, clamp, inflate, runsToPath, stated } from './kit/geometry';
|
|
54
|
+
export { CURVE_KEYS, curveValue, isCurve } from './kit/curve';
|
|
55
|
+
export type { CurveValues } from './kit/curve';
|
|
56
|
+
export { along, AXIS_COLOR, declareFormulas, drawLabels, drawn, lerpInterval, loadFormulas, PLOT_COLOR, readInterval, withoutTips } from './kit/furniture';
|
|
57
|
+
export type { Label, LabelStyle } from './kit/furniture';
|
|
58
|
+
export {
|
|
59
|
+
add, between, container, FOLLOW_COMMANDS, FOLLOW_STATE, followedQuad, grown, heading, outlineBounds, OWN_FRAME, resting,
|
|
60
|
+
} from './kit/follow';
|
|
61
|
+
export type { FollowProps, FollowValues, Parted, Quad, Retarget, Target } from './kit/follow';
|
|
62
|
+
export {
|
|
63
|
+
parseSpaceCurve, parseSurface, spaceCurveError, spaceCurveParams, surfaceError, surfaceParams, EQUATION_KINDS, EQUATION_VARIABLES_3D,
|
|
64
|
+
} from './kit/equation3d';
|
|
65
|
+
export type { EquationLanguage, SpaceCurveEquation, SurfaceEquation } from './kit/equation3d';
|
|
66
|
+
export { aim, graphEntry, graphOf, graphSpace, spaceOf, GRAPH_3D } from './three/space';
|
|
67
|
+
export type { Graph3D, GraphSpace } from './three/space';
|
|
68
|
+
export { domainEntry, meshEntries } from './three/entries';
|
|
69
|
+
export { drawLabel3D } from './three/label3d';
|
|
70
|
+
export type { LabelStyle3D } from './three/label3d';
|
|
71
|
+
// A traced path is a plot whose span follows a value, so a copied one builds on these rather than a copy of them.
|
|
72
|
+
export { FunctionPlot, PLOT_COMMANDS, PLOT_STATE, PLOT_STROKE, tracePlot } from './plots/function-plot';
|
|
73
|
+
export type { FunctionPlotProps, PlotValues } from './plots/function-plot';
|
|
74
|
+
export { drawField, FIELD_COMMANDS, FIELD_STATE, traceField } from './kit/field-mark';
|
|
75
|
+
export type { FieldDrawing, FieldProps, FieldSampler, FieldStroke, FieldValues } from './kit/field-mark';
|
|
76
|
+
export { fieldError, fieldParams, parseField, FIELD_VARIABLES } from './kit/field';
|
|
77
|
+
export type { FieldEquation } from './kit/field';
|
|
78
|
+
export { traceContour } from './kit/contour';
|
|
79
|
+
export { colorAt, fillAt, lerpFillScale, lerpScale, readFillScale, readScale } from './kit/scale';
|
|
80
|
+
export {
|
|
81
|
+
IDENTITY_MATRIX, isIdentityMatrix, lerpMatrix, lineThrough, readMatrix, transformedMap, warpedMap,
|
|
82
|
+
} from './kit/coords';
|
|
83
|
+
export type { Matrix2, Warp } from './kit/coords';
|
|
84
|
+
export { braceOutline } from './kit/brace';
|
|
85
|
+
export { GRAPH_LAYOUTS, layOut } from './structures/graph-layout';
|
|
86
|
+
export type { GraphEdge, GraphLayout } from './structures/graph-layout';
|
package/src/index.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export * from './tex/node';
|
|
2
|
-
export * from './tex/matrix';
|
|
3
|
-
export * from './systems/number-line';
|
|
4
|
-
export * from './systems/axes2d';
|
|
5
|
-
export * from './systems/number-plane';
|
|
6
|
-
export * from './plots/function-plot';
|
|
7
|
-
export * from './plots/points-plot';
|
|
8
|
-
export * from './marks/plot-point';
|
|
9
|
-
export * from './marks/vector-arrow';
|
|
10
|
-
export * from './marks/curve-area';
|
|
11
|
-
export * from './marks/riemann-sum';
|
|
12
|
-
export * from './marks/tangent-line';
|
|
13
|
-
export * from './marks/drop-lines';
|
|
14
|
-
export * from './annotate/curly-brace';
|
|
15
|
-
export * from './annotate/angle-mark';
|
|
16
|
-
export * from './annotate/emphasis-mark';
|
|
17
|
-
export * from './three/axes3d';
|
|
18
|
-
export * from './three/surface-plot3d';
|
|
19
|
-
export * from './three/curve-plot3d';
|
|
20
|
-
export * from './three/plot-point3d';
|
|
21
|
-
export * from './three/vector-arrow3d';
|
|
22
|
-
export * from './systems/polar-plane';
|
|
23
|
-
export * from './plots/vector-field';
|
|
24
|
-
export * from './plots/stream-lines';
|
|
25
|
-
export * from './plots/traced-path';
|
|
26
|
-
export * from './structures/network-graph';
|
|
27
|
-
export * from './structures/sample-space';
|
|
28
|
-
export * from './engine';
|
|
29
|
-
export { NODES } from "./nodes";
|
|
1
|
+
export * from './tex/node';
|
|
2
|
+
export * from './tex/matrix';
|
|
3
|
+
export * from './systems/number-line';
|
|
4
|
+
export * from './systems/axes2d';
|
|
5
|
+
export * from './systems/number-plane';
|
|
6
|
+
export * from './plots/function-plot';
|
|
7
|
+
export * from './plots/points-plot';
|
|
8
|
+
export * from './marks/plot-point';
|
|
9
|
+
export * from './marks/vector-arrow';
|
|
10
|
+
export * from './marks/curve-area';
|
|
11
|
+
export * from './marks/riemann-sum';
|
|
12
|
+
export * from './marks/tangent-line';
|
|
13
|
+
export * from './marks/drop-lines';
|
|
14
|
+
export * from './annotate/curly-brace';
|
|
15
|
+
export * from './annotate/angle-mark';
|
|
16
|
+
export * from './annotate/emphasis-mark';
|
|
17
|
+
export * from './three/axes3d';
|
|
18
|
+
export * from './three/surface-plot3d';
|
|
19
|
+
export * from './three/curve-plot3d';
|
|
20
|
+
export * from './three/plot-point3d';
|
|
21
|
+
export * from './three/vector-arrow3d';
|
|
22
|
+
export * from './systems/polar-plane';
|
|
23
|
+
export * from './plots/vector-field';
|
|
24
|
+
export * from './plots/stream-lines';
|
|
25
|
+
export * from './plots/traced-path';
|
|
26
|
+
export * from './structures/network-graph';
|
|
27
|
+
export * from './structures/sample-space';
|
|
28
|
+
export * from './engine';
|
|
29
|
+
export { NODES } from "./nodes";
|
package/src/kit/brace.ts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import type { PathCommand, Vector2 } from "@motionscript/sdk";
|
|
2
|
-
import { add, between, heading } from "./follow";
|
|
3
|
-
|
|
4
|
-
/** How far a quarter circle's control points sit along its tangents, as a share of its radius. */
|
|
5
|
-
const QUARTER = 0.5523;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A curly brace from `from` to `to`, bulging toward `out` (a unit vector) and
|
|
9
|
-
* `reach` deep at its tip: what a brace node draws, and a sample space beside
|
|
10
|
-
* its parts. Path commands, y-up.
|
|
11
|
-
*/
|
|
12
|
-
export function braceOutline(from: Vector2, to: Vector2, out: Vector2, reach: number): PathCommand[] {
|
|
13
|
-
const { unit, length } = heading(from, to);
|
|
14
|
-
if (length === 0) return [];
|
|
15
|
-
const r = Math.min(reach / 2, length / 4);
|
|
16
|
-
const mid = between(from, to);
|
|
17
|
-
const lift = (p: Vector2, k: number) => add(p, out, k * r);
|
|
18
|
-
const along = (p: Vector2, k: number) => add(p, unit, k * r);
|
|
19
|
-
const h = QUARTER;
|
|
20
|
-
const curve = (c1: Vector2, c2: Vector2, end: Vector2): PathCommand => ({
|
|
21
|
-
type: "C", x1: c1.x, y1: c1.y, x2: c2.x, y2: c2.y, x: end.x, y: end.y,
|
|
22
|
-
});
|
|
23
|
-
const a = lift(along(from, 1), 1);
|
|
24
|
-
const b = lift(along(mid, -1), 1);
|
|
25
|
-
const tip = lift(mid, 2);
|
|
26
|
-
const c = lift(along(mid, 1), 1);
|
|
27
|
-
const d = lift(along(to, -1), 1);
|
|
28
|
-
return [
|
|
29
|
-
{ type: "M", x: from.x, y: from.y },
|
|
30
|
-
curve(lift(from, h), lift(along(from, 1 - h), 1), a),
|
|
31
|
-
{ type: "L", x: b.x, y: b.y },
|
|
32
|
-
curve(lift(along(mid, -1 + h), 1), lift(mid, 2 - h), tip),
|
|
33
|
-
curve(lift(mid, 2 - h), lift(along(mid, 1 - h), 1), c),
|
|
34
|
-
{ type: "L", x: d.x, y: d.y },
|
|
35
|
-
curve(lift(along(to, -1 + h), 1), lift(to, h), to),
|
|
36
|
-
];
|
|
37
|
-
}
|
|
1
|
+
import type { PathCommand, Vector2 } from "@motionscript/sdk";
|
|
2
|
+
import { add, between, heading } from "./follow";
|
|
3
|
+
|
|
4
|
+
/** How far a quarter circle's control points sit along its tangents, as a share of its radius. */
|
|
5
|
+
const QUARTER = 0.5523;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A curly brace from `from` to `to`, bulging toward `out` (a unit vector) and
|
|
9
|
+
* `reach` deep at its tip: what a brace node draws, and a sample space beside
|
|
10
|
+
* its parts. Path commands, y-up.
|
|
11
|
+
*/
|
|
12
|
+
export function braceOutline(from: Vector2, to: Vector2, out: Vector2, reach: number): PathCommand[] {
|
|
13
|
+
const { unit, length } = heading(from, to);
|
|
14
|
+
if (length === 0) return [];
|
|
15
|
+
const r = Math.min(reach / 2, length / 4);
|
|
16
|
+
const mid = between(from, to);
|
|
17
|
+
const lift = (p: Vector2, k: number) => add(p, out, k * r);
|
|
18
|
+
const along = (p: Vector2, k: number) => add(p, unit, k * r);
|
|
19
|
+
const h = QUARTER;
|
|
20
|
+
const curve = (c1: Vector2, c2: Vector2, end: Vector2): PathCommand => ({
|
|
21
|
+
type: "C", x1: c1.x, y1: c1.y, x2: c2.x, y2: c2.y, x: end.x, y: end.y,
|
|
22
|
+
});
|
|
23
|
+
const a = lift(along(from, 1), 1);
|
|
24
|
+
const b = lift(along(mid, -1), 1);
|
|
25
|
+
const tip = lift(mid, 2);
|
|
26
|
+
const c = lift(along(mid, 1), 1);
|
|
27
|
+
const d = lift(along(to, -1), 1);
|
|
28
|
+
return [
|
|
29
|
+
{ type: "M", x: from.x, y: from.y },
|
|
30
|
+
curve(lift(from, h), lift(along(from, 1 - h), 1), a),
|
|
31
|
+
{ type: "L", x: b.x, y: b.y },
|
|
32
|
+
curve(lift(along(mid, -1 + h), 1), lift(mid, 2 - h), tip),
|
|
33
|
+
curve(lift(mid, 2 - h), lift(along(mid, 1 - h), 1), c),
|
|
34
|
+
{ type: "L", x: d.x, y: d.y },
|
|
35
|
+
curve(lift(along(to, -1 + h), 1), lift(to, h), to),
|
|
36
|
+
];
|
|
37
|
+
}
|