@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,115 @@
|
|
|
1
|
+
import { type Color, type NodeOf, type NodeView, type NormalizedColor, type Vector2, 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";
|
|
2
|
+
import { type FollowProps } from "../kit/follow.js";
|
|
3
|
+
export type BraceSide = "below" | "above" | "left" | "right";
|
|
4
|
+
export interface CurlyBraceProps extends FollowProps {
|
|
5
|
+
side?: BraceSide;
|
|
6
|
+
tail?: Vector2;
|
|
7
|
+
head?: Vector2;
|
|
8
|
+
clearance?: number;
|
|
9
|
+
reach?: number;
|
|
10
|
+
label?: string;
|
|
11
|
+
labelSize?: number;
|
|
12
|
+
labelColor?: Color;
|
|
13
|
+
fontFamily?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A curly brace along one side of a node or of a part of a formula, or between
|
|
17
|
+
* two points when it names neither, with an optional label at its tip. A label
|
|
18
|
+
* written between dollar signs is typeset.
|
|
19
|
+
*/
|
|
20
|
+
export declare const CurlyBrace: import("@motionscript/sdk").Component<"curlyBrace", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
21
|
+
side: import("@motionscript/sdk").Type<"right" | "left" | "below" | "above", "right" | "left" | "below" | "above", false>;
|
|
22
|
+
/** The two ends of a brace that follows nothing, from the brace's own position. It bulges to the left of tail to head. */
|
|
23
|
+
tail: import("@motionscript/sdk").Type<Vector2, Vector2, false>;
|
|
24
|
+
head: import("@motionscript/sdk").Type<Vector2, Vector2, false>;
|
|
25
|
+
/** The room between the target and the brace. (`gap` is a layout's.) */
|
|
26
|
+
clearance: import("@motionscript/sdk").Type<number, number, false>;
|
|
27
|
+
/** How far the brace reaches from its ends to its tip. (`depth` is a node's place in 3D.) */
|
|
28
|
+
reach: import("@motionscript/sdk").Type<number, number, false>;
|
|
29
|
+
label: import("@motionscript/sdk").Type<string, string, false>;
|
|
30
|
+
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
31
|
+
labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
|
|
32
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
33
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
34
|
+
part: import("@motionscript/sdk").Type<string, string, false>;
|
|
35
|
+
occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
36
|
+
retarget: import("@motionscript/sdk").Type<import("../index.js").Retarget | null, import("../index.js").Retarget | null, false>;
|
|
37
|
+
retargetOn: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
38
|
+
retargetFrom: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
39
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
40
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
41
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
42
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
43
|
+
}>, {
|
|
44
|
+
retargetTo: {
|
|
45
|
+
readonly on: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
|
|
46
|
+
readonly part: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
|
|
47
|
+
readonly occurrence: 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
|
+
}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
56
|
+
side: import("@motionscript/sdk").Type<"right" | "left" | "below" | "above", "right" | "left" | "below" | "above", false>;
|
|
57
|
+
/** The two ends of a brace that follows nothing, from the brace's own position. It bulges to the left of tail to head. */
|
|
58
|
+
tail: import("@motionscript/sdk").Type<Vector2, Vector2, false>;
|
|
59
|
+
head: import("@motionscript/sdk").Type<Vector2, Vector2, false>;
|
|
60
|
+
/** The room between the target and the brace. (`gap` is a layout's.) */
|
|
61
|
+
clearance: import("@motionscript/sdk").Type<number, number, false>;
|
|
62
|
+
/** How far the brace reaches from its ends to its tip. (`depth` is a node's place in 3D.) */
|
|
63
|
+
reach: import("@motionscript/sdk").Type<number, number, false>;
|
|
64
|
+
label: import("@motionscript/sdk").Type<string, string, false>;
|
|
65
|
+
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
66
|
+
labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
|
|
67
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
68
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
69
|
+
part: import("@motionscript/sdk").Type<string, string, false>;
|
|
70
|
+
occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
71
|
+
retarget: import("@motionscript/sdk").Type<import("../index.js").Retarget | null, import("../index.js").Retarget | null, false>;
|
|
72
|
+
retargetOn: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
73
|
+
retargetFrom: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
74
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
75
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
76
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
77
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
78
|
+
}>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
79
|
+
side: import("@motionscript/sdk").Type<"right" | "left" | "below" | "above", "right" | "left" | "below" | "above", false>;
|
|
80
|
+
/** The two ends of a brace that follows nothing, from the brace's own position. It bulges to the left of tail to head. */
|
|
81
|
+
tail: import("@motionscript/sdk").Type<Vector2, Vector2, false>;
|
|
82
|
+
head: import("@motionscript/sdk").Type<Vector2, Vector2, false>;
|
|
83
|
+
/** The room between the target and the brace. (`gap` is a layout's.) */
|
|
84
|
+
clearance: import("@motionscript/sdk").Type<number, number, false>;
|
|
85
|
+
/** How far the brace reaches from its ends to its tip. (`depth` is a node's place in 3D.) */
|
|
86
|
+
reach: import("@motionscript/sdk").Type<number, number, false>;
|
|
87
|
+
label: import("@motionscript/sdk").Type<string, string, false>;
|
|
88
|
+
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
89
|
+
labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
|
|
90
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
91
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
92
|
+
part: import("@motionscript/sdk").Type<string, string, false>;
|
|
93
|
+
occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
94
|
+
retarget: import("@motionscript/sdk").Type<import("../index.js").Retarget | null, import("../index.js").Retarget | null, false>;
|
|
95
|
+
retargetOn: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
96
|
+
retargetFrom: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
97
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
98
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
99
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
100
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
101
|
+
}>, {
|
|
102
|
+
retargetTo: {
|
|
103
|
+
readonly on: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
|
|
104
|
+
readonly part: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
|
|
105
|
+
readonly occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
106
|
+
};
|
|
107
|
+
strokeTo: readonly ["stroke"];
|
|
108
|
+
shadowTo: readonly ["shadow"];
|
|
109
|
+
progressTo: readonly ["start", "end"];
|
|
110
|
+
flash: {
|
|
111
|
+
readonly portion: import("@motionscript/sdk").Type<number, number, false>;
|
|
112
|
+
};
|
|
113
|
+
}, _Node2D<_Node2DProps>>>>;
|
|
114
|
+
export type CurlyBrace = NodeOf<typeof CurlyBrace>;
|
|
115
|
+
//# sourceMappingURL=curly-brace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"curly-brace.d.ts","sourceRoot":"","sources":["../../src/annotate/curly-brace.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,KAAK,EACV,KAAK,MAAM,EACX,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|
3
|
+
import { listed, painted } from "../kit/component.js";
|
|
4
|
+
import { add, between, container, FOLLOW_COMMANDS, FOLLOW_STATE, followedQuad, heading, outlineBounds, OWN_FRAME, resting, } from "../kit/follow.js";
|
|
5
|
+
import { drawLabels, loadFormulas } from "../kit/furniture.js";
|
|
6
|
+
import { strokeShape } from "../kit/mark.js";
|
|
7
|
+
/** The edge of a target a brace runs along, as two corner indexes of its quad, read with the brace's bulge to the left. */
|
|
8
|
+
const EDGE = {
|
|
9
|
+
below: [2, 3],
|
|
10
|
+
above: [0, 1],
|
|
11
|
+
left: [3, 0],
|
|
12
|
+
right: [1, 2],
|
|
13
|
+
};
|
|
14
|
+
const state = {
|
|
15
|
+
...FOLLOW_STATE,
|
|
16
|
+
side: listed(["below", "above", "left", "right"], "below", { animatable: false }),
|
|
17
|
+
/** The two ends of a brace that follows nothing, from the brace's own position. It bulges to the left of tail to head. */
|
|
18
|
+
tail: Types.vector2({ x: -80, y: 0 }),
|
|
19
|
+
head: Types.vector2({ x: 80, y: 0 }),
|
|
20
|
+
/** The room between the target and the brace. (`gap` is a layout's.) */
|
|
21
|
+
clearance: Types.number(8, { min: 0, unit: "px" }),
|
|
22
|
+
/** How far the brace reaches from its ends to its tip. (`depth` is a node's place in 3D.) */
|
|
23
|
+
reach: Types.number(18, { min: 2, unit: "px" }),
|
|
24
|
+
label: Types.text("", { animatable: false }),
|
|
25
|
+
labelSize: Types.number(28, { min: 1, unit: "px" }),
|
|
26
|
+
labelColor: Types.color("#e5e7eb"),
|
|
27
|
+
fontFamily: Types.text("", { animatable: false }),
|
|
28
|
+
};
|
|
29
|
+
/** Whether the brace follows nothing, and so spans its own two points. */
|
|
30
|
+
function spans(s, parted) {
|
|
31
|
+
return !s.retarget && resting(s, parted) === null;
|
|
32
|
+
}
|
|
33
|
+
/** No target: the span itself, as an edge with nothing above it. */
|
|
34
|
+
function quadOf(s, parted) {
|
|
35
|
+
return spans(s, parted) ? [s.head, s.tail, s.tail, s.head] : followedQuad(s, parted);
|
|
36
|
+
}
|
|
37
|
+
/** The edge the brace runs along, pushed out by the gap, and the way it bulges. */
|
|
38
|
+
function edgeOf(s, parted, quad) {
|
|
39
|
+
const [i, j] = spans(s, parted) ? [1, 0] : EDGE[s.side];
|
|
40
|
+
const { unit } = heading(quad[i], quad[j]);
|
|
41
|
+
// Left of the edge's own direction, in a y-up frame.
|
|
42
|
+
const out = { x: -unit.y, y: unit.x };
|
|
43
|
+
return { from: add(quad[i], out, s.clearance), to: add(quad[j], out, s.clearance), out };
|
|
44
|
+
}
|
|
45
|
+
function outline(s, parted) {
|
|
46
|
+
const quad = quadOf(s, parted);
|
|
47
|
+
if (!quad)
|
|
48
|
+
return [];
|
|
49
|
+
const { from, to, out } = edgeOf(s, parted, quad);
|
|
50
|
+
return braceOutline(from, to, out, s.reach);
|
|
51
|
+
}
|
|
52
|
+
/** One of the two ends to drag, while the brace spans them. */
|
|
53
|
+
const end = (which) => ({
|
|
54
|
+
at: (s) => (spans(s, container(null, s)) ? s[which] : null),
|
|
55
|
+
value: (at) => ({ x: at.x, y: at.y }),
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* A curly brace along one side of a node or of a part of a formula, or between
|
|
59
|
+
* two points when it names neither, with an optional label at its tip. A label
|
|
60
|
+
* written between dollar signs is typeset.
|
|
61
|
+
*/
|
|
62
|
+
export const CurlyBrace = component2d({
|
|
63
|
+
key: "curlyBrace",
|
|
64
|
+
state,
|
|
65
|
+
defaults: { stroke: { weight: 3, fill: "#e5e7eb", align: "center", cap: "round", join: "round" }, width: "hug", height: "hug" },
|
|
66
|
+
load: (loader, s) => {
|
|
67
|
+
if (s.label !== "" && s.fontFamily !== "")
|
|
68
|
+
loader.font(s.fontFamily);
|
|
69
|
+
loadFormulas(loader, [s.label]);
|
|
70
|
+
},
|
|
71
|
+
commands: FOLLOW_COMMANDS,
|
|
72
|
+
handles: { tail: end("tail"), head: end("head") },
|
|
73
|
+
measure: () => ({ width: 0, height: 0 }),
|
|
74
|
+
bounds: (_size, s) => outlineBounds(outline(s, container(null, s))),
|
|
75
|
+
render: (ctx, s) => {
|
|
76
|
+
const parted = container(ctx, s);
|
|
77
|
+
const data = outline(s, parted);
|
|
78
|
+
const shape = data.length > 0 ? () => new Graphics2D().path({ data, centerBounds: OWN_FRAME, start: s.start, end: s.end }) : null;
|
|
79
|
+
painted(ctx, () => {
|
|
80
|
+
if (shape)
|
|
81
|
+
ctx.draw(shape().shadow(s.shadow).fill([]));
|
|
82
|
+
if (s.label === "")
|
|
83
|
+
return;
|
|
84
|
+
const quad = quadOf(s, parted);
|
|
85
|
+
if (!quad)
|
|
86
|
+
return;
|
|
87
|
+
const { from, to, out } = edgeOf(s, parted, quad);
|
|
88
|
+
const reach = Math.min(s.reach, heading(from, to).length / 2) + s.labelSize * 0.75;
|
|
89
|
+
const at = add(between(from, to), out, reach);
|
|
90
|
+
const align = out.x > 0.5 ? "left" : out.x < -0.5 ? "right" : "center";
|
|
91
|
+
const style = { fontSize: s.labelSize, fontFamily: s.fontFamily, color: s.labelColor };
|
|
92
|
+
ctx.draw(drawLabels([{ text: s.label, at, align }], style));
|
|
93
|
+
}, () => {
|
|
94
|
+
if (shape)
|
|
95
|
+
strokeShape(ctx, shape, s);
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=curly-brace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"curly-brace.js","sourceRoot":"","sources":["../../src/annotate/curly-brace.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,UAAU,EACV,KAAK,GAcR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACH,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE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EAAE;YACD,IAAI,KAAK;gBAAE,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QAC1C,CAAC,CACJ,CAAC;IACN,CAAC;CACJ,CAAC,CAAC","sourcesContent":["import {\n component2d,\n Graphics2D,\n Types,\n type Color,\n type NodeOf,\n type NodeView,\n type NormalizedColor,\n type PathCommand,\n type Vector2,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n} from \"@motionscript/sdk\";\nimport { braceOutline } from \"../kit/brace\";\nimport { listed, painted } from \"../kit/component\";\nimport {\n add, between, container, FOLLOW_COMMANDS, FOLLOW_STATE, followedQuad, heading, outlineBounds, OWN_FRAME, resting,\n type FollowProps, type FollowValues, type Quad,\n} from \"../kit/follow\";\nimport { drawLabels, loadFormulas } from \"../kit/furniture\";\nimport { strokeShape } from \"../kit/mark\";\n\nexport type BraceSide = \"below\" | \"above\" | \"left\" | \"right\";\n\nexport interface CurlyBraceProps extends FollowProps {\n side?: BraceSide;\n tail?: Vector2;\n head?: Vector2;\n clearance?: number;\n reach?: number;\n label?: string;\n labelSize?: number;\n labelColor?: Color;\n fontFamily?: string;\n}\n\n/** The edge of a target a brace runs along, as two corner indexes of its quad, read with the brace's bulge to the left. */\nconst EDGE: Record<BraceSide, [number, number]> = {\n below: [2, 3],\n above: [0, 1],\n left: [3, 0],\n right: [1, 2],\n};\n\nconst state = {\n ...FOLLOW_STATE,\n side: listed([\"below\", \"above\", \"left\", \"right\"], \"below\", { animatable: false }),\n /** The two ends of a brace that follows nothing, from the brace's own position. It bulges to the left of tail to head. */\n tail: Types.vector2({ x: -80, y: 0 }),\n head: Types.vector2({ x: 80, y: 0 }),\n /** The room between the target and the brace. (`gap` is a layout's.) */\n clearance: Types.number(8, { min: 0, unit: \"px\" }),\n /** How far the brace reaches from its ends to its tip. (`depth` is a node's place in 3D.) */\n reach: Types.number(18, { min: 2, unit: \"px\" }),\n label: Types.text(\"\", { animatable: false }),\n labelSize: Types.number(28, { min: 1, unit: \"px\" }),\n labelColor: Types.color(\"#e5e7eb\"),\n fontFamily: Types.text(\"\", { animatable: false }),\n};\n\ninterface BraceValues extends FollowValues {\n readonly side: BraceSide;\n readonly tail: Vector2;\n readonly head: Vector2;\n readonly clearance: number;\n readonly reach: number;\n}\n\n/** Whether the brace follows nothing, and so spans its own two points. */\nfunction spans(s: BraceValues, parted: NodeView | null): boolean {\n return !s.retarget && resting(s, parted) === null;\n}\n\n/** No target: the span itself, as an edge with nothing above it. */\nfunction quadOf(s: BraceValues, parted: NodeView | null): Quad | null {\n return spans(s, parted) ? [s.head, s.tail, s.tail, s.head] : followedQuad(s, parted);\n}\n\n/** The edge the brace runs along, pushed out by the gap, and the way it bulges. */\nfunction edgeOf(s: BraceValues, parted: NodeView | null, quad: Quad): { from: Vector2; to: Vector2; out: Vector2 } {\n const [i, j] = spans(s, parted) ? [1, 0] : EDGE[s.side];\n const { unit } = heading(quad[i], quad[j]);\n // Left of the edge's own direction, in a y-up frame.\n const out = { x: -unit.y, y: unit.x };\n return { from: add(quad[i], out, s.clearance), to: add(quad[j], out, s.clearance), out };\n}\n\nfunction outline(s: BraceValues, parted: NodeView | null): PathCommand[] {\n const quad = quadOf(s, parted);\n if (!quad) return [];\n const { from, to, out } = edgeOf(s, parted, quad);\n return braceOutline(from, to, out, s.reach);\n}\n\n/** One of the two ends to drag, while the brace spans them. */\nconst end = (which: \"tail\" | \"head\") => ({\n at: (s: BraceValues) => (spans(s, container(null, s)) ? s[which] : null),\n value: (at: Vector2) => ({ x: at.x, y: at.y }),\n});\n\n/**\n * A curly brace along one side of a node or of a part of a formula, or between\n * two points when it names neither, with an optional label at its tip. A label\n * written between dollar signs is typeset.\n */\nexport const CurlyBrace = component2d({\n key: \"curlyBrace\",\n state,\n defaults: { stroke: { weight: 3, fill: \"#e5e7eb\", align: \"center\", cap: \"round\", join: \"round\" }, width: \"hug\", height: \"hug\" },\n load: (loader, s) => {\n if (s.label !== \"\" && s.fontFamily !== \"\") loader.font(s.fontFamily);\n loadFormulas(loader, [s.label]);\n },\n commands: FOLLOW_COMMANDS,\n handles: { tail: end(\"tail\"), head: end(\"head\") },\n measure: () => ({ width: 0, height: 0 }),\n bounds: (_size, s) => outlineBounds(outline(s, container(null, s))),\n render: (ctx, s) => {\n const parted = container(ctx, s);\n const data = outline(s, parted);\n const shape = data.length > 0 ? () => new Graphics2D().path({ data, centerBounds: OWN_FRAME, start: s.start, end: s.end }) : null;\n painted(\n ctx,\n () => {\n if (shape) ctx.draw(shape().shadow(s.shadow).fill([]));\n if (s.label === \"\") return;\n const quad = quadOf(s, parted);\n if (!quad) return;\n const { from, to, out } = edgeOf(s, parted, quad);\n const reach = Math.min(s.reach, heading(from, to).length / 2) + s.labelSize * 0.75;\n const at = add(between(from, to), out, reach);\n const align = out.x > 0.5 ? \"left\" : out.x < -0.5 ? \"right\" : \"center\";\n const style = { fontSize: s.labelSize, fontFamily: s.fontFamily, color: s.labelColor as NormalizedColor };\n ctx.draw(drawLabels([{ text: s.label, at, align }], style));\n },\n () => {\n if (shape) strokeShape(ctx, shape, s);\n },\n );\n },\n});\n\nexport type CurlyBrace = NodeOf<typeof CurlyBrace>;\n"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type NodeOf, type NodeView, 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";
|
|
2
|
+
import { type FollowProps } from "../kit/follow.js";
|
|
3
|
+
export type EmphasisShape = "box" | "circle" | "underline" | "cross";
|
|
4
|
+
export interface EmphasisMarkProps extends FollowProps {
|
|
5
|
+
shape?: EmphasisShape;
|
|
6
|
+
clearance?: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A box, a circle, an underline or a cross drawn on a node, or on one part of
|
|
10
|
+
* a formula. `progressTo` draws it on, and `retargetTo` slides it to another.
|
|
11
|
+
*/
|
|
12
|
+
export declare const EmphasisMark: import("@motionscript/sdk").Component<"emphasisMark", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
13
|
+
shape: import("@motionscript/sdk").Type<"box" | "cross" | "circle" | "underline", "box" | "cross" | "circle" | "underline", false>;
|
|
14
|
+
/** The room between the target and the mark. (`gap` is a layout's.) */
|
|
15
|
+
clearance: import("@motionscript/sdk").Type<number, number, false>;
|
|
16
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
17
|
+
part: import("@motionscript/sdk").Type<string, string, false>;
|
|
18
|
+
occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
19
|
+
retarget: import("@motionscript/sdk").Type<import("../index.js").Retarget | null, import("../index.js").Retarget | null, false>;
|
|
20
|
+
retargetOn: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
21
|
+
retargetFrom: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
22
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
23
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
24
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
25
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
26
|
+
}>, {
|
|
27
|
+
retargetTo: {
|
|
28
|
+
readonly on: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
|
|
29
|
+
readonly part: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
|
|
30
|
+
readonly occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
31
|
+
};
|
|
32
|
+
strokeTo: readonly ["stroke"];
|
|
33
|
+
shadowTo: readonly ["shadow"];
|
|
34
|
+
progressTo: readonly ["start", "end"];
|
|
35
|
+
flash: {
|
|
36
|
+
readonly portion: import("@motionscript/sdk").Type<number, number, false>;
|
|
37
|
+
};
|
|
38
|
+
}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
39
|
+
shape: import("@motionscript/sdk").Type<"box" | "cross" | "circle" | "underline", "box" | "cross" | "circle" | "underline", false>;
|
|
40
|
+
/** The room between the target and the mark. (`gap` is a layout's.) */
|
|
41
|
+
clearance: import("@motionscript/sdk").Type<number, number, false>;
|
|
42
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
43
|
+
part: import("@motionscript/sdk").Type<string, string, false>;
|
|
44
|
+
occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
45
|
+
retarget: import("@motionscript/sdk").Type<import("../index.js").Retarget | null, import("../index.js").Retarget | null, false>;
|
|
46
|
+
retargetOn: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
47
|
+
retargetFrom: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
48
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
49
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
50
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
51
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
52
|
+
}>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
53
|
+
shape: import("@motionscript/sdk").Type<"box" | "cross" | "circle" | "underline", "box" | "cross" | "circle" | "underline", false>;
|
|
54
|
+
/** The room between the target and the mark. (`gap` is a layout's.) */
|
|
55
|
+
clearance: import("@motionscript/sdk").Type<number, number, false>;
|
|
56
|
+
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
57
|
+
part: import("@motionscript/sdk").Type<string, string, false>;
|
|
58
|
+
occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
59
|
+
retarget: import("@motionscript/sdk").Type<import("../index.js").Retarget | null, import("../index.js").Retarget | null, false>;
|
|
60
|
+
retargetOn: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
61
|
+
retargetFrom: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, true>;
|
|
62
|
+
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
63
|
+
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
64
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
65
|
+
shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
66
|
+
}>, {
|
|
67
|
+
retargetTo: {
|
|
68
|
+
readonly on: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
|
|
69
|
+
readonly part: import("@motionscript/sdk").Type<string | undefined, string | undefined, false>;
|
|
70
|
+
readonly occurrence: import("@motionscript/sdk").Type<number, number, false>;
|
|
71
|
+
};
|
|
72
|
+
strokeTo: readonly ["stroke"];
|
|
73
|
+
shadowTo: readonly ["shadow"];
|
|
74
|
+
progressTo: readonly ["start", "end"];
|
|
75
|
+
flash: {
|
|
76
|
+
readonly portion: import("@motionscript/sdk").Type<number, number, false>;
|
|
77
|
+
};
|
|
78
|
+
}, _Node2D<_Node2DProps>>>>;
|
|
79
|
+
export type EmphasisMark = NodeOf<typeof EmphasisMark>;
|
|
80
|
+
//# sourceMappingURL=emphasis-mark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emphasis-mark.d.ts","sourceRoot":"","sources":["../../src/annotate/emphasis-mark.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,MAAM,EACX,KAAK,QAAQ,EAIb,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;AAE3B,OAAO,EAC6G,KAAK,WAAW,EACnI,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAErE,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IAClD,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAgED;;;GAGG;AACH,eAAO,MAAM,YAAY;;IAlBrB,uEAAuE;;;;;;;;;;;;;;;;;;;;;;;;;;IAAvE,uEAAuE;;;;;;;;;;;;;;IAAvE,uEAAuE;;;;;;;;;;;;;;;;;;;;;;;;2BAsCzE,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { component2d, Graphics2D, Types, } from "@motionscript/sdk";
|
|
2
|
+
import { listed, painted } from "../kit/component.js";
|
|
3
|
+
import { add, between, container, FOLLOW_COMMANDS, FOLLOW_STATE, followedQuad, grown, heading, outlineBounds, OWN_FRAME, } from "../kit/follow.js";
|
|
4
|
+
import { strokeShape } from "../kit/mark.js";
|
|
5
|
+
/** How far a cubic's handle reaches to draw a quarter of an ellipse. */
|
|
6
|
+
const QUARTER = 0.5523;
|
|
7
|
+
const line = (a, b) => [
|
|
8
|
+
{ type: "M", x: a.x, y: a.y },
|
|
9
|
+
{ type: "L", x: b.x, y: b.y },
|
|
10
|
+
];
|
|
11
|
+
const SHAPES = {
|
|
12
|
+
box: (quad, gap) => {
|
|
13
|
+
const [tl, tr, br, bl] = grown(quad, gap);
|
|
14
|
+
return [{ type: "M", x: tl.x, y: tl.y }, ...[tr, br, bl].map((p) => ({ type: "L", x: p.x, y: p.y })), { type: "Z" }];
|
|
15
|
+
},
|
|
16
|
+
// The ellipse through the grown box's corners.
|
|
17
|
+
circle: (quad, gap) => {
|
|
18
|
+
const [tl, tr, br, bl] = grown(quad, gap);
|
|
19
|
+
const centre = between(tl, br);
|
|
20
|
+
const across = { x: ((tr.x - tl.x) / 2) * Math.SQRT2, y: ((tr.y - tl.y) / 2) * Math.SQRT2 };
|
|
21
|
+
const up = { x: ((tl.x - bl.x) / 2) * Math.SQRT2, y: ((tl.y - bl.y) / 2) * Math.SQRT2 };
|
|
22
|
+
const at = (a, u) => add(add(centre, across, a), up, u);
|
|
23
|
+
const arc = (c1, c2, end) => ({
|
|
24
|
+
type: "C", x1: c1.x, y1: c1.y, x2: c2.x, y2: c2.y, x: end.x, y: end.y,
|
|
25
|
+
});
|
|
26
|
+
const k = QUARTER;
|
|
27
|
+
const start = at(0, 1);
|
|
28
|
+
return [
|
|
29
|
+
{ type: "M", x: start.x, y: start.y },
|
|
30
|
+
arc(at(k, 1), at(1, k), at(1, 0)),
|
|
31
|
+
arc(at(1, -k), at(k, -1), at(0, -1)),
|
|
32
|
+
arc(at(-k, -1), at(-1, -k), at(-1, 0)),
|
|
33
|
+
arc(at(-1, k), at(-k, 1), start),
|
|
34
|
+
{ type: "Z" },
|
|
35
|
+
];
|
|
36
|
+
},
|
|
37
|
+
underline: (quad, gap) => {
|
|
38
|
+
const [, , br, bl] = quad;
|
|
39
|
+
const down = heading(quad[0], bl).unit;
|
|
40
|
+
return line(add(bl, down, gap), add(br, down, gap));
|
|
41
|
+
},
|
|
42
|
+
cross: (quad, gap) => {
|
|
43
|
+
const [tl, tr, br, bl] = grown(quad, gap);
|
|
44
|
+
return [...line(tl, br), ...line(bl, tr)];
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const state = {
|
|
48
|
+
...FOLLOW_STATE,
|
|
49
|
+
shape: listed(["box", "circle", "underline", "cross"], "box", { animatable: false }),
|
|
50
|
+
/** The room between the target and the mark. (`gap` is a layout's.) */
|
|
51
|
+
clearance: Types.number(10, { unit: "px" }),
|
|
52
|
+
};
|
|
53
|
+
function outline(s, parted) {
|
|
54
|
+
const quad = followedQuad(s, parted);
|
|
55
|
+
return quad ? SHAPES[s.shape](quad, s.clearance) : [];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A box, a circle, an underline or a cross drawn on a node, or on one part of
|
|
59
|
+
* a formula. `progressTo` draws it on, and `retargetTo` slides it to another.
|
|
60
|
+
*/
|
|
61
|
+
export const EmphasisMark = component2d({
|
|
62
|
+
key: "emphasisMark",
|
|
63
|
+
state,
|
|
64
|
+
defaults: { stroke: { weight: 3, fill: "#facc15", align: "center", cap: "round", join: "round" }, width: "hug", height: "hug" },
|
|
65
|
+
commands: FOLLOW_COMMANDS,
|
|
66
|
+
measure: () => ({ width: 0, height: 0 }),
|
|
67
|
+
bounds: (_size, s) => outlineBounds(outline(s, container(null, s))),
|
|
68
|
+
render: (ctx, s) => {
|
|
69
|
+
const data = outline(s, container(ctx, s));
|
|
70
|
+
const shape = data.length > 0 ? () => new Graphics2D().path({ data, centerBounds: OWN_FRAME, start: s.start, end: s.end }) : null;
|
|
71
|
+
painted(ctx, () => {
|
|
72
|
+
if (shape)
|
|
73
|
+
ctx.draw(shape().shadow(s.shadow).fill([]));
|
|
74
|
+
}, () => {
|
|
75
|
+
if (shape)
|
|
76
|
+
strokeShape(ctx, shape, s);
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=emphasis-mark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emphasis-mark.js","sourceRoot":"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n component2d,\n Graphics2D,\n Types,\n type NodeOf,\n type NodeView,\n type PathCommand,\n type Vector2,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n} from \"@motionscript/sdk\";\nimport { listed, painted } from \"../kit/component\";\nimport {\n add, between, container, FOLLOW_COMMANDS, FOLLOW_STATE, followedQuad, grown, heading, outlineBounds, OWN_FRAME, type FollowProps, type FollowValues, type Quad,\n} from \"../kit/follow\";\nimport { strokeShape } from \"../kit/mark\";\n\nexport type EmphasisShape = \"box\" | \"circle\" | \"underline\" | \"cross\";\n\nexport interface EmphasisMarkProps extends FollowProps {\n shape?: EmphasisShape;\n clearance?: number;\n}\n\n/** How far a cubic's handle reaches to draw a quarter of an ellipse. */\nconst QUARTER = 0.5523;\n\nconst line = (a: Vector2, b: Vector2): PathCommand[] => [\n { type: \"M\", x: a.x, y: a.y },\n { type: \"L\", x: b.x, y: b.y },\n];\n\nconst SHAPES: Record<EmphasisShape, (quad: Quad, gap: number) => PathCommand[]> = {\n box: (quad, gap) => {\n const [tl, tr, br, bl] = grown(quad, gap);\n 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\" }];\n },\n // The ellipse through the grown box's corners.\n circle: (quad, gap) => {\n const [tl, tr, br, bl] = grown(quad, gap);\n const centre = between(tl, br);\n const across = { x: ((tr.x - tl.x) / 2) * Math.SQRT2, y: ((tr.y - tl.y) / 2) * Math.SQRT2 };\n const up = { x: ((tl.x - bl.x) / 2) * Math.SQRT2, y: ((tl.y - bl.y) / 2) * Math.SQRT2 };\n const at = (a: number, u: number) => add(add(centre, across, a), up, u);\n const arc = (c1: Vector2, c2: Vector2, end: Vector2): PathCommand => ({\n type: \"C\", x1: c1.x, y1: c1.y, x2: c2.x, y2: c2.y, x: end.x, y: end.y,\n });\n const k = QUARTER;\n const start = at(0, 1);\n return [\n { type: \"M\", x: start.x, y: start.y },\n arc(at(k, 1), at(1, k), at(1, 0)),\n arc(at(1, -k), at(k, -1), at(0, -1)),\n arc(at(-k, -1), at(-1, -k), at(-1, 0)),\n arc(at(-1, k), at(-k, 1), start),\n { type: \"Z\" },\n ];\n },\n underline: (quad, gap) => {\n const [, , br, bl] = quad;\n const down = heading(quad[0], bl).unit;\n return line(add(bl, down, gap), add(br, down, gap));\n },\n cross: (quad, gap) => {\n const [tl, tr, br, bl] = grown(quad, gap);\n return [...line(tl, br), ...line(bl, tr)];\n },\n};\n\nconst state = {\n ...FOLLOW_STATE,\n shape: listed([\"box\", \"circle\", \"underline\", \"cross\"], \"box\", { animatable: false }),\n /** The room between the target and the mark. (`gap` is a layout's.) */\n clearance: Types.number(10, { unit: \"px\" }),\n};\n\ninterface EmphasisValues extends FollowValues {\n readonly shape: EmphasisShape;\n readonly clearance: number;\n}\n\nfunction outline(s: EmphasisValues, parted: NodeView | null): PathCommand[] {\n const quad = followedQuad(s, parted);\n return quad ? SHAPES[s.shape](quad, s.clearance) : [];\n}\n\n/**\n * A box, a circle, an underline or a cross drawn on a node, or on one part of\n * a formula. `progressTo` draws it on, and `retargetTo` slides it to another.\n */\nexport const EmphasisMark = component2d({\n key: \"emphasisMark\",\n state,\n defaults: { stroke: { weight: 3, fill: \"#facc15\", align: \"center\", cap: \"round\", join: \"round\" }, width: \"hug\", height: \"hug\" },\n commands: FOLLOW_COMMANDS,\n measure: () => ({ width: 0, height: 0 }),\n bounds: (_size, s) => outlineBounds(outline(s, container(null, s))),\n render: (ctx, s) => {\n const data = outline(s, container(ctx, s));\n const shape = data.length > 0 ? () => new Graphics2D().path({ data, centerBounds: OWN_FRAME, start: s.start, end: s.end }) : null;\n painted(\n ctx,\n () => {\n if (shape) ctx.draw(shape().shadow(s.shadow).fill([]));\n },\n () => {\n if (shape) strokeShape(ctx, shape, s);\n },\n );\n },\n});\n\nexport type EmphasisMark = NodeOf<typeof EmphasisMark>;\n"]}
|