@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.
Files changed (233) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +39 -33
  3. package/dist/annotate/angle-mark.d.ts +77 -27
  4. package/dist/annotate/angle-mark.d.ts.map +1 -1
  5. package/dist/annotate/angle-mark.js +80 -115
  6. package/dist/annotate/angle-mark.js.map +1 -1
  7. package/dist/annotate/curly-brace.d.ts +94 -25
  8. package/dist/annotate/curly-brace.d.ts.map +1 -1
  9. package/dist/annotate/curly-brace.js +85 -100
  10. package/dist/annotate/curly-brace.js.map +1 -1
  11. package/dist/annotate/emphasis-mark.d.ts +69 -9
  12. package/dist/annotate/emphasis-mark.d.ts.map +1 -1
  13. package/dist/annotate/emphasis-mark.js +33 -34
  14. package/dist/annotate/emphasis-mark.js.map +1 -1
  15. package/dist/browser/chunks/chunk-ABYBW64J.js +2 -0
  16. package/dist/browser/chunks/chunk-ABYBW64J.js.map +7 -0
  17. package/dist/browser/chunks/chunk-K77KLQX4.js +2 -0
  18. package/dist/browser/chunks/chunk-K77KLQX4.js.map +7 -0
  19. package/dist/browser/index.js +1 -1
  20. package/dist/browser/index.js.map +3 -3
  21. package/dist/browser/kit.js +1 -1
  22. package/dist/browser/manifest.json +1 -1
  23. package/dist/browser/tex.js +1 -1
  24. package/dist/browser/tex.js.map +2 -2
  25. package/dist/engine.d.ts +26 -19
  26. package/dist/engine.d.ts.map +1 -1
  27. package/dist/engine.js +17 -14
  28. package/dist/engine.js.map +1 -1
  29. package/dist/kit/component.d.ts +51 -0
  30. package/dist/kit/component.d.ts.map +1 -0
  31. package/dist/kit/component.js +30 -0
  32. package/dist/kit/component.js.map +1 -0
  33. package/dist/kit/curve.d.ts +22 -11
  34. package/dist/kit/curve.d.ts.map +1 -1
  35. package/dist/kit/curve.js +25 -18
  36. package/dist/kit/curve.js.map +1 -1
  37. package/dist/kit/field-mark.d.ts +56 -35
  38. package/dist/kit/field-mark.d.ts.map +1 -1
  39. package/dist/kit/field-mark.js +100 -120
  40. package/dist/kit/field-mark.js.map +1 -1
  41. package/dist/kit/follow.d.ts +67 -29
  42. package/dist/kit/follow.d.ts.map +1 -1
  43. package/dist/kit/follow.js +114 -110
  44. package/dist/kit/follow.js.map +1 -1
  45. package/dist/kit/furniture.d.ts +3 -1
  46. package/dist/kit/furniture.d.ts.map +1 -1
  47. package/dist/kit/furniture.js +5 -0
  48. package/dist/kit/furniture.js.map +1 -1
  49. package/dist/kit/graph.d.ts +46 -0
  50. package/dist/kit/graph.d.ts.map +1 -0
  51. package/dist/kit/graph.js +90 -0
  52. package/dist/kit/graph.js.map +1 -0
  53. package/dist/kit/mark.d.ts +64 -39
  54. package/dist/kit/mark.d.ts.map +1 -1
  55. package/dist/kit/mark.js +80 -96
  56. package/dist/kit/mark.js.map +1 -1
  57. package/dist/kit/place.d.ts +10 -8
  58. package/dist/kit/place.d.ts.map +1 -1
  59. package/dist/kit/place.js +28 -30
  60. package/dist/kit/place.js.map +1 -1
  61. package/dist/kit/system.d.ts +27 -29
  62. package/dist/kit/system.d.ts.map +1 -1
  63. package/dist/kit/system.js +62 -58
  64. package/dist/kit/system.js.map +1 -1
  65. package/dist/kit/withdrawn.d.ts +3 -3
  66. package/dist/kit/withdrawn.js +3 -3
  67. package/dist/kit/withdrawn.js.map +1 -1
  68. package/dist/marks/curve-area.d.ts +37 -18
  69. package/dist/marks/curve-area.d.ts.map +1 -1
  70. package/dist/marks/curve-area.js +50 -73
  71. package/dist/marks/curve-area.js.map +1 -1
  72. package/dist/marks/drop-lines.d.ts +45 -10
  73. package/dist/marks/drop-lines.d.ts.map +1 -1
  74. package/dist/marks/drop-lines.js +37 -52
  75. package/dist/marks/drop-lines.js.map +1 -1
  76. package/dist/marks/plot-point.d.ts +56 -20
  77. package/dist/marks/plot-point.d.ts.map +1 -1
  78. package/dist/marks/plot-point.js +65 -91
  79. package/dist/marks/plot-point.js.map +1 -1
  80. package/dist/marks/riemann-sum.d.ts +47 -26
  81. package/dist/marks/riemann-sum.d.ts.map +1 -1
  82. package/dist/marks/riemann-sum.js +57 -85
  83. package/dist/marks/riemann-sum.js.map +1 -1
  84. package/dist/marks/tangent-line.d.ts +58 -14
  85. package/dist/marks/tangent-line.d.ts.map +1 -1
  86. package/dist/marks/tangent-line.js +73 -87
  87. package/dist/marks/tangent-line.js.map +1 -1
  88. package/dist/marks/vector-arrow.d.ts +48 -20
  89. package/dist/marks/vector-arrow.d.ts.map +1 -1
  90. package/dist/marks/vector-arrow.js +58 -78
  91. package/dist/marks/vector-arrow.js.map +1 -1
  92. package/dist/nodes.d.ts +13 -5
  93. package/dist/nodes.d.ts.map +1 -1
  94. package/dist/nodes.js +0 -6
  95. package/dist/nodes.js.map +1 -1
  96. package/dist/plots/function-plot.d.ts +135 -43
  97. package/dist/plots/function-plot.d.ts.map +1 -1
  98. package/dist/plots/function-plot.js +146 -177
  99. package/dist/plots/function-plot.js.map +1 -1
  100. package/dist/plots/points-plot.d.ts +55 -19
  101. package/dist/plots/points-plot.d.ts.map +1 -1
  102. package/dist/plots/points-plot.js +31 -58
  103. package/dist/plots/points-plot.js.map +1 -1
  104. package/dist/plots/stream-lines.d.ts +60 -19
  105. package/dist/plots/stream-lines.d.ts.map +1 -1
  106. package/dist/plots/stream-lines.js +60 -79
  107. package/dist/plots/stream-lines.js.map +1 -1
  108. package/dist/plots/traced-path.d.ts +54 -15
  109. package/dist/plots/traced-path.d.ts.map +1 -1
  110. package/dist/plots/traced-path.js +33 -48
  111. package/dist/plots/traced-path.js.map +1 -1
  112. package/dist/plots/vector-field.d.ts +48 -11
  113. package/dist/plots/vector-field.d.ts.map +1 -1
  114. package/dist/plots/vector-field.js +50 -64
  115. package/dist/plots/vector-field.js.map +1 -1
  116. package/dist/structures/network-graph.d.ts +140 -49
  117. package/dist/structures/network-graph.d.ts.map +1 -1
  118. package/dist/structures/network-graph.js +168 -217
  119. package/dist/structures/network-graph.js.map +1 -1
  120. package/dist/structures/sample-space.d.ts +90 -38
  121. package/dist/structures/sample-space.d.ts.map +1 -1
  122. package/dist/structures/sample-space.js +132 -170
  123. package/dist/structures/sample-space.js.map +1 -1
  124. package/dist/systems/axes2d.d.ts +159 -37
  125. package/dist/systems/axes2d.d.ts.map +1 -1
  126. package/dist/systems/axes2d.js +147 -183
  127. package/dist/systems/axes2d.js.map +1 -1
  128. package/dist/systems/number-line.d.ts +80 -28
  129. package/dist/systems/number-line.d.ts.map +1 -1
  130. package/dist/systems/number-line.js +82 -118
  131. package/dist/systems/number-line.js.map +1 -1
  132. package/dist/systems/number-plane.d.ts +140 -31
  133. package/dist/systems/number-plane.d.ts.map +1 -1
  134. package/dist/systems/number-plane.js +142 -149
  135. package/dist/systems/number-plane.js.map +1 -1
  136. package/dist/systems/polar-plane.d.ts +76 -26
  137. package/dist/systems/polar-plane.d.ts.map +1 -1
  138. package/dist/systems/polar-plane.js +107 -133
  139. package/dist/systems/polar-plane.js.map +1 -1
  140. package/dist/tex/index.d.ts.map +1 -1
  141. package/dist/tex/index.js +1 -0
  142. package/dist/tex/index.js.map +1 -1
  143. package/dist/tex/matrix.d.ts +88 -18
  144. package/dist/tex/matrix.d.ts.map +1 -1
  145. package/dist/tex/matrix.js +33 -50
  146. package/dist/tex/matrix.js.map +1 -1
  147. package/dist/tex/node.d.ts +84 -201
  148. package/dist/tex/node.d.ts.map +1 -1
  149. package/dist/tex/node.js +23 -593
  150. package/dist/tex/node.js.map +1 -1
  151. package/dist/tex/typeset.d.ts +133 -0
  152. package/dist/tex/typeset.d.ts.map +1 -0
  153. package/dist/tex/typeset.js +403 -0
  154. package/dist/tex/typeset.js.map +1 -0
  155. package/dist/three/axes3d.d.ts +214 -54
  156. package/dist/three/axes3d.d.ts.map +1 -1
  157. package/dist/three/axes3d.js +163 -204
  158. package/dist/three/axes3d.js.map +1 -1
  159. package/dist/three/curve-plot3d.d.ts +108 -42
  160. package/dist/three/curve-plot3d.d.ts.map +1 -1
  161. package/dist/three/curve-plot3d.js +97 -132
  162. package/dist/three/curve-plot3d.js.map +1 -1
  163. package/dist/three/entries.d.ts +17 -0
  164. package/dist/three/entries.d.ts.map +1 -0
  165. package/dist/three/entries.js +15 -0
  166. package/dist/three/entries.js.map +1 -0
  167. package/dist/three/plot-point3d.d.ts +85 -12
  168. package/dist/three/plot-point3d.d.ts.map +1 -1
  169. package/dist/three/plot-point3d.js +27 -53
  170. package/dist/three/plot-point3d.js.map +1 -1
  171. package/dist/three/space.d.ts +17 -2
  172. package/dist/three/space.d.ts.map +1 -1
  173. package/dist/three/space.js +19 -8
  174. package/dist/three/space.js.map +1 -1
  175. package/dist/three/surface-plot3d.d.ts +176 -49
  176. package/dist/three/surface-plot3d.d.ts.map +1 -1
  177. package/dist/three/surface-plot3d.js +227 -261
  178. package/dist/three/surface-plot3d.js.map +1 -1
  179. package/dist/three/vector-arrow3d.d.ts +87 -16
  180. package/dist/three/vector-arrow3d.d.ts.map +1 -1
  181. package/dist/three/vector-arrow3d.js +48 -67
  182. package/dist/three/vector-arrow3d.js.map +1 -1
  183. package/package.json +4 -4
  184. package/src/annotate/angle-mark.ts +95 -105
  185. package/src/annotate/curly-brace.ts +107 -85
  186. package/src/annotate/emphasis-mark.ts +55 -26
  187. package/src/engine.ts +35 -21
  188. package/src/kit/component.ts +57 -0
  189. package/src/kit/curve.ts +38 -20
  190. package/src/kit/field-mark.ts +124 -108
  191. package/src/kit/follow.ts +146 -120
  192. package/src/kit/furniture.ts +6 -1
  193. package/src/kit/graph.ts +116 -0
  194. package/src/kit/mark.ts +135 -114
  195. package/src/kit/place.ts +32 -56
  196. package/src/kit/system.ts +77 -71
  197. package/src/kit/withdrawn.ts +3 -3
  198. package/src/marks/curve-area.ts +65 -65
  199. package/src/marks/drop-lines.ts +50 -42
  200. package/src/marks/plot-point.ts +77 -82
  201. package/src/marks/riemann-sum.ts +73 -72
  202. package/src/marks/tangent-line.ts +87 -71
  203. package/src/marks/vector-arrow.ts +73 -73
  204. package/src/nodes.ts +41 -5
  205. package/src/plots/function-plot.ts +155 -171
  206. package/src/plots/points-plot.ts +46 -50
  207. package/src/plots/stream-lines.ts +75 -66
  208. package/src/plots/traced-path.ts +51 -33
  209. package/src/plots/vector-field.ts +68 -49
  210. package/src/structures/network-graph.ts +168 -185
  211. package/src/structures/sample-space.ts +149 -148
  212. package/src/systems/axes2d.ts +165 -156
  213. package/src/systems/number-line.ts +91 -92
  214. package/src/systems/number-plane.ts +149 -120
  215. package/src/systems/polar-plane.ts +117 -116
  216. package/src/tex/index.ts +2 -1
  217. package/src/tex/matrix.ts +62 -40
  218. package/src/tex/node.ts +54 -621
  219. package/src/tex/typeset.ts +461 -0
  220. package/src/three/axes3d.ts +187 -160
  221. package/src/three/curve-plot3d.ts +107 -110
  222. package/src/three/entries.ts +42 -0
  223. package/src/three/plot-point3d.ts +42 -45
  224. package/src/three/space.ts +34 -9
  225. package/src/three/surface-plot3d.ts +312 -323
  226. package/src/three/vector-arrow3d.ts +65 -54
  227. package/dist/browser/chunks/chunk-3GJB6AVO.js +0 -2
  228. package/dist/browser/chunks/chunk-3GJB6AVO.js.map +0 -7
  229. package/dist/browser/chunks/chunk-D5WHCVBC.js +0 -2
  230. package/dist/browser/chunks/chunk-D5WHCVBC.js.map +0 -7
  231. package/dist/browser/chunks/chunk-WL4KEX7Y.js +0 -2
  232. package/dist/browser/chunks/chunk-WL4KEX7Y.js.map +0 -7
  233. package/src/kit/placement.ts +0 -8
