@motionscript/math 0.1.0-alpha.4 → 0.1.0-alpha.6

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 +132 -92
  2. package/README.md +39 -33
  3. package/dist/annotate/angle-mark.d.ts +52 -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 +59 -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 +43 -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 +58 -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 +24 -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 +28 -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 +37 -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 +30 -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 +38 -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 +30 -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 +107 -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 +34 -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 +38 -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 +34 -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 +31 -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 +99 -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 +69 -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 +126 -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 +51 -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 +92 -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 +47 -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 +56 -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 +55 -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 +140 -54
  156. package/dist/three/axes3d.d.ts.map +1 -1
  157. package/dist/three/axes3d.js +159 -204
  158. package/dist/three/axes3d.js.map +1 -1
  159. package/dist/three/curve-plot3d.d.ts +70 -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 +57 -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 +131 -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 +58 -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 +182 -161
  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,6 +1,4 @@
1
- import { Graphics2D, type AssetScope, type Color, type Command, type CommandArgs, type Extents, type NodeConfig, type PaintProps, type Stroke } from "@motionscript/sdk";
2
- import { type CoordinateMap } from "../kit/coords.js";
3
- import { CoordinateSystem } from "../kit/system.js";
1
+ import { type Color, type NodeOf, type NormalizedColor, type PaintProps, type Stroke, type StrokeResolved, type Fill as _Fill, type FillResolved as _FillResolved, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved } from "@motionscript/sdk";
4
2
  export interface PolarPlaneProps extends PaintProps {
5
3
  radius?: number;
6
4
  ringStep?: number;
@@ -17,32 +15,55 @@ export interface PolarPlaneProps extends PaintProps {
17
15
  * Children sit in its graph coordinates, x and y in the units its rings count,
18
16
  * so a plot of `r = 1 + cos(theta)`, a point or an arrow goes on it as on axes.
19
17
  */
20
- export declare class PolarPlane extends CoordinateSystem<PolarPlaneProps> {
18
+ export declare const PolarPlane: import("@motionscript/sdk").Component<"polarPlane", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
21
19
  /** The radius of the outermost ring, in graph units. */
22
- radius: number;
20
+ radius: import("@motionscript/sdk").Type<number, number, false>;
23
21
  /** The spacing of the rings; zero picks a tidy one for the plane's size. */
24
- ringStep: number;
22
+ ringStep: import("@motionscript/sdk").Type<number, number, false>;
25
23
  /** How many spokes divide the turn; zero draws none. */
26
- spokes: number;
27
- angleUnit: "degrees" | "radians";
24
+ spokes: import("@motionscript/sdk").Type<number, number, false>;
25
+ angleUnit: import("@motionscript/sdk").Type<"degrees" | "radians", "degrees" | "radians", false>;
28
26
  /** The inner rings and the spokes. */
29
- gridStroke: Stroke;
30
- /** The outer ring and the two lines through the origin. */
31
- stroke: Stroke;
27
+ gridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
32
28
  /** A number at each ring, and an angle at each spoke. */
33
- labels: boolean;
34
- labelSize: number;
35
- labelColor: Color;
36
- fontFamily: string;
37
- constructor(props?: NodeConfig<PolarPlane, PolarPlaneProps>);
38
- /** Animate how far out the plane reaches: a zoom about its origin. */
39
- rangeTo(args: CommandArgs<{
40
- radius: number;
41
- }> & {
42
- duration: number;
43
- }): Command<PolarPlaneProps>;
44
- declareAssets(assets: AssetScope): void;
45
- protected mapFor(area: Extents): CoordinateMap;
46
- protected furniture(map: CoordinateMap): Graphics2D[];
47
- }
29
+ labels: import("@motionscript/sdk").Type<boolean, boolean, 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
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
34
+ stroke: import("@motionscript/sdk").Attribute<Stroke, StrokeResolved[]>;
35
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
36
+ start: import("@motionscript/sdk").Type<number, number, false>;
37
+ end: import("@motionscript/sdk").Type<number, number, false>;
38
+ }>, {
39
+ readonly rangeTo: readonly ["radius"];
40
+ readonly fillTo: readonly ["fill"];
41
+ readonly strokeTo: readonly ["stroke"];
42
+ readonly shadowTo: readonly ["shadow"];
43
+ readonly progressTo: readonly ["start", "end"];
44
+ readonly flash: {
45
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
46
+ };
47
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
48
+ /** The radius of the outermost ring, in graph units. */
49
+ radius: import("@motionscript/sdk").Type<number, number, false>;
50
+ /** The spacing of the rings; zero picks a tidy one for the plane's size. */
51
+ ringStep: import("@motionscript/sdk").Type<number, number, false>;
52
+ /** How many spokes divide the turn; zero draws none. */
53
+ spokes: import("@motionscript/sdk").Type<number, number, false>;
54
+ angleUnit: import("@motionscript/sdk").Type<"degrees" | "radians", "degrees" | "radians", false>;
55
+ /** The inner rings and the spokes. */
56
+ gridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
57
+ /** A number at each ring, and an angle at each spoke. */
58
+ labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
59
+ labelSize: import("@motionscript/sdk").Type<number, number, false>;
60
+ labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
61
+ fontFamily: import("@motionscript/sdk").Type<string, string, false>;
62
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
63
+ stroke: import("@motionscript/sdk").Attribute<Stroke, StrokeResolved[]>;
64
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
65
+ start: import("@motionscript/sdk").Type<number, number, false>;
66
+ end: import("@motionscript/sdk").Type<number, number, false>;
67
+ }>, null>>;
68
+ export type PolarPlane = NodeOf<typeof PolarPlane>;
48
69
  //# sourceMappingURL=polar-plane.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"polar-plane.d.ts","sourceRoot":"","sources":["../../src/systems/polar-plane.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,UAAU,EAIV,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,UAAU,EAEf,KAAK,UAAU,EACf,KAAK,MAAM,EAEd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,WAAW,eAAgB,SAAQ,UAAU;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAKD;;;;GAIG;AACH,qBAOa,UAAW,SAAQ,gBAAgB,CAAC,eAAe,CAAC;IAC7D,wDAAwD;IACE,MAAM,EAAE,MAAM,CAAC;IACzE,4EAA4E;IAClC,QAAQ,EAAE,MAAM,CAAC;IAC3D,wDAAwD;IACwB,MAAM,EAA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MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAyBD;;;;GAIG;AACH,eAAO,MAAM,UAAU;IAvBnB,wDAAwD;;IAExD,4EAA4E;;IAE5E,wDAAwD;;;IAGxD,sCAAsC;;IAEtC,yDAAyD;;;;;;;;;;;;;;;;;;;;IATzD,wDAAwD;;IAExD,4EAA4E;;IAE5E,wDAAwD;;;IAGxD,sCAAsC;;IAEtC,yDAAyD;;;;;;;;;;UAgC3D,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -1,151 +1,125 @@
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, command, Graphics2D, node, property, strokeProperty, } from "@motionscript/sdk";
1
+ import { component2d, Graphics2D, Types, } from "@motionscript/sdk";
2
+ import { listed, PAINT, PAINT_COMMANDS } from "../kit/component.js";
8
3
  import { cartesianMap } from "../kit/coords.js";