@@ -1,5 +1,5 @@
1
- import { type AssetScope, type Color, type NodeConfig, type NodeHandle, type PathCommand, type RenderContext2D, type Stroke, type Vector2 } from "@motionscript/sdk";
2
- import { FollowMark, type FollowProps, type Quad } from "../kit/follow.js";
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
3
  export type BraceSide = "below" | "above" | "left" | "right";
4
4
  export interface CurlyBraceProps extends FollowProps {
5
5
  side?: BraceSide;
@@ -17,30 +17,99 @@ export interface CurlyBraceProps extends FollowProps {
17
17
  * two points when it names neither, with an optional label at its tip. A label
18
18
  * written between dollar signs is typeset.
19
19
  */
20
- export declare class CurlyBrace extends FollowMark<CurlyBraceProps> {
21
- side: BraceSide;
20
+ export declare const CurlyBrace: import("@motionscript/sdk").Component<"curlyBrace", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
21
+ side: import("@motionscript/sdk").Type<"left" | "right" | "below" | "above", "left" | "right" | "below" | "above", false>;
22
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: Vector2;
24
- head: Vector2;
23
+ tail: import("@motionscript/sdk").Type<Vector2, Vector2, false>;
24
+ head: import("@motionscript/sdk").Type<Vector2, Vector2, false>;
25
25
  /** The room between the target and the brace. (`gap` is a layout's.) */
26
- clearance: number;
26
+ clearance: import("@motionscript/sdk").Type<number, number, false>;
27
27
  /** How far the brace reaches from its ends to its tip. (`depth` is a node's place in 3D.) */
28
- reach: number;
29
- label: string;
30
- labelSize: number;
31
- labelColor: Color;
32
- fontFamily: string;
33
- stroke: Stroke;
34
- constructor(props?: NodeConfig<CurlyBrace, CurlyBraceProps>);
35
- declareAssets(assets: AssetScope): void;
36
- protected quad(): Quad | null;
37
- /** Whether the brace follows nothing, and so spans its own two points. */
38
- private _spans;
39
- protected outline(quad: Quad): PathCommand[];
40
- protected renderSelf(ctx: RenderContext2D): void;
41
- /** The edge the brace runs along, pushed out by the gap, and the way it bulges. */
42
- private _span;
43
- _handles(): readonly NodeHandle[];
44
- _handleValue(prop: string, at: Vector2): Vector2 | null;
45
- }
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
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
40
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
41
+ start: import("@motionscript/sdk").Type<number, number, false>;
42
+ end: import("@motionscript/sdk").Type<number, number, false>;
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<"left" | "right" | "below" | "above", "left" | "right" | "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
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
75
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
76
+ start: import("@motionscript/sdk").Type<number, number, false>;
77
+ end: import("@motionscript/sdk").Type<number, number, false>;
78
+ }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
79
+ side: import("@motionscript/sdk").Type<"left" | "right" | "below" | "above", "left" | "right" | "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
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
98
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
99
+ start: import("@motionscript/sdk").Type<number, number, false>;
100
+ end: import("@motionscript/sdk").Type<number, number, false>;
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>;
46
115
  //# sourceMappingURL=curly-brace.d.ts.map
@@ -1 +1 @@
1
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AAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAkED;;;;GAIG;AACH,eAAO,MAAM,UAAU;;IA1DnB,0HAA0H;;;IAG1H,wEAAwE;;IAExE,6FAA6F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAL7F,0HAA0H;;;IAG1H,wEAAwE;;IAExE,6FAA6F;;;;;;;;;;;;;;;;;;IAL7F,0HAA0H;;;IAG1H,wEAAwE;;IAExE,6FAA6F;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAwF/F,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -1,13 +1,9 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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 { colorProperty, node, property, strokeProperty, vector2Property, } from "@motionscript/sdk";
1
+ import { component2d, Graphics2D, Types, } from "@motionscript/sdk";
8
2
  import { braceOutline } from "../kit/brace.js";
9
- import { add, between, followed, FollowMark, heading } from "../kit/follow.js";
10
- import { declareFormulas, drawLabels } from "../kit/furniture.js";
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";
11
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. */
12
8
  const EDGE = {
13
9
  below: [2, 3],
@@ -15,100 +11,89 @@ const EDGE = {
15
11
  left: [3, 0],
16
12
  right: [1, 2],
17
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
+ });
18
57
  /**
19
58
  * A curly brace along one side of a node or of a part of a formula, or between
20
59
  * two points when it names neither, with an optional label at its tip. A label
21
60
  * written between dollar signs is typeset.
22
61
  */
23
- let CurlyBrace = class CurlyBrace extends FollowMark {
24
- constructor(props) {
25
- super(props ?? {});
26
- }
27
- declareAssets(assets) {
28
- super.declareAssets(assets);
29
- if (this.label !== "" && this.fontFamily !== "")
30
- assets.font(this.fontFamily);
31
- declareFormulas(assets, [this.label]);
32
- }
33
- quad() {
34
- // No target: the span itself, as an edge with nothing above it.
35
- return this._spans() ? [this.head, this.tail, this.tail, this.head] : super.quad();
36
- }
37
- /** Whether the brace follows nothing, and so spans its own two points. */
38
- _spans() {
39
- return !this.retarget && followed(this, this.on) === null;
40
- }
41
- outline(quad) {
42
- const { from, to, out } = this._span(quad);
43
- return braceOutline(from, to, out, this.reach);
44
- }
45
- renderSelf(ctx) {
46
- super.renderSelf(ctx);
47
- if (this.label === "")
48
- return;
49
- const quad = this.quad();
50
- if (!quad)
51
- return;
52
- const { from, to, out } = this._span(quad);
53
- const reach = Math.min(this.reach, heading(from, to).length / 2) + this.labelSize * 0.75;
54
- const at = add(between(from, to), out, reach);
55
- const align = out.x > 0.5 ? "left" : out.x < -0.5 ? "right" : "center";
56
- const style = { fontSize: this.labelSize, fontFamily: this.fontFamily, color: this.labelColor };
57
- for (const part of drawLabels([{ text: this.label, at, align }], style))
58
- ctx.draw(part);
59
- }
60
- /** The edge the brace runs along, pushed out by the gap, and the way it bulges. */
61
- _span(quad) {
62
- const [i, j] = this._spans() ? [1, 0] : EDGE[this.side];
63
- const { unit } = heading(quad[i], quad[j]);
64
- // Left of the edge's own direction, in a y-up frame.
65
- const out = { x: -unit.y, y: unit.x };
66
- return { from: add(quad[i], out, this.clearance), to: add(quad[j], out, this.clearance), out };
67
- }
68
- _handles() {
69
- return this._spans() ? [{ prop: "tail", at: this.tail }, { prop: "head", at: this.head }] : [];
70
- }
71
- _handleValue(prop, at) {
72
- return this._spans() && (prop === "tail" || prop === "head") ? { x: at.x, y: at.y } : null;
73
- }
74
- };
75
- __decorate([
76
- property({ default: "below", options: ["below", "above", "left", "right"], animatable: false })
77
- ], CurlyBrace.prototype, "side", void 0);
78
- __decorate([
79
- vector2Property({ default: { x: -80, y: 0 } })
80
- ], CurlyBrace.prototype, "tail", void 0);
81
- __decorate([
82
- vector2Property({ default: { x: 80, y: 0 } })
83
- ], CurlyBrace.prototype, "head", void 0);
84
- __decorate([
85
- property({ default: 8, min: 0, unit: "px" })
86
- ], CurlyBrace.prototype, "clearance", void 0);
87
- __decorate([
88
- property({ default: 18, min: 2, unit: "px" })
89
- ], CurlyBrace.prototype, "reach", void 0);
90
- __decorate([
91
- property({ default: "", animatable: false })
92
- ], CurlyBrace.prototype, "label", void 0);
93
- __decorate([
94
- property({ default: 28, min: 1, unit: "px" })
95
- ], CurlyBrace.prototype, "labelSize", void 0);
96
- __decorate([
97
- colorProperty({ default: "#e5e7eb" })
98
- ], CurlyBrace.prototype, "labelColor", void 0);
99
- __decorate([
100
- property({ default: "", animatable: false })
101
- ], CurlyBrace.prototype, "fontFamily", void 0);
102
- __decorate([
103
- strokeProperty({ default: { weight: 3, fill: "#e5e7eb", align: "center", cap: "round", join: "round" } })
104
- ], CurlyBrace.prototype, "stroke", void 0);
105
- CurlyBrace = __decorate([
106
- node({
107
- key: "curlyBrace",
108
- parentKey: "shape",
109
- forkable: true,
110
- layout: { children: "freeform", defaultWidthMode: "hug", defaultHeightMode: "hug", acceptsChildren: false },
111
- })
112
- ], CurlyBrace);
113
- export { CurlyBrace };
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
+ });
114
99
  //# sourceMappingURL=curly-brace.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"curly-brace.js","sourceRoot":"","sources":["../../src/annotate/curly-brace.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,eAAe,GAUlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAA+B,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAgB/D,2HAA2H;AAC3H,MAA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CAAC;QACF,GAAG,EAAE,YAAY;QACjB,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE;KAC9G,CAAC;GACW,UAAU,CAwEtB","sourcesContent":["import {\r\n colorProperty,\r\n node,\r\n property,\r\n strokeProperty,\r\n vector2Property,\r\n type AssetScope,\r\n type Color,\r\n type NodeConfig,\r\n type NodeHandle,\r\n type NormalizedColor,\r\n type PathCommand,\r\n type RenderContext2D,\r\n type Stroke,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport { braceOutline } from \"../kit/brace\";\r\nimport { add, between, followed, FollowMark, heading, type FollowProps, type Quad } from \"../kit/follow\";\r\nimport { declareFormulas, drawLabels } from \"../kit/furniture\";\r\n\r\nexport type BraceSide = \"below\" | \"above\" | \"left\" | \"right\";\r\n\r\nexport interface CurlyBraceProps extends FollowProps {\r\n side?: BraceSide;\r\n tail?: Vector2;\r\n head?: Vector2;\r\n clearance?: number;\r\n reach?: number;\r\n label?: string;\r\n labelSize?: number;\r\n labelColor?: Color;\r\n fontFamily?: string;\r\n}\r\n\r\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. */\r\nconst EDGE: Record<BraceSide, [number, number]> = {\r\n below: [2, 3],\r\n above: [0, 1],\r\n left: [3, 0],\r\n right: [1, 2],\r\n};\r\n\r\n/**\r\n * A curly brace along one side of a node or of a part of a formula, or between\r\n * two points when it names neither, with an optional label at its tip. A label\r\n * written between dollar signs is typeset.\r\n */\r\n@node({\r\n key: \"curlyBrace\",\r\n parentKey: \"shape\",\r\n forkable: true,\r\n layout: { children: \"freeform\", defaultWidthMode: \"hug\", defaultHeightMode: \"hug\", acceptsChildren: false },\r\n})\r\nexport class CurlyBrace extends FollowMark<CurlyBraceProps> {\r\n @property({ default: \"below\", options: [\"below\", \"above\", \"left\", \"right\"], animatable: false }) declare side: BraceSide;\r\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. */\r\n @vector2Property({ default: { x: -80, y: 0 } }) declare tail: Vector2;\r\n @vector2Property({ default: { x: 80, y: 0 } }) declare head: Vector2;\r\n /** The room between the target and the brace. (`gap` is a layout's.) */\r\n @property({ default: 8, min: 0, unit: \"px\" }) declare clearance: number;\r\n /** How far the brace reaches from its ends to its tip. (`depth` is a node's place in 3D.) */\r\n @property({ default: 18, min: 2, unit: \"px\" }) declare reach: number;\r\n\r\n @property({ default: \"\", animatable: false }) declare label: string;\r\n @property({ default: 28, min: 1, unit: \"px\" }) declare labelSize: number;\r\n @colorProperty({ default: \"#e5e7eb\" }) declare labelColor: Color;\r\n @property({ default: \"\", animatable: false }) declare fontFamily: string;\r\n\r\n @strokeProperty({ default: { weight: 3, fill: \"#e5e7eb\", align: \"center\", cap: \"round\", join: \"round\" } })\r\n declare stroke: Stroke;\r\n\r\n constructor(props?: NodeConfig<CurlyBrace, CurlyBraceProps>) {\r\n super(props ?? {});\r\n }\r\n\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n if (this.label !== \"\" && this.fontFamily !== \"\") assets.font(this.fontFamily);\r\n declareFormulas(assets, [this.label]);\r\n }\r\n\r\n protected override quad(): Quad | null {\r\n // No target: the span itself, as an edge with nothing above it.\r\n return this._spans() ? [this.head, this.tail, this.tail, this.head] : super.quad();\r\n }\r\n\r\n /** Whether the brace follows nothing, and so spans its own two points. */\r\n private _spans(): boolean {\r\n return !this.retarget && followed(this, this.on) === null;\r\n }\r\n\r\n protected outline(quad: Quad): PathCommand[] {\r\n const { from, to, out } = this._span(quad);\r\n return braceOutline(from, to, out, this.reach);\r\n }\r\n\r\n protected override renderSelf(ctx: RenderContext2D): void {\r\n super.renderSelf(ctx);\r\n if (this.label === \"\") return;\r\n const quad = this.quad();\r\n if (!quad) return;\r\n const { from, to, out } = this._span(quad);\r\n const reach = Math.min(this.reach, heading(from, to).length / 2) + this.labelSize * 0.75;\r\n const at = add(between(from, to), out, reach);\r\n const align = out.x > 0.5 ? \"left\" : out.x < -0.5 ? \"right\" : \"center\";\r\n const style = { fontSize: this.labelSize, fontFamily: this.fontFamily, color: this.labelColor as NormalizedColor };\r\n for (const part of drawLabels([{ text: this.label, at, align }], style)) ctx.draw(part);\r\n }\r\n\r\n /** The edge the brace runs along, pushed out by the gap, and the way it bulges. */\r\n private _span(quad: Quad): { from: Vector2; to: Vector2; out: Vector2 } {\r\n const [i, j] = this._spans() ? [1, 0] : EDGE[this.side];\r\n const { unit } = heading(quad[i], quad[j]);\r\n // Left of the edge's own direction, in a y-up frame.\r\n const out = { x: -unit.y, y: unit.x };\r\n return { from: add(quad[i], out, this.clearance), to: add(quad[j], out, this.clearance), out };\r\n }\r\n\r\n override _handles(): readonly NodeHandle[] {\r\n return this._spans() ? [{ prop: \"tail\", at: this.tail }, { prop: \"head\", at: this.head }] : [];\r\n }\r\n\r\n override _handleValue(prop: string, at: Vector2): Vector2 | null {\r\n return this._spans() && (prop === \"tail\" || prop === \"head\") ? { x: at.x, y: at.y } : null;\r\n }\r\n}\r\n"]}
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,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,GAEnH,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OA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cesContent":["import {\r\n component2d,\r\n Graphics2D,\r\n Types,\r\n type Color,\r\n type NodeOf,\r\n type NodeView,\r\n type NormalizedColor,\r\n type PathCommand,\r\n type Vector2,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\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 type Stroke as _Stroke,\r\n type StrokeResolved as _StrokeResolved,\r\n} from \"@motionscript/sdk\";\r\nimport { braceOutline } from \"../kit/brace\";\r\nimport { listed, painted } from \"../kit/component\";\r\nimport {\r\n add, between, container, FOLLOW_COMMANDS, FOLLOW_STATE, followedQuad, heading, outlineBounds, OWN_FRAME, resting,\r\n type FollowProps, type FollowValues, type Quad,\r\n} from \"../kit/follow\";\r\nimport { drawLabels, loadFormulas } from \"../kit/furniture\";\r\nimport { strokeShape } from \"../kit/mark\";\r\n\r\nexport type BraceSide = \"below\" | \"above\" | \"left\" | \"right\";\r\n\r\nexport interface CurlyBraceProps extends FollowProps {\r\n side?: BraceSide;\r\n tail?: Vector2;\r\n head?: Vector2;\r\n clearance?: number;\r\n reach?: number;\r\n label?: string;\r\n labelSize?: number;\r\n labelColor?: Color;\r\n fontFamily?: string;\r\n}\r\n\r\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. */\r\nconst EDGE: Record<BraceSide, [number, number]> = {\r\n below: [2, 3],\r\n above: [0, 1],\r\n left: [3, 0],\r\n right: [1, 2],\r\n};\r\n\r\nconst state = {\r\n ...FOLLOW_STATE,\r\n side: listed([\"below\", \"above\", \"left\", \"right\"], \"below\", { animatable: false }),\r\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. */\r\n tail: Types.vector2({ x: -80, y: 0 }),\r\n head: Types.vector2({ x: 80, y: 0 }),\r\n /** The room between the target and the brace. (`gap` is a layout's.) */\r\n clearance: Types.number(8, { min: 0, unit: \"px\" }),\r\n /** How far the brace reaches from its ends to its tip. (`depth` is a node's place in 3D.) */\r\n reach: Types.number(18, { min: 2, unit: \"px\" }),\r\n label: Types.text(\"\", { animatable: false }),\r\n labelSize: Types.number(28, { min: 1, unit: \"px\" }),\r\n labelColor: Types.color(\"#e5e7eb\"),\r\n fontFamily: Types.text(\"\", { animatable: false }),\r\n};\r\n\r\ninterface BraceValues extends FollowValues {\r\n readonly side: BraceSide;\r\n readonly tail: Vector2;\r\n readonly head: Vector2;\r\n readonly clearance: number;\r\n readonly reach: number;\r\n}\r\n\r\n/** Whether the brace follows nothing, and so spans its own two points. */\r\nfunction spans(s: BraceValues, parted: NodeView | null): boolean {\r\n return !s.retarget && resting(s, parted) === null;\r\n}\r\n\r\n/** No target: the span itself, as an edge with nothing above it. */\r\nfunction quadOf(s: BraceValues, parted: NodeView | null): Quad | null {\r\n return spans(s, parted) ? [s.head, s.tail, s.tail, s.head] : followedQuad(s, parted);\r\n}\r\n\r\n/** The edge the brace runs along, pushed out by the gap, and the way it bulges. */\r\nfunction edgeOf(s: BraceValues, parted: NodeView | null, quad: Quad): { from: Vector2; to: Vector2; out: Vector2 } {\r\n const [i, j] = spans(s, parted) ? [1, 0] : EDGE[s.side];\r\n const { unit } = heading(quad[i], quad[j]);\r\n // Left of the edge's own direction, in a y-up frame.\r\n const out = { x: -unit.y, y: unit.x };\r\n return { from: add(quad[i], out, s.clearance), to: add(quad[j], out, s.clearance), out };\r\n}\r\n\r\nfunction outline(s: BraceValues, parted: NodeView | null): PathCommand[] {\r\n const quad = quadOf(s, parted);\r\n if (!quad) return [];\r\n const { from, to, out } = edgeOf(s, parted, quad);\r\n return braceOutline(from, to, out, s.reach);\r\n}\r\n\r\n/** One of the two ends to drag, while the brace spans them. */\r\nconst end = (which: \"tail\" | \"head\") => ({\r\n at: (s: BraceValues) => (spans(s, container(null, s)) ? s[which] : null),\r\n value: (at: Vector2) => ({ x: at.x, y: at.y }),\r\n});\r\n\r\n/**\r\n * A curly brace along one side of a node or of a part of a formula, or between\r\n * two points when it names neither, with an optional label at its tip. A label\r\n * written between dollar signs is typeset.\r\n */\r\nexport const CurlyBrace = component2d({\r\n key: \"curlyBrace\",\r\n state,\r\n defaults: { stroke: { weight: 3, fill: \"#e5e7eb\", align: \"center\", cap: \"round\", join: \"round\" }, width: \"hug\", height: \"hug\" },\r\n load: (loader, s) => {\r\n if (s.label !== \"\" && s.fontFamily !== \"\") loader.font(s.fontFamily);\r\n loadFormulas(loader, [s.label]);\r\n },\r\n commands: FOLLOW_COMMANDS,\r\n handles: { tail: end(\"tail\"), head: end(\"head\") },\r\n measure: () => ({ width: 0, height: 0 }),\r\n bounds: (_size, s) => outlineBounds(outline(s, container(null, s))),\r\n render: (ctx, s) => {\r\n const parted = container(ctx, s);\r\n const data = outline(s, parted);\r\n const shape = data.length > 0 ? () => new Graphics2D().path({ data, centerBounds: OWN_FRAME, start: s.start, end: s.end }) : null;\r\n painted(\r\n ctx,\r\n () => {\r\n if (shape) ctx.draw(shape().shadow(s.shadow).fill([]));\r\n if (s.label === \"\") return;\r\n const quad = quadOf(s, parted);\r\n if (!quad) return;\r\n const { from, to, out } = edgeOf(s, parted, quad);\r\n const reach = Math.min(s.reach, heading(from, to).length / 2) + s.labelSize * 0.75;\r\n const at = add(between(from, to), out, reach);\r\n const align = out.x > 0.5 ? \"left\" : out.x < -0.5 ? \"right\" : \"center\";\r\n const style = { fontSize: s.labelSize, fontFamily: s.fontFamily, color: s.labelColor as NormalizedColor };\r\n ctx.draw(drawLabels([{ text: s.label, at, align }], style));\r\n },\r\n () => {\r\n if (shape) strokeShape(ctx, shape, s);\r\n },\r\n );\r\n },\r\n});\r\n\r\nexport type CurlyBrace = NodeOf<typeof CurlyBrace>;\r\n"]}
@@ -1,5 +1,5 @@
1
- import { type NodeConfig, type PathCommand, type Stroke } from "@motionscript/sdk";
2
- import { FollowMark, type FollowProps, type Quad } from "../kit/follow.js";
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
3
  export type EmphasisShape = "box" | "circle" | "underline" | "cross";
4
4
  export interface EmphasisMarkProps extends FollowProps {
5
5
  shape?: EmphasisShape;
@@ -9,12 +9,72 @@ export interface EmphasisMarkProps extends FollowProps {
9
9
  * A box, a circle, an underline or a cross drawn on a node, or on one part of
10
10
  * a formula. `progressTo` draws it on, and `retargetTo` slides it to another.
11
11
  */
12
- export declare class EmphasisMark extends FollowMark<EmphasisMarkProps> {
13
- shape: EmphasisShape;
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" | "circle" | "underline" | "cross", "box" | "circle" | "underline" | "cross", false>;
14
14
  /** The room between the target and the mark. (`gap` is a layout's.) */
15
- clearance: number;
16
- stroke: Stroke;
17
- constructor(props?: NodeConfig<EmphasisMark, EmphasisMarkProps>);
18
- protected outline(quad: Quad): PathCommand[];
19
- }
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
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
23
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
24
+ start: import("@motionscript/sdk").Type<number, number, false>;
25
+ end: import("@motionscript/sdk").Type<number, number, false>;
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" | "circle" | "underline" | "cross", "box" | "circle" | "underline" | "cross", 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
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
49
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
50
+ start: import("@motionscript/sdk").Type<number, number, false>;
51
+ end: import("@motionscript/sdk").Type<number, number, false>;
52
+ }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
53
+ shape: import("@motionscript/sdk").Type<"box" | "circle" | "underline" | "cross", "box" | "circle" | "underline" | "cross", 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
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
63
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
64
+ start: import("@motionscript/sdk").Type<number, number, false>;
65
+ end: import("@motionscript/sdk").Type<number, number, false>;
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>;
20
80
  //# sourceMappingURL=emphasis-mark.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"emphasis-mark.d.ts","sourceRoot":"","sources":["../../src/annotate/emphasis-mark.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,UAAU,E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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"}
@@ -1,11 +1,7 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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 { node, property, strokeProperty, } from "@motionscript/sdk";
8
- import { add, between, FollowMark, grown, heading } from "../kit/follow.js";
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";
9
5
  /** How far a cubic's handle reaches to draw a quarter of an ellipse. */
10
6
  const QUARTER = 0.5523;
11
7
  const line = (a, b) => [
@@ -48,34 +44,37 @@ const SHAPES = {
48
44
  return [...line(tl, br), ...line(bl, tr)];
49
45
  },
50
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
+ }
51
57
  /**
52
58
  * A box, a circle, an underline or a cross drawn on a node, or on one part of
53
59
  * a formula. `progressTo` draws it on, and `retargetTo` slides it to another.
54
60
  */
55
- let EmphasisMark = class EmphasisMark extends FollowMark {
56
- constructor(props) {
57
- super(props ?? {});
58
- }
59
- outline(quad) {
60
- return SHAPES[this.shape](quad, this.clearance);
61
- }
62
- };
63
- __decorate([
64
- property({ default: "box", options: ["box", "circle", "underline", "cross"], animatable: false })
65
- ], EmphasisMark.prototype, "shape", void 0);
66
- __decorate([
67
- property({ default: 10, unit: "px" })
68
- ], EmphasisMark.prototype, "clearance", void 0);
69
- __decorate([
70
- strokeProperty({ default: { weight: 3, fill: "#facc15", align: "center", cap: "round", join: "round" } })
71
- ], EmphasisMark.prototype, "stroke", void 0);
72
- EmphasisMark = __decorate([
73
- node({
74
- key: "emphasisMark",
75
- parentKey: "shape",
76
- forkable: true,
77
- layout: { children: "freeform", defaultWidthMode: "hug", defaultHeightMode: "hug", acceptsChildren: false },
78
- })
79
- ], EmphasisMark);
80
- export { EmphasisMark };
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
+ });
81
80
  //# sourceMappingURL=emphasis-mark.js.map