9
4
  import { AXIS_COLOR, drawLabels } from "../kit/furniture.js";
10
- import { stated } from "../kit/geometry.js";
11
- import { CoordinateSystem } from "../kit/system.js";
5
+ import { drawSystem, systemLayout, systemMap, systemOpenPlane, systemProvides, systemSize } from "../kit/system.js";
12
6
  import { formatTick, ticksFor } from "../kit/ticks.js";
13
7
  /** How much room, in label sizes, the angles written round the outer ring take from the plane. */
14
8
  const LABEL_ROOM = 2.2;
9
+ const state = {
10
+ ...PAINT,
11
+ /** The radius of the outermost ring, in graph units. */
12
+ radius: Types.number(4, { min: 0.0001, step: 0.5 }),
13
+ /** The spacing of the rings; zero picks a tidy one for the plane's size. */
14
+ ringStep: Types.number(0, { min: 0 }),
15
+ /** How many spokes divide the turn; zero draws none. */
16
+ spokes: Types.number(12, { min: 0, max: 72, step: 1, animatable: false }),
17
+ angleUnit: listed(["degrees", "radians"], "degrees", { animatable: false }),
18
+ /** The inner rings and the spokes. */
19
+ gridStroke: Types.stroke({ weight: 1.25, fill: "#3b4658", align: "center" }),
20
+ /** A number at each ring, and an angle at each spoke. */
21
+ labels: Types.boolean(true, { animatable: false }),
22
+ labelSize: Types.number(16, { min: 1, unit: "px" }),
23
+ labelColor: Types.color(AXIS_COLOR),
24
+ fontFamily: Types.text("", { animatable: false }),
25
+ };
15
26
  /**
16
27
  * Rings and spokes about an origin: the plane a polar curve is read on.
17
28
  * Children sit in its graph coordinates, x and y in the units its rings count,
18
29
  * so a plot of `r = 1 + cos(theta)`, a point or an arrow goes on it as on axes.
19
30
  */
20
- let PolarPlane = class PolarPlane extends CoordinateSystem {
21
- constructor(props) {
22
- super(props ?? {});
31
+ export const PolarPlane = component2d({
32
+ key: "polarPlane",
33
+ state,
34
+ /** The outer ring and the two lines through the origin. */
35
+ defaults: { stroke: { weight: 2, fill: AXIS_COLOR, align: "center" } },
36
+ load: (loader, s) => {
37
+ if (s.fontFamily !== "")
38
+ loader.font(s.fontFamily);
39
+ },
40
+ commands: {
41
+ ...PAINT_COMMANDS,
42
+ /** Animate how far out the plane reaches: a zoom about its origin. */
43
+ rangeTo: { args: ["radius"] },
44
+ },
45
+ provide: (s) => systemProvides(s),
46
+ measure: (_measurer, s) => systemSize(s),
47
+ layout: (box, s, children) => systemLayout(box, s, children, polarMap),
48
+ plane: (box, s) => systemOpenPlane(box, s, polarMap),
49
+ render: (ctx, s) => drawSystem(ctx, s, systemMap(ctx.size, s, polarMap), (map) => polarFurniture(map, s)),
50
+ });
51
+ function polarMap(area, s) {
52
+ const width = area.maxX - area.minX;
53
+ const height = area.maxY - area.minY;
54
+ // The outer ring fits the shorter side, less the room its angles are written in; units are square.
55
+ const reach = Math.max(1, Math.min(width, height) / 2 - (s.labels ? s.labelSize * LABEL_ROOM : 0));
56
+ const unit = reach / Math.max(s.radius, 1e-9);
57
+ return cartesianMap({
58
+ xRange: [-width / 2 / unit, width / 2 / unit],
59
+ yRange: [-height / 2 / unit, height / 2 / unit],
60
+ area,
61
+ });
62
+ }
63
+ function polarFurniture(map, s) {
64
+ const stroke = s.stroke;
65
+ const grid = s.gridStroke;
66
+ const { start, end, radius } = s;
67
+ const centre = map.toPoint(0, 0);
68
+ const reach = map.toPoint(radius, 0).x - centre.x;
69
+ if (!(reach > 0))
70
+ return [];
71
+ const at = (r, degrees) => {
72
+ const angle = (degrees * Math.PI) / 180;
73
+ return map.toPoint(r * Math.cos(angle), r * Math.sin(angle));
74
+ };
75
+ const ring = (g, r) => {
76
+ const size = (map.toPoint(r, 0).x - centre.x) * 2;
77
+ return g.ellipse({ x: centre.x, y: centre.y, width: size, height: size, start, end });
78
+ };
79
+ const parts = [];
80
+ const marks = ticksFor([0, radius], s.ringStep, reach);
81
+ const rings = marks.values.filter((r) => r > 0 && r < radius * (1 - 1e-9));
82
+ const count = Math.round(s.spokes);
83
+ const turns = Array.from({ length: count }, (_, i) => (360 * i) / count);
84
+ if (grid.length > 0) {
85
+ const inner = new Graphics2D();
86
+ for (const r of rings)
87
+ ring(inner, r);
88
+ // The four along the axes are drawn with them.
89
+ for (const degrees of turns) {
90
+ if (degrees % 90 !== 0)
91
+ inner.line({ points: [centre, at(radius, degrees)], radius: 0, start, end });
92
+ }
93
+ if (rings.length > 0 || turns.some((degrees) => degrees % 90 !== 0))
94
+ parts.push(inner.stroke(grid));
23
95
  }
24
- /** Animate how far out the plane reaches: a zoom about its origin. */
25
- rangeTo(args) {
26
- return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
96
+ if (stroke.length > 0) {
97
+ parts.push(ring(new Graphics2D(), radius)
98
+ .line({ points: [at(radius, 180), at(radius, 0)], radius: 0, start, end })
99
+ .line({ points: [at(radius, 270), at(radius, 90)], radius: 0, start, end })
100
+ .stroke(stroke));
27
101
  }
28
- declareAssets(assets) {
29
- super.declareAssets(assets);
30
- if (this.fontFamily !== "")
31
- assets.font(this.fontFamily);
102
+ if (!s.labels)
103
+ return parts;
104
+ const size = s.labelSize;
105
+ const labels = [];
106
+ for (const r of [...rings, radius]) {
107
+ const p = map.toPoint(r, 0);
108
+ labels.push({ text: formatTick(r, marks.step), at: { x: p.x - size * 0.2, y: p.y - size * 0.95 }, align: "right" });
32
109
  }
33
- mapFor(area) {
34
- const width = area.maxX - area.minX;
35
- const height = area.maxY - area.minY;
36
- // The outer ring fits the shorter side, less the room its angles are written in; units are square.
37
- const reach = Math.max(1, Math.min(width, height) / 2 - (this.labels ? this.labelSize * LABEL_ROOM : 0));
38
- const unit = reach / Math.max(this.radius, 1e-9);
39
- return cartesianMap({
40
- xRange: [-width / 2 / unit, width / 2 / unit],
41
- yRange: [-height / 2 / unit, height / 2 / unit],
42
- area,
110
+ for (const degrees of turns) {
111
+ const p = at(radius, degrees);
112
+ const cos = Math.cos((degrees * Math.PI) / 180);
113
+ const sin = Math.sin((degrees * Math.PI) / 180);
114
+ labels.push({
115
+ text: s.angleUnit === "degrees" ? `${formatTick(degrees, 1)}°` : radians(degrees),
116
+ at: { x: p.x + cos * size * 0.6, y: p.y + sin * size * 1.05 },
117
+ align: cos > 0.3 ? "left" : cos < -0.3 ? "right" : "center",
43
118
  });
44
119
  }
45
- furniture(map) {
46
- const stroke = this.stroke;
47
- const grid = this.gridStroke;
48
- const { start, end, radius } = this;
49
- const centre = map.toPoint(0, 0);
50
- const reach = map.toPoint(radius, 0).x - centre.x;
51
- if (!(reach > 0))
52
- return [];
53
- const at = (r, degrees) => {
54
- const angle = (degrees * Math.PI) / 180;
55
- return map.toPoint(r * Math.cos(angle), r * Math.sin(angle));
56
- };
57
- const ring = (g, r) => {
58
- const size = (map.toPoint(r, 0).x - centre.x) * 2;
59
- return g.ellipse({ x: centre.x, y: centre.y, width: size, height: size, start, end });
60
- };
61
- const parts = [];
62
- const marks = ticksFor([0, radius], this.ringStep, reach);
63
- const rings = marks.values.filter((r) => r > 0 && r < radius * (1 - 1e-9));
64
- const count = Math.round(this.spokes);
65
- const turns = Array.from({ length: count }, (_, i) => (360 * i) / count);
66
- if (grid.length > 0) {
67
- const inner = new Graphics2D();
68
- for (const r of rings)
69
- ring(inner, r);
70
- // The four along the axes are drawn with them.
71
- for (const degrees of turns) {
72
- if (degrees % 90 !== 0)
73
- inner.line({ points: [centre, at(radius, degrees)], radius: 0, start, end });
74
- }
75
- if (rings.length > 0 || turns.some((degrees) => degrees % 90 !== 0))
76
- parts.push(inner.stroke(grid));
77
- }
78
- if (stroke.length > 0) {
79
- parts.push(ring(new Graphics2D(), radius)
80
- .line({ points: [at(radius, 180), at(radius, 0)], radius: 0, start, end })
81
- .line({ points: [at(radius, 270), at(radius, 90)], radius: 0, start, end })
82
- .stroke(stroke));
83
- }
84
- if (!this.labels)
85
- return parts;
86
- const size = this.labelSize;
87
- const labels = [];
88
- for (const r of [...rings, radius]) {
89
- const p = map.toPoint(r, 0);
90
- labels.push({ text: formatTick(r, marks.step), at: { x: p.x - size * 0.2, y: p.y - size * 0.95 }, align: "right" });
91
- }
92
- for (const degrees of turns) {
93
- const p = at(radius, degrees);
94
- const cos = Math.cos((degrees * Math.PI) / 180);
95
- const sin = Math.sin((degrees * Math.PI) / 180);
96
- labels.push({
97
- text: this.angleUnit === "degrees" ? `${formatTick(degrees, 1)}°` : radians(degrees),
98
- at: { x: p.x + cos * size * 0.6, y: p.y + sin * size * 1.05 },
99
- align: cos > 0.3 ? "left" : cos < -0.3 ? "right" : "center",
100
- });
101
- }
102
- parts.push(...drawLabels(labels, { fontSize: size, fontFamily: this.fontFamily, color: this.labelColor }));
103
- return parts;
104
- }
105
- };
106
- __decorate([
107
- property({ default: 4, min: 0.0001, step: 0.5 })
108
- ], PolarPlane.prototype, "radius", void 0);
109
- __decorate([
110
- property({ default: 0, min: 0 })
111
- ], PolarPlane.prototype, "ringStep", void 0);
112
- __decorate([
113
- property({ default: 12, min: 0, max: 72, step: 1, animatable: false })
114
- ], PolarPlane.prototype, "spokes", void 0);
115
- __decorate([
116
- property({ default: "degrees", options: ["degrees", "radians"], animatable: false })
117
- ], PolarPlane.prototype, "angleUnit", void 0);
118
- __decorate([
119
- strokeProperty({ default: { weight: 1.25, fill: "#3b4658", align: "center" } })
120
- ], PolarPlane.prototype, "gridStroke", void 0);
121
- __decorate([
122
- strokeProperty({ default: { weight: 2, fill: AXIS_COLOR, align: "center" } })
123
- ], PolarPlane.prototype, "stroke", void 0);
124
- __decorate([
125
- property({ default: true, animatable: false })
126
- ], PolarPlane.prototype, "labels", void 0);
127
- __decorate([
128
- property({ default: 16, min: 1, unit: "px" })
129
- ], PolarPlane.prototype, "labelSize", void 0);
130
- __decorate([
131
- colorProperty({ default: AXIS_COLOR })
132
- ], PolarPlane.prototype, "labelColor", void 0);
133
- __decorate([
134
- property({ default: "", animatable: false })
135
- ], PolarPlane.prototype, "fontFamily", void 0);
136
- __decorate([
137
- command({ args: ["radius"] })
138
- ], PolarPlane.prototype, "rangeTo", null);
139
- PolarPlane = __decorate([
140
- node({
141
- key: "polarPlane",
142
- parentKey: "node",
143
- forkable: true,
144
- layout: { children: "freeform", defaultWidthMode: "fixed", defaultHeightMode: "fixed", acceptsChildren: true },
145
- seed: { width: 560, height: 560 },
146
- })
147
- ], PolarPlane);
148
- export { PolarPlane };
120
+ parts.push(...drawLabels(labels, { fontSize: size, fontFamily: s.fontFamily, color: s.labelColor }));
121
+ return parts;
122
+ }
149
123
  /** An angle in degrees as a fraction of π: 90 is `π/2`, 240 is `4π/3`. */
150
124
  function radians(degrees) {
151
125
  if (degrees === 0)
@@ -1 +1 @@
1
- {"version":3,"file":"polar-plane.js","sourceRoot":"","sources":["../../src/systems/polar-plane.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,aAAa,EACb,OAAO,EACP,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,cAAc,GAWjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAsB,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAc,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAcpD,kGAAkG;AAClG,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB;;;;GAIG;AAQI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,gBAAiC;IAoB7D,YAAY,KAA+C;QACvD,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACvB,CAAC;IAED,sEAAsE;IAEtE,OAAO,CAAC,IAA4D;QAChE,OAAO,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9F,CAAC;IAEQ,aAAa,CAAC,MAAkB;QACrC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5B,IAAI,IAAI,CAAC,UAAU,KAAK,EAAE;YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;IAES,MAAM,CAAC,IAAa;QAC1B,MAAM,K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E,CAAC,GAAG,WAAW,GAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAC7D,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACV,SAAS,IAAI,CAAC,CAAC;YACf,WAAW,IAAI,CAAC,CAAC;YACjB,MAAM;QACV,CAAC;IACL,CAAC;IACD,MAAM,GAAG,GAAG,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC;IACpD,OAAO,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAC7D,CAAC","sourcesContent":["import {\r\n colorProperty,\r\n command,\r\n Graphics2D,\r\n node,\r\n property,\r\n strokeProperty,\r\n type AssetScope,\r\n type Color,\r\n type Command,\r\n type CommandArgs,\r\n type Extents,\r\n type NodeConfig,\r\n type NormalizedColor,\r\n type PaintProps,\r\n type Stroke,\r\n type StrokeResolved,\r\n} from \"@motionscript/sdk\";\r\nimport { cartesianMap, type CoordinateMap } from \"../kit/coords\";\r\nimport { AXIS_COLOR, drawLabels, type Label } from \"../kit/furniture\";\r\nimport { stated } from \"../kit/geometry\";\r\nimport { CoordinateSystem } from \"../kit/system\";\r\nimport { formatTick, ticksFor } from \"../kit/ticks\";\r\n\r\nexport interface PolarPlaneProps extends PaintProps {\r\n radius?: number;\r\n ringStep?: number;\r\n spokes?: number;\r\n angleUnit?: \"degrees\" | \"radians\";\r\n gridStroke?: Stroke;\r\n labels?: boolean;\r\n labelSize?: number;\r\n labelColor?: Color;\r\n fontFamily?: string;\r\n}\r\n\r\n/** How much room, in label sizes, the angles written round the outer ring take from the plane. */\r\nconst LABEL_ROOM = 2.2;\r\n\r\n/**\r\n * Rings and spokes about an origin: the plane a polar curve is read on.\r\n * Children sit in its graph coordinates, x and y in the units its rings count,\r\n * so a plot of `r = 1 + cos(theta)`, a point or an arrow goes on it as on axes.\r\n */\r\n@node({\r\n key: \"polarPlane\",\r\n parentKey: \"node\",\r\n forkable: true,\r\n layout: { children: \"freeform\", defaultWidthMode: \"fixed\", defaultHeightMode: \"fixed\", acceptsChildren: true },\r\n seed: { width: 560, height: 560 },\r\n})\r\nexport class PolarPlane extends CoordinateSystem<PolarPlaneProps> {\r\n /** The radius of the outermost ring, in graph units. */\r\n @property({ default: 4, min: 0.0001, step: 0.5 }) declare radius: number;\r\n /** The spacing of the rings; zero picks a tidy one for the plane's size. */\r\n @property({ default: 0, min: 0 }) declare ringStep: number;\r\n /** How many spokes divide the turn; zero draws none. */\r\n @property({ default: 12, min: 0, max: 72, step: 1, animatable: false }) declare spokes: number;\r\n @property({ default: \"degrees\", options: [\"degrees\", \"radians\"], animatable: false }) declare angleUnit: \"degrees\" | \"radians\";\r\n\r\n /** The inner rings and the spokes. */\r\n @strokeProperty({ default: { weight: 1.25, fill: \"#3b4658\", align: \"center\" } }) declare gridStroke: Stroke;\r\n /** The outer ring and the two lines through the origin. */\r\n @strokeProperty({ default: { weight: 2, fill: AXIS_COLOR, align: \"center\" } }) declare stroke: Stroke;\r\n\r\n /** A number at each ring, and an angle at each spoke. */\r\n @property({ default: true, animatable: false }) declare labels: boolean;\r\n @property({ default: 16, min: 1, unit: \"px\" }) declare labelSize: number;\r\n @colorProperty({ default: AXIS_COLOR }) declare labelColor: Color;\r\n @property({ default: \"\", animatable: false }) declare fontFamily: string;\r\n\r\n constructor(props?: NodeConfig<PolarPlane, PolarPlaneProps>) {\r\n super(props ?? {});\r\n }\r\n\r\n /** Animate how far out the plane reaches: a zoom about its origin. */\r\n @command({ args: [\"radius\"] })\r\n rangeTo(args: CommandArgs<{ radius: number }> & { duration: number }): Command<PolarPlaneProps> {\r\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\r\n }\r\n\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n if (this.fontFamily !== \"\") assets.font(this.fontFamily);\r\n }\r\n\r\n protected mapFor(area: Extents): CoordinateMap {\r\n const width = area.maxX - area.minX;\r\n const height = area.maxY - area.minY;\r\n // The outer ring fits the shorter side, less the room its angles are written in; units are square.\r\n const reach = Math.max(1, Math.min(width, height) / 2 - (this.labels ? this.labelSize * LABEL_ROOM : 0));\r\n const unit = reach / Math.max(this.radius, 1e-9);\r\n return cartesianMap({\r\n xRange: [-width / 2 / unit, width / 2 / unit],\r\n yRange: [-height / 2 / unit, height / 2 / unit],\r\n area,\r\n });\r\n }\r\n\r\n protected furniture(map: CoordinateMap): Graphics2D[] {\r\n const stroke = this.stroke as StrokeResolved[];\r\n const grid = this.gridStroke as StrokeResolved[];\r\n const { start, end, radius } = this;\r\n const centre = map.toPoint(0, 0);\r\n const reach = map.toPoint(radius, 0).x - centre.x;\r\n if (!(reach > 0)) return [];\r\n const at = (r: number, degrees: number) => {\r\n const angle = (degrees * Math.PI) / 180;\r\n return map.toPoint(r * Math.cos(angle), r * Math.sin(angle));\r\n };\r\n const ring = (g: Graphics2D, r: number): Graphics2D => {\r\n const size = (map.toPoint(r, 0).x - centre.x) * 2;\r\n return g.ellipse({ x: centre.x, y: centre.y, width: size, height: size, start, end });\r\n };\r\n\r\n const parts: Graphics2D[] = [];\r\n const marks = ticksFor([0, radius], this.ringStep, reach);\r\n const rings = marks.values.filter((r) => r > 0 && r < radius * (1 - 1e-9));\r\n const count = Math.round(this.spokes);\r\n const turns = Array.from({ length: count }, (_, i) => (360 * i) / count);\r\n\r\n if (grid.length > 0) {\r\n const inner = new Graphics2D();\r\n for (const r of rings) ring(inner, r);\r\n // The four along the axes are drawn with them.\r\n for (const degrees of turns) {\r\n if (degrees % 90 !== 0) inner.line({ points: [centre, at(radius, degrees)], radius: 0, start, end });\r\n }\r\n if (rings.length > 0 || turns.some((degrees) => degrees % 90 !== 0)) parts.push(inner.stroke(grid));\r\n }\r\n if (stroke.length > 0) {\r\n parts.push(\r\n ring(new Graphics2D(), radius)\r\n .line({ points: [at(radius, 180), at(radius, 0)], radius: 0, start, end })\r\n .line({ points: [at(radius, 270), at(radius, 90)], radius: 0, start, end })\r\n .stroke(stroke),\r\n );\r\n }\r\n if (!this.labels) return parts;\r\n\r\n const size = this.labelSize;\r\n const labels: Label[] = [];\r\n for (const r of [...rings, radius]) {\r\n const p = map.toPoint(r, 0);\r\n labels.push({ text: formatTick(r, marks.step), at: { x: p.x - size * 0.2, y: p.y - size * 0.95 }, align: \"right\" });\r\n }\r\n for (const degrees of turns) {\r\n const p = at(radius, degrees);\r\n const cos = Math.cos((degrees * Math.PI) / 180);\r\n const sin = Math.sin((degrees * Math.PI) / 180);\r\n labels.push({\r\n text: this.angleUnit === \"degrees\" ? `${formatTick(degrees, 1)}°` : radians(degrees),\r\n at: { x: p.x + cos * size * 0.6, y: p.y + sin * size * 1.05 },\r\n align: cos > 0.3 ? \"left\" : cos < -0.3 ? \"right\" : \"center\",\r\n });\r\n }\r\n parts.push(...drawLabels(labels, { fontSize: size, fontFamily: this.fontFamily, color: this.labelColor as NormalizedColor }));\r\n return parts;\r\n }\r\n}\r\n\r\n/** An angle in degrees as a fraction of π: 90 is `π/2`, 240 is `4π/3`. */\r\nfunction radians(degrees: number): string {\r\n if (degrees === 0) return \"0\";\r\n let numerator = Math.round(degrees);\r\n let denominator = 180;\r\n for (let a = numerator, b = denominator; ; [a, b] = [b, a % b]) {\r\n if (b === 0) {\r\n numerator /= a;\r\n denominator /= a;\r\n break;\r\n }\r\n }\r\n const top = numerator === 1 ? \"π\" : `${numerator}π`;\r\n return denominator === 1 ? top : `${top}/${denominator}`;\r\n}\r\n"]}
1
+ {"version":3,"file":"polar-plane.js","sourceRoot":"","sources":["../../src/systems/polar-plane.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,UAAU,EACV,KAAK,GAgBR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kB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AAC;YACf,WAAW,IAAI,CAAC,CAAC;YACjB,MAAM;QACV,CAAC;IACL,CAAC;IACD,MAAM,GAAG,GAAG,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC;IACpD,OAAO,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAC7D,CAAC","sourcesContent":["import {\r\n component2d,\r\n Graphics2D,\r\n Types,\r\n type Color,\r\n type Extents,\r\n type NodeOf,\r\n type NormalizedColor,\r\n type PaintProps,\r\n type Stroke,\r\n type StrokeResolved,\r\n type Values,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Fill as _Fill,\r\n type FillResolved as _FillResolved,\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n type Shadow as _Shadow,\r\n type ShadowResolved as _ShadowResolved,\r\n} from \"@motionscript/sdk\";\r\nimport { listed, PAINT, PAINT_COMMANDS } from \"../kit/component\";\r\nimport { cartesianMap, type CoordinateMap } from \"../kit/coords\";\r\nimport { AXIS_COLOR, drawLabels, type Label } from \"../kit/furniture\";\r\nimport { drawSystem, systemLayout, systemMap, systemOpenPlane, systemProvides, systemSize } from \"../kit/system\";\r\nimport { formatTick, ticksFor } from \"../kit/ticks\";\r\n\r\nexport interface PolarPlaneProps extends PaintProps {\r\n radius?: number;\r\n ringStep?: number;\r\n spokes?: number;\r\n angleUnit?: \"degrees\" | \"radians\";\r\n gridStroke?: Stroke;\r\n labels?: boolean;\r\n labelSize?: number;\r\n labelColor?: Color;\r\n fontFamily?: string;\r\n}\r\n\r\n/** How much room, in label sizes, the angles written round the outer ring take from the plane. */\r\nconst LABEL_ROOM = 2.2;\r\n\r\nconst state = {\r\n ...PAINT,\r\n /** The radius of the outermost ring, in graph units. */\r\n radius: Types.number(4, { min: 0.0001, step: 0.5 }),\r\n /** The spacing of the rings; zero picks a tidy one for the plane's size. */\r\n ringStep: Types.number(0, { min: 0 }),\r\n /** How many spokes divide the turn; zero draws none. */\r\n spokes: Types.number(12, { min: 0, max: 72, step: 1, animatable: false }),\r\n angleUnit: listed([\"degrees\", \"radians\"], \"degrees\", { animatable: false }),\r\n /** The inner rings and the spokes. */\r\n gridStroke: Types.stroke({ weight: 1.25, fill: \"#3b4658\", align: \"center\" }),\r\n /** A number at each ring, and an angle at each spoke. */\r\n labels: Types.boolean(true, { animatable: false }),\r\n labelSize: Types.number(16, { min: 1, unit: \"px\" }),\r\n labelColor: Types.color(AXIS_COLOR),\r\n fontFamily: Types.text(\"\", { animatable: false }),\r\n};\r\n\r\ntype PolarValues = Values<typeof state>;\r\n\r\n/**\r\n * Rings and spokes about an origin: the plane a polar curve is read on.\r\n * Children sit in its graph coordinates, x and y in the units its rings count,\r\n * so a plot of `r = 1 + cos(theta)`, a point or an arrow goes on it as on axes.\r\n */\r\nexport const PolarPlane = component2d({\r\n key: \"polarPlane\",\r\n state,\r\n /** The outer ring and the two lines through the origin. */\r\n defaults: { stroke: { weight: 2, fill: AXIS_COLOR, align: \"center\" } },\r\n load: (loader, s) => {\r\n if (s.fontFamily !== \"\") loader.font(s.fontFamily);\r\n },\r\n commands: {\r\n ...PAINT_COMMANDS,\r\n /** Animate how far out the plane reaches: a zoom about its origin. */\r\n rangeTo: { args: [\"radius\"] },\r\n },\r\n provide: (s) => systemProvides(s),\r\n measure: (_measurer, s) => systemSize(s),\r\n layout: (box, s, children) => systemLayout(box, s, children, polarMap),\r\n plane: (box, s) => systemOpenPlane(box, s, polarMap),\r\n render: (ctx, s) => drawSystem(ctx, s, systemMap(ctx.size, s, polarMap), (map) => polarFurniture(map, s)),\r\n});\r\n\r\nexport type PolarPlane = NodeOf<typeof PolarPlane>;\r\n\r\nfunction polarMap(area: Extents, s: PolarValues): CoordinateMap {\r\n const width = area.maxX - area.minX;\r\n const height = area.maxY - area.minY;\r\n // The outer ring fits the shorter side, less the room its angles are written in; units are square.\r\n const reach = Math.max(1, Math.min(width, height) / 2 - (s.labels ? s.labelSize * LABEL_ROOM : 0));\r\n const unit = reach / Math.max(s.radius, 1e-9);\r\n return cartesianMap({\r\n xRange: [-width / 2 / unit, width / 2 / unit],\r\n yRange: [-height / 2 / unit, height / 2 / unit],\r\n area,\r\n });\r\n}\r\n\r\nfunction polarFurniture(map: CoordinateMap, s: PolarValues): Graphics2D[] {\r\n const stroke = s.stroke as StrokeResolved[];\r\n const grid = s.gridStroke as StrokeResolved[];\r\n const { start, end, radius } = s;\r\n const centre = map.toPoint(0, 0);\r\n const reach = map.toPoint(radius, 0).x - centre.x;\r\n if (!(reach > 0)) return [];\r\n const at = (r: number, degrees: number) => {\r\n const angle = (degrees * Math.PI) / 180;\r\n return map.toPoint(r * Math.cos(angle), r * Math.sin(angle));\r\n };\r\n const ring = (g: Graphics2D, r: number): Graphics2D => {\r\n const size = (map.toPoint(r, 0).x - centre.x) * 2;\r\n return g.ellipse({ x: centre.x, y: centre.y, width: size, height: size, start, end });\r\n };\r\n\r\n const parts: Graphics2D[] = [];\r\n const marks = ticksFor([0, radius], s.ringStep, reach);\r\n const rings = marks.values.filter((r) => r > 0 && r < radius * (1 - 1e-9));\r\n const count = Math.round(s.spokes);\r\n const turns = Array.from({ length: count }, (_, i) => (360 * i) / count);\r\n\r\n if (grid.length > 0) {\r\n const inner = new Graphics2D();\r\n for (const r of rings) ring(inner, r);\r\n // The four along the axes are drawn with them.\r\n for (const degrees of turns) {\r\n if (degrees % 90 !== 0) inner.line({ points: [centre, at(radius, degrees)], radius: 0, start, end });\r\n }\r\n if (rings.length > 0 || turns.some((degrees) => degrees % 90 !== 0)) parts.push(inner.stroke(grid));\r\n }\r\n if (stroke.length > 0) {\r\n parts.push(\r\n ring(new Graphics2D(), radius)\r\n .line({ points: [at(radius, 180), at(radius, 0)], radius: 0, start, end })\r\n .line({ points: [at(radius, 270), at(radius, 90)], radius: 0, start, end })\r\n .stroke(stroke),\r\n );\r\n }\r\n if (!s.labels) return parts;\r\n\r\n const size = s.labelSize;\r\n const labels: Label[] = [];\r\n for (const r of [...rings, radius]) {\r\n const p = map.toPoint(r, 0);\r\n labels.push({ text: formatTick(r, marks.step), at: { x: p.x - size * 0.2, y: p.y - size * 0.95 }, align: \"right\" });\r\n }\r\n for (const degrees of turns) {\r\n const p = at(radius, degrees);\r\n const cos = Math.cos((degrees * Math.PI) / 180);\r\n const sin = Math.sin((degrees * Math.PI) / 180);\r\n labels.push({\r\n text: s.angleUnit === \"degrees\" ? `${formatTick(degrees, 1)}°` : radians(degrees),\r\n at: { x: p.x + cos * size * 0.6, y: p.y + sin * size * 1.05 },\r\n align: cos > 0.3 ? \"left\" : cos < -0.3 ? \"right\" : \"center\",\r\n });\r\n }\r\n parts.push(...drawLabels(labels, { fontSize: size, fontFamily: s.fontFamily, color: s.labelColor as NormalizedColor }));\r\n return parts;\r\n}\r\n\r\n/** An angle in degrees as a fraction of π: 90 is `π/2`, 240 is `4π/3`. */\r\nfunction radians(degrees: number): string {\r\n if (degrees === 0) return \"0\";\r\n let numerator = Math.round(degrees);\r\n let denominator = 180;\r\n for (let a = numerator, b = denominator; ; [a, b] = [b, a % b]) {\r\n if (b === 0) {\r\n numerator /= a;\r\n denominator /= a;\r\n break;\r\n }\r\n }\r\n const top = numerator === 1 ? \"π\" : `${numerator}π`;\r\n return denominator === 1 ? top : `${top}/${denominator}`;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tex/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EACH,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,GACrI,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEjE,yEAAyE;AACzE,eAAO,MAAM,SAAS,uCAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tex/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EACH,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,GACrI,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEjE,yEAAyE;AAEzE,eAAO,MAAM,SAAS,EAAE,CAAC,OAAO,KAAK,GAAG,OAAO,WAAW,CAAC,EAAyB,CAAC"}
package/dist/tex/index.js CHANGED
@@ -5,5 +5,6 @@ export * from './matrix.js';
5
5
  export { blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER, } from './geometry.js';
6
6
  export { defaultLatexMorph } from './tween.js';
7
7
  /** The typeset-math node types, for a host that registers only these. */
8
+ // Typed by name, so the declaration names each component rather than spelling out its type through core.
8
9
  export const TEX_NODES = [Latex, LatexMatrix];
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tex/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EACH,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,GACrI,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,yEAAyE;AACzE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { LatexMatrix } from './matrix';\r\nimport { Latex } from './node';\r\n\r\nexport * from './node';\r\nexport * from './matrix';\r\nexport {\r\n blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER,\r\n} from './geometry';\r\nexport type { LatexPart, LatexToken, LatexPathResult } from './geometry';\r\nexport { defaultLatexMorph } from './tween';\r\nexport type { AnimatedToken, LatexMorphStrategy } from './tween';\r\n\r\n/** The typeset-math node types, for a host that registers only these. */\r\nexport const TEX_NODES = [Latex, LatexMatrix];\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tex/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EACH,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,GACrI,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,yEAAyE;AACzE,yGAAyG;AACzG,MAAM,CAAC,MAAM,SAAS,GAA0C,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { LatexMatrix } from './matrix';\r\nimport { Latex } from './node';\r\n\r\nexport * from './node';\r\nexport * from './matrix';\r\nexport {\r\n blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER,\r\n} from './geometry';\r\nexport type { LatexPart, LatexToken, LatexPathResult } from './geometry';\r\nexport { defaultLatexMorph } from './tween';\r\nexport type { AnimatedToken, LatexMorphStrategy } from './tween';\r\n\r\n/** The typeset-math node types, for a host that registers only these. */\r\n// Typed by name, so the declaration names each component rather than spelling out its type through core.\r\nexport const TEX_NODES: (typeof Latex | typeof LatexMatrix)[] = [Latex, LatexMatrix];\r\n"]}
@@ -1,5 +1,6 @@
1
- import { type Command, type CommandArgs, type NodeConfig } from "@motionscript/sdk";
2
- import { Latex, type LatexProps } from "./node.js";
1
+ import { type NodeOf, type Alignment as _Alignment, type Fill as _Fill, type FillResolved as _FillResolved, type FlowMode as _FlowMode, type FlowResolved as _FlowResolved, type GapSize as _GapSize, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved, type Vector2 as _Vector2 } from "@motionscript/sdk";
2
+ import type { LatexProps } from "./node.js";
3
+ import { type Morphing } from "./typeset.js";
3
4
  export type MatrixBrackets = "square" | "round" | "bar" | "double" | "curly" | "none";
4
5
  export interface LatexMatrixProps extends LatexProps {
5
6
  entries: string[][];
@@ -7,25 +8,62 @@ export interface LatexMatrixProps extends LatexProps {
7
8
  }
8
9
  /** The LaTeX a matrix of `entries` is typeset from; empty for one with no entries. */
9
10
  export declare function matrixSource(entries: readonly (readonly string[])[], brackets?: MatrixBrackets): string;
10
- type MatrixNext = Partial<LatexMatrixProps>;
11
11
  /**
12
12
  * A matrix typeset from its entries, row by row, inside the brackets it is
13
13
  * given. Each entry is a piece of LaTeX and is one of the formula's parts, so
14
14
  * it can be painted, boxed or braced by its own source.
15
15
  */
16
- export declare class LatexMatrix extends Latex {
17
- entries: string[][];
18
- brackets: MatrixBrackets;
19
- constructor(props?: NodeConfig<LatexMatrix, LatexMatrixProps>);
20
- /** Change the entries: the ones both matrices write travel, the rest fade. */
21
- entriesTo(args: CommandArgs<{
22
- entries: string[][];
23
- }> & {
24
- duration: number;
25
- }): Command<LatexProps>;
26
- _source(next?: MatrixNext): string;
27
- _sourceProps(next?: MatrixNext): Partial<LatexProps>;
28
- _resets(next: MatrixNext): boolean;
29
- }
30
- export {};
16
+ export declare const LatexMatrix: import("@motionscript/sdk").Component<"latexMatrix", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
17
+ latex: import("@motionscript/sdk").Type<string, Morphing<string>, false>;
18
+ /** A list of rows is a whole value: mid-tween it holds both, and the morph draws the way there. */
19
+ entries: import("@motionscript/sdk").Type<string[][], Morphing<string[][]>, false>;
20
+ brackets: import("@motionscript/sdk").Type<MatrixBrackets, Morphing<MatrixBrackets>, false>;
21
+ fontSize: number;
22
+ partFills: import("@motionscript/sdk").Type<import("../index.js").PartFill[], import("../index.js").PartFillResolved[], false>;
23
+ written: import("@motionscript/sdk").Type<number, number, false>;
24
+ morphProgress: import("@motionscript/sdk").Type<number, number, false>;
25
+ flow: import("@motionscript/sdk").Type<_FlowMode, _FlowResolved, false>;
26
+ gap: import("@motionscript/sdk").Type<_GapSize, _GapSize, false>;
27
+ wrap: boolean;
28
+ crossGap: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
29
+ columns: import("@motionscript/sdk").Type<number, number, false>;
30
+ align: import("@motionscript/sdk").Attribute<_Alignment, _Vector2>;
31
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
32
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
33
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
34
+ overlay: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
35
+ }>, {
36
+ readonly morphTo: readonly ["latex"];
37
+ readonly entriesTo: readonly ["entries"];
38
+ readonly writeTo: readonly ["written"];
39
+ readonly partFillTo: {
40
+ readonly part: import("@motionscript/sdk").Type<string, string, false>;
41
+ readonly fill: import("@motionscript/sdk").Type<_Fill, _Fill, false>;
42
+ readonly occurrence: import("@motionscript/sdk").Type<number, number, false>;
43
+ };
44
+ readonly overlayTo: readonly ["overlay"];
45
+ readonly fillTo: readonly ["fill"];
46
+ readonly strokeTo: readonly ["stroke"];
47
+ readonly shadowTo: readonly ["shadow"];
48
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
49
+ latex: import("@motionscript/sdk").Type<string, Morphing<string>, false>;
50
+ /** A list of rows is a whole value: mid-tween it holds both, and the morph draws the way there. */
51
+ entries: import("@motionscript/sdk").Type<string[][], Morphing<string[][]>, false>;
52
+ brackets: import("@motionscript/sdk").Type<MatrixBrackets, Morphing<MatrixBrackets>, false>;
53
+ fontSize: number;
54
+ partFills: import("@motionscript/sdk").Type<import("../index.js").PartFill[], import("../index.js").PartFillResolved[], false>;
55
+ written: import("@motionscript/sdk").Type<number, number, false>;
56
+ morphProgress: import("@motionscript/sdk").Type<number, number, false>;
57
+ flow: import("@motionscript/sdk").Type<_FlowMode, _FlowResolved, false>;
58
+ gap: import("@motionscript/sdk").Type<_GapSize, _GapSize, false>;
59
+ wrap: boolean;
60
+ crossGap: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
61
+ columns: import("@motionscript/sdk").Type<number, number, false>;
62
+ align: import("@motionscript/sdk").Attribute<_Alignment, _Vector2>;
63
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
64
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
65
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
66
+ overlay: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
67
+ }>, null>>;
68
+ export type LatexMatrix = NodeOf<typeof LatexMatrix>;
31
69
  //# sourceMappingURL=matrix.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../../src/tex/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7G,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEtF,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAChD,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;CAC5B;AAWD,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,EAAE,QAAQ,GAAE,cAAyB,GAAG,MAAM,CAKjH;AAQD,KAAK,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE5C;;;;GAIG;AACH,qBAOa,WAAY,SAAQ,KAAK;IACwC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;IAEtF,QAAQ,EAAE,cAAc,CAAC;gBAErB,KAAK,CAAC,EAAE,UAAU,CAAC,WAAW,EAAE,gBAAgB,CAAC;IAI7D,8EAA8E;IAE9E,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,EAAE,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