@motionscript/patterns 0.0.0-stage → 0.1.0-alpha.4

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 (73) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +48 -0
  4. package/README.md +79 -3
  5. package/dist/browser/chunks/chunk-EZEE76AY.js +2 -0
  6. package/dist/browser/chunks/chunk-EZEE76AY.js.map +7 -0
  7. package/dist/browser/index.js +2 -0
  8. package/dist/browser/index.js.map +7 -0
  9. package/dist/browser/kit.js +2 -0
  10. package/dist/browser/kit.js.map +7 -0
  11. package/dist/browser/manifest.json +13 -0
  12. package/dist/dot-grid-pattern/dot-grid-pattern.d.ts +41 -0
  13. package/dist/dot-grid-pattern/dot-grid-pattern.d.ts.map +1 -0
  14. package/dist/dot-grid-pattern/dot-grid-pattern.js +93 -0
  15. package/dist/dot-grid-pattern/dot-grid-pattern.js.map +1 -0
  16. package/dist/dot-grid-pattern/index.d.ts +2 -0
  17. package/dist/dot-grid-pattern/index.d.ts.map +1 -0
  18. package/dist/dot-grid-pattern/index.js +2 -0
  19. package/dist/dot-grid-pattern/index.js.map +1 -0
  20. package/dist/engine.d.ts +12 -0
  21. package/dist/engine.d.ts.map +1 -0
  22. package/dist/engine.js +12 -0
  23. package/dist/engine.js.map +1 -0
  24. package/dist/grid-pattern/grid-pattern.d.ts +31 -0
  25. package/dist/grid-pattern/grid-pattern.d.ts.map +1 -0
  26. package/dist/grid-pattern/grid-pattern.js +138 -0
  27. package/dist/grid-pattern/grid-pattern.js.map +1 -0
  28. package/dist/grid-pattern/index.d.ts +2 -0
  29. package/dist/grid-pattern/index.d.ts.map +1 -0
  30. package/dist/grid-pattern/index.js +2 -0
  31. package/dist/grid-pattern/index.js.map +1 -0
  32. package/dist/index.d.ts +6 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +6 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/kit/grid-lines.d.ts +104 -0
  37. package/dist/kit/grid-lines.d.ts.map +1 -0
  38. package/dist/kit/grid-lines.js +127 -0
  39. package/dist/kit/grid-lines.js.map +1 -0
  40. package/dist/kit/index.d.ts +3 -0
  41. package/dist/kit/index.d.ts.map +1 -0
  42. package/dist/kit/index.js +3 -0
  43. package/dist/kit/index.js.map +1 -0
  44. package/dist/kit/viewport-pattern.d.ts +36 -0
  45. package/dist/kit/viewport-pattern.d.ts.map +1 -0
  46. package/dist/kit/viewport-pattern.js +77 -0
  47. package/dist/kit/viewport-pattern.js.map +1 -0
  48. package/dist/line-grid-pattern/index.d.ts +2 -0
  49. package/dist/line-grid-pattern/index.d.ts.map +1 -0
  50. package/dist/line-grid-pattern/index.js +2 -0
  51. package/dist/line-grid-pattern/index.js.map +1 -0
  52. package/dist/line-grid-pattern/line-grid-pattern.d.ts +30 -0
  53. package/dist/line-grid-pattern/line-grid-pattern.d.ts.map +1 -0
  54. package/dist/line-grid-pattern/line-grid-pattern.js +96 -0
  55. package/dist/line-grid-pattern/line-grid-pattern.js.map +1 -0
  56. package/dist/nodes.d.ts +14 -0
  57. package/dist/nodes.d.ts.map +1 -0
  58. package/dist/nodes.js +14 -0
  59. package/dist/nodes.js.map +1 -0
  60. package/package.json +72 -3
  61. package/registry.json +26 -0
  62. package/src/dot-grid-pattern/dot-grid-pattern.ts +132 -0
  63. package/src/dot-grid-pattern/index.ts +1 -0
  64. package/src/engine.ts +11 -0
  65. package/src/grid-pattern/grid-pattern.ts +170 -0
  66. package/src/grid-pattern/index.ts +1 -0
  67. package/src/index.ts +5 -0
  68. package/src/kit/grid-lines.ts +199 -0
  69. package/src/kit/index.ts +2 -0
  70. package/src/kit/viewport-pattern.ts +98 -0
  71. package/src/line-grid-pattern/index.ts +1 -0
  72. package/src/line-grid-pattern/line-grid-pattern.ts +125 -0
  73. package/src/nodes.ts +14 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # @motionscript/patterns
2
+
3
+ ## 0.1.0-alpha.4
4
+
5
+ ### Minor Changes
6
+
7
+ - 3eefc7e: Package reshuffle.
8
+
9
+ - `@motionscript/layout-grid` is now `@motionscript/grids` (`@motionscript/grids/kit`, and `packages/components/grids`), and its `LayoutGrid` base class is `ItemGrid` (`ItemGridProps`, `ITEM_GRID_TYPES`). `RectangularGrid`, `RadialGrid`, `PathGrid` and `SphereGrid` keep their names and document keys. Update the dependency, the imports, and any `@motionscript/layout-grid/kit` specifier a copied component carries.
10
+ - `@motionscript/geo-data` is now `@motionscript/geography`. The data format on disk (`data/v1/…`) is unchanged, so `@motionscript/geo` reads it as before and a host that serves `@motionscript/geo-data/data` serves `@motionscript/geography/data` the same way.
11
+ - `@motionscript/ui` is removed: its `Switch`, `Button`, `Window` and `Cursor` nodes, and the `ControlNode` base class, no longer ship. They are plain nodes over `@motionscript/sdk`, so a project that needs one writes its own and shapes it to taste.
12
+ - `@motionscript/patterns` is new. It holds the pattern nodes (`LineGridPattern`, `DotGridPattern`, `GridPattern`, `ViewportPattern`) that `@motionscript/core` and `@motionscript/sdk` no longer ship.
13
+
14
+ ### Patch Changes
15
+
16
+ - a6c042d: `LineGridPattern` and `DotGridPattern` now put a line (or a dot column and row) on every edge of their box, whatever the number of cells. This changes how existing scenes with an odd `divisions × subdivisions` look: the lattice was centred on the box, so `divisions: 1` drew a single line through the middle and `divisions: 3` drew three lines with none on the edges, where a grid of `divisions: 4` has always drawn five. The lattice now starts at the near edge, and with an odd `divisions` and an even `subdivisions` (such as `3` and `2`) the major lines are the division lines, edges included, rather than the middle ones. A grid with an even `divisions`, and `GridPattern`'s world-anchored lattice, are drawn exactly as before.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,48 @@
1
+ Motionscript
2
+ Copyright 2026 Motionscript LLC
3
+
4
+ This product includes the third-party code below, each part under the MIT
5
+ License reproduced at the end of this file.
6
+
7
+ - packages/skia-render/src/fills/fractal-noise.ts: `hash2` is "Hash without
8
+ Sine" by David Hoskins (https://www.shadertoy.com/view/4djSRW).
9
+ Copyright (c) 2014 David Hoskins.
10
+
11
+ - packages/skia-render/src/fills/fractal-noise.ts: `simplexNoise` follows
12
+ "Noise - simplex - 2D" by Inigo Quilez (https://www.shadertoy.com/view/Msf3WH).
13
+ Copyright (c) 2013 Inigo Quilez.
14
+
15
+ The project website, which is in the source repository only and in no npm
16
+ package, also includes MIT code: its landing-page background
17
+ (packages/site/components/landing/GradientBackground.tsx) uses 3D simplex
18
+ noise from webgl-noise by Ian McEwan, Ashima Arts
19
+ (https://github.com/ashima/webgl-noise). Copyright (C) 2011 by Ashima Arts.
20
+
21
+ @motionscript/canvaskit is a build of Skia's CanvasKit (BSD-3-Clause,
22
+ Copyright (c) 2011 Google Inc.) and carries FreeType, HarfBuzz, ICU, zlib,
23
+ libpng, Brotli, WOFF2, Emscripten and musl; their notices are in
24
+ packages/canvaskit/THIRD_PARTY_NOTICES.txt.
25
+
26
+ The browser builds under dist/browser/ bundle each package's npm dependencies;
27
+ dist/browser/THIRD_PARTY_LICENSES.txt in each package lists them with their
28
+ licences.
29
+
30
+ MIT License
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining a copy
33
+ of this software and associated documentation files (the "Software"), to deal
34
+ in the Software without restriction, including without limitation the rights
35
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
+ copies of the Software, and to permit persons to whom the Software is
37
+ furnished to do so, subject to the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be included in all
40
+ copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,79 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @motionscript/patterns
2
+
3
+ Grid backgrounds for [Motion Script](https://motionscript.dev): `LineGridPattern`
4
+ and `DotGridPattern` fill a box of their own, and `GridPattern` is an infinite
5
+ grid that fills whatever a `Camera` can currently see.
6
+
7
+ ```ts
8
+ import { NODES } from '@motionscript/patterns';
9
+
10
+ // hand them to an engine: new Engine(platform, { nodes: NODES })
11
+ ```
12
+
13
+ Documents name them `lineGridPattern`, `dotGridPattern` and `gridPattern`.
14
+ The engine does not know these keys on its own: a document that names one needs
15
+ the engine given `NODES`.
16
+
17
+ ## Laid together
18
+
19
+ `DotGridPattern` shares `divisions`, `subdivisions` and `offset` with
20
+ `LineGridPattern`, and both tile through the same function, so a dot grid laid
21
+ over a line grid with the same numbers keeps its dots on the intersections while
22
+ both scroll. `GridPattern` extends `ViewportPattern`, which is exported for a
23
+ pattern of your own: it is handed the region the camera sees and only generates
24
+ what is on screen.
25
+
26
+ Core's `grid` and `dotGrid` **fills** are a different thing: paints over any
27
+ shape, built into the engine.
28
+
29
+ ## Nodes and props
30
+
31
+ All three are shapes (`parentKey: 'shape'`), so they take a shape's paint props
32
+ (`fill`, `stroke`, `shadow`, ...) and children, and declare no commands of their
33
+ own: `to` on `offset` (all three) and on `cellSize` (`gridPattern`) animates them.
34
+
35
+ | Key | Own props | Space |
36
+ |---|---|---|
37
+ | `lineGridPattern` | `divisions` (4), `subdivisions` (1), `subStroke`, `offset` | the node's box, in pixels |
38
+ | `dotGridPattern` | `divisions` (4), `subdivisions` (1), `radius` (3), `subScale` (0.5), `offset` | the node's box, in pixels |
39
+ | `gridPattern` | `cellSize` (100; a number or `{ x, y }`), `subdivisions` (1), `subStroke`, `offset` | world units |
40
+
41
+ `stroke` paints the major lines and `subStroke` the minor ones (drawn when
42
+ `subdivisions > 1`); when a pattern is built with a `stroke` and no `subStroke`, the
43
+ minor stroke is the major one at half opacity.
44
+
45
+ - **One tiling.** Every mark of every pattern comes from `addTiledLines`
46
+ (`src/kit/grid-lines.ts`), so patterns with the same `divisions`, `subdivisions` and
47
+ `offset` agree on every intersection. A mark is major by its tile index against the
48
+ un-panned grid, so panning never changes a mark's class.
49
+ - **`gridPattern` is world-locked and has no box of its own.** `ViewportPattern`
50
+ draws over `visibleBounds()`: the world rect the nearest `Camera` ancestor sees
51
+ (widened to the bounding box of the turned viewport when it has a `heading`), or,
52
+ with no camera, the node's own layout rect centred on its origin. Nothing is kept
53
+ between frames, so a pan or zoom regenerates the marks for the region; only
54
+ `offset` moves it relative to the world. A dashed stroke is drawn line by line with
55
+ its dash phase locked to the world, and each line's span snapped to whole dash
56
+ cycles, so dashes do not crawl as the camera moves.
57
+ - **Lines are centred.** A line has no inside, so stroke `align` is ignored. A
58
+ `lineGridPattern` insets its extent by half the thickest stroke so the outer lines
59
+ are not cut by the box, and `dotGridPattern` by the dot radius.
60
+ - **A degenerate step or an empty box draws nothing**; none of them throws.
61
+
62
+ ## Usage
63
+
64
+ ```bash
65
+ npm install @motionscript/patterns @motionscript/sdk
66
+ ```
67
+
68
+ Or copy one into a project with `ms add line-grid-pattern`, `ms add dot-grid-pattern`
69
+ or `ms add grid-pattern`; a copy keeps importing `ViewportPattern` and the tiling
70
+ helpers from `@motionscript/patterns/kit`.
71
+
72
+ ## Development
73
+
74
+ From the monorepo root:
75
+
76
+ ```bash
77
+ pnpm --filter @motionscript/patterns build
78
+ pnpm --filter @motionscript/patterns test
79
+ ```
@@ -0,0 +1,2 @@
1
+ import{strokeOps as x}from"@motionscript/sdk";function y(e,t,o,i,n=0){let s=[],h=[],r=[],f=[],l=u(t.min-i,t.step,t.offset,n,Math.floor),m=u(t.max+i,t.step,t.offset,n,Math.ceil),a=u(e.min-i,e.step,e.offset,n,Math.floor),p=u(e.max+i,e.step,e.offset,n,Math.ceil);return M(e.min,e.max,e.step,e.offset,o,i,(c,d)=>{(d?s:h).push(c)},e.anchor),M(t.min,t.max,t.step,t.offset,o,i,(c,d)=>{(d?r:f).push(c)},t.anchor),{top:l,bottom:m,left:a,right:p,verticalMajor:s,verticalMinor:h,horizontalMajor:r,horizontalMinor:f}}function z(e,t,o,i){let n=y(e,t,o,i),s=[],h=[];for(let r of n.verticalMajor)s.push({type:"M",x:r,y:n.top},{type:"L",x:r,y:n.bottom});for(let r of n.verticalMinor)h.push({type:"M",x:r,y:n.top},{type:"L",x:r,y:n.bottom});for(let r of n.horizontalMajor)s.push({type:"M",x:n.left,y:r},{type:"L",x:n.right,y:r});for(let r of n.horizontalMinor)h.push({type:"M",x:n.left,y:r},{type:"L",x:n.right,y:r});return{major:s,minor:h}}function u(e,t,o,i,n){return i>0?n(e/i)*i:t<=0?e:n((e-o)/t)*t+o}function M(e,t,o,i,n,s,h,r=0){if(o<=0)return;let f=o*1e-6,l=Math.ceil((e-s-i-r-f)/o),m=Math.floor((t+s-i-r+f)/o);for(let a=l;a<=m;a++){let p=r+a*o+i,c=(a%n+n)%n===0;h(p,c)}}function C(e){let t=0;for(let o of e)o.weight>t&&(t=o.weight);return t}function k(e){return e.map(t=>t.align===0?t:{...t,align:0})}function B(e,t){return x.resolve(e.map(o=>({...o,fill:o.fill.map(i=>({...i,opacity:(i.opacity??1)*t}))})))}import{Camera as w,Clip as b,ShapeNode as L}from"@motionscript/sdk";var g=class extends L{renderSelf(t){let o=this.visibleBounds();t.beginClip(new b().rect({x:o.x,y:o.y,width:o.width,height:o.height})),this.renderPattern(t,o),t.endClip()}visibleBounds(){let t=this.findCamera();if(!t){let a=this.layoutBounds?.width??0,p=this.layoutBounds?.height??0;return{x:0,y:0,width:a,height:p}}let o=t.measuredWidth,i=t.measuredHeight,n=t.zoom||1,s=t.heading,h=o/2/n,r=i/2/n,f=h,l=r;if(s!==0){let a=s*Math.PI/180,p=Math.abs(Math.cos(a)),c=Math.abs(Math.sin(a));f=h*p+r*c,l=h*c+r*p}let m=t.lookAt;return{x:m.x,y:m.y,width:f*2,height:l*2}}findCamera(){for(let t=this.parent;t;t=t.parent)if(t instanceof w)return t;return null}};export{y as a,z as b,M as c,C as d,k as e,B as f,g};
2
+ //# sourceMappingURL=chunk-EZEE76AY.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/kit/grid-lines.ts", "../../../src/kit/viewport-pattern.ts"],
4
+ "sourcesContent": ["import { strokeOps, type PathCommand, type StrokeProp, type StrokeResolved } from \"@motionscript/sdk\";\r\n\r\n/**\r\n * Shared geometry for line grids. Both {@link LineGridPattern} (a fixed grid filling\r\n * its layout rect) and {@link GridPattern} (an infinite grid tiled across the\r\n * camera's visible region) build the same multi-subpath line paths from these\r\n * helpers — they differ only in how the extent and step are chosen.\r\n *\r\n * Lines are tiled by the minor step and panned by an origin offset: every\r\n * position within the extent (grown by `overscan` so thick lines clip out\r\n * smoothly) is emitted regardless of the offset, so the area always stays full\r\n * and animating the offset scrolls the grid. The lattice starts at the axis's\r\n * `anchor` (the world origin unless it says otherwise). A tile whose index\r\n * aligns to the division grid is major; the rest are minor. Each is built as a\r\n * single multi-subpath path so the trailing stroke paints every line as one\r\n * union with no destructive boolean op (which would erase the open lines).\r\n */\r\n\r\n/** A grid extent on one axis: lines tile within `[min, max]`, on a lattice that starts at `anchor`. */\r\nexport interface GridAxis {\r\n /** Minimum coordinate (typically negative). */\r\n min: number;\r\n /** Maximum coordinate. */\r\n max: number;\r\n /** Spacing between adjacent (minor) lines. */\r\n step: number;\r\n /** Pan offset in pixels along this axis. */\r\n offset: number;\r\n /**\r\n * Where the lattice starts: a line sits at `anchor + n * step`, and the tile\r\n * index `n` that decides which lines are major counts from there. Omitted it is 0, the\r\n * world origin, which is what a grid that follows a camera keeps. A grid with a box of its\r\n * own sets it to `min`, so the box's edges are lines whatever the count of cells.\r\n */\r\n anchor?: number;\r\n}\r\n\r\n/** The resolved grid: where each line sits and how far it runs. Vertical lines\r\n * sit at x = `verticalX[i]` and run from `top` to `bottom`; horizontal lines sit\r\n * at y = `horizontalY[i]` and run from `left` to `right`. Positions are split\r\n * into major (division) and minor (subdivision) lines. */\r\nexport interface GridLines {\r\n /** y-extent every vertical line spans. */\r\n top: number;\r\n bottom: number;\r\n /** x-extent every horizontal line spans. */\r\n left: number;\r\n right: number;\r\n verticalMajor: number[];\r\n verticalMinor: number[];\r\n horizontalMajor: number[];\r\n horizontalMinor: number[];\r\n}\r\n\r\n/**\r\n * Resolve the grid for the given per-axis extents: the cross-axis span and the\r\n * major/minor line positions on each axis. Vertical lines span the full y\r\n * extent; horizontal lines span the full x extent. Both spans are grown by\r\n * `overscan` so a thick line slides out under the clip instead of popping, and\r\n * snapped outward to the grid so the endpoints sit on stable world positions\r\n * (a line's start stays fixed as the camera pans, so a dashed stroke anchored to\r\n * it doesn't crawl).\r\n *\r\n * `cycle` (the dash period, when dashed) snaps the cross-axis span to a whole\r\n * number of dash cycles too, so each parallel line is the same dash-aligned\r\n * length and the renderer's per-path dash-fit becomes a no-op (no per-frame\r\n * resizing of the dashes as lines enter and leave view).\r\n */\r\nexport function gridLines(\r\n x: GridAxis,\r\n y: GridAxis,\r\n subdivisions: number,\r\n overscan: number,\r\n cycle = 0,\r\n): GridLines {\r\n const verticalMajor: number[] = [];\r\n const verticalMinor: number[] = [];\r\n const horizontalMajor: number[] = [];\r\n const horizontalMinor: number[] = [];\r\n\r\n // Span each line across the cross axis, snapped outward to the grid (and to\r\n // the dash cycle when dashed) so the endpoints sit on stable world positions.\r\n const top = snapSpan(y.min - overscan, y.step, y.offset, cycle, Math.floor);\r\n const bottom = snapSpan(y.max + overscan, y.step, y.offset, cycle, Math.ceil);\r\n const left = snapSpan(x.min - overscan, x.step, x.offset, cycle, Math.floor);\r\n const right = snapSpan(x.max + overscan, x.step, x.offset, cycle, Math.ceil);\r\n\r\n addTiledLines(x.min, x.max, x.step, x.offset, subdivisions, overscan, (px, isMajor) => {\r\n (isMajor ? verticalMajor : verticalMinor).push(px);\r\n }, x.anchor);\r\n addTiledLines(y.min, y.max, y.step, y.offset, subdivisions, overscan, (py, isMajor) => {\r\n (isMajor ? horizontalMajor : horizontalMinor).push(py);\r\n }, y.anchor);\r\n\r\n return { top, bottom, left, right, verticalMajor, verticalMinor, horizontalMajor, horizontalMinor };\r\n}\r\n\r\n/**\r\n * Build the grid lines as multi-subpath path commands, split into the major\r\n * (division) lines and the minor (subdivision) lines, for the given per-axis\r\n * extents. Every line in a group shares one stroke (drawn as one union path), so\r\n * this is the path for solid strokes; dashed strokes that must stay world-locked\r\n * draw per line from {@link gridLines} instead.\r\n */\r\nexport function gridLinePaths(\r\n x: GridAxis,\r\n y: GridAxis,\r\n subdivisions: number,\r\n overscan: number,\r\n): { major: PathCommand[]; minor: PathCommand[] } {\r\n const g = gridLines(x, y, subdivisions, overscan);\r\n const major: PathCommand[] = [];\r\n const minor: PathCommand[] = [];\r\n for (const px of g.verticalMajor) major.push({ type: \"M\", x: px, y: g.top }, { type: \"L\", x: px, y: g.bottom });\r\n for (const px of g.verticalMinor) minor.push({ type: \"M\", x: px, y: g.top }, { type: \"L\", x: px, y: g.bottom });\r\n for (const py of g.horizontalMajor) major.push({ type: \"M\", x: g.left, y: py }, { type: \"L\", x: g.right, y: py });\r\n for (const py of g.horizontalMinor) minor.push({ type: \"M\", x: g.left, y: py }, { type: \"L\", x: g.right, y: py });\r\n return { major, minor };\r\n}\r\n\r\n// Snap `pos` outward to a stable world position so a dashed line's start stays\r\n// fixed as the viewport moves (the renderer anchors dash phase to the subpath\r\n// start). Snap to the grid line lattice (`n*step + offset`); when a dash `cycle`\r\n// is given, snap to the dash lattice instead (`n*cycle`, anchored to world 0) so\r\n// every parallel line is the same whole number of cycles long and the renderer's\r\n// per-path dash-fit stays a no-op. `round` is `Math.floor` to snap below, `ceil`\r\n// to snap above. The lattice is the one about 0 whatever an axis's `anchor`: a span\r\n// only has to reach past the edge, and a line's ends stay where they always were.\r\nfunction snapSpan(pos: number, step: number, offset: number, cycle: number, round: (n: number) => number): number {\r\n if (cycle > 0) return round(pos / cycle) * cycle;\r\n if (step <= 0) return pos;\r\n return round((pos - offset) / step) * step + offset;\r\n}\r\n\r\n/**\r\n * Emit every grid line position in `[min, max]` (grown by `overscan` on each\r\n * end) for a grid of spacing `step`, panned by `offset` px. Without panning the\r\n * lattice starts at `anchor` (0 unless given) and its tile indices count outward\r\n * from there; the line at tile index `n` is major when `n` is a multiple of\r\n * `subdivisions`. The pan shifts each position by `offset` while keeping the\r\n * area full, so `n` is taken relative to the un-panned lattice (offset folded\r\n * out) to keep classification stable as it scrolls.\r\n *\r\n * A fixed grid anchors at `min`, so its first line is on the box's edge and the\r\n * last is too whenever the extent is a whole number of steps. An infinite grid\r\n * keeps the default, so its lines stay on the world's lattice.\r\n */\r\nexport function addTiledLines(\r\n min: number,\r\n max: number,\r\n step: number,\r\n offset: number,\r\n subdivisions: number,\r\n overscan: number,\r\n emit: (pos: number, isMajor: boolean) => void,\r\n anchor = 0,\r\n): void {\r\n if (step <= 0) return;\r\n // First/last tile index whose panned position is within the overscanned\r\n // [min, max]. Positions are `anchor + n*step + offset` (n=0 sits on the\r\n // anchor). A small epsilon keeps a line that lands exactly on an edge (an\r\n // anchor at `min`, or a world lattice that reaches it) from being dropped by FP error.\r\n const eps = step * 1e-6;\r\n const startN = Math.ceil((min - overscan - offset - anchor - eps) / step);\r\n const endN = Math.floor((max + overscan - offset - anchor + eps) / step);\r\n for (let n = startN; n <= endN; n++) {\r\n const pos = anchor + n * step + offset;\r\n // mod that stays non-negative for negative n.\r\n const isMajor = ((n % subdivisions) + subdivisions) % subdivisions === 0;\r\n emit(pos, isMajor);\r\n }\r\n}\r\n\r\n/** Largest stroke weight across the layers of a resolved stroke array. Used to\r\n * overscan the tiling so a thick line stays drawn until fully off the area. */\r\nexport function maxWeight(strokes: StrokeResolved[]): number {\r\n let max = 0;\r\n for (const s of strokes) if (s.weight > max) max = s.weight;\r\n return max;\r\n}\r\n\r\n/** Force every layer of a resolved stroke array to centered alignment. Grid\r\n * lines are open paths, not a closed region, so inside/outside alignment is\r\n * meaningless — they always straddle their position. (Open paths are already\r\n * stroked centered by the renderer; this makes the intent explicit and ignores\r\n * any author `align`.) */\r\nexport function centered(strokes: StrokeResolved[]): StrokeResolved[] {\r\n return strokes.map(s => (s.align === 0 ? s : { ...s, align: 0 }));\r\n}\r\n\r\n/** Copy a resolved stroke array with every fill layer's opacity scaled by\r\n * `factor`. Used to derive the default minor-line stroke from the major one.\r\n * Every resolved fill carries an `opacity` field, so this is type-uniform. */\r\nexport function dimStroke(strokes: StrokeResolved[], factor: number): StrokeResolved[] {\r\n return strokeOps.resolve(strokes.map(s => ({\r\n ...s,\r\n fill: s.fill.map(f => ({ ...f, opacity: (f.opacity ?? 1) * factor })),\r\n })) as unknown as StrokeProp[]);\r\n}\r\n", "import {\r\n Camera,\r\n Clip,\r\n ShapeNode,\r\n type BoxBounds,\r\n type RenderContext2D,\r\n type ShapeProps,\r\n} from \"@motionscript/sdk\";\r\n\r\n/**\r\n * Base for backgrounds that fill whatever region is currently visible, rather\r\n * than a fixed rect. Placed inside a {@link Camera}, the node resolves the\r\n * world region the camera can currently see (from its `zoom`/`origin`/`heading`)\r\n * and hands those bounds to {@link renderPattern}, so the subclass only ever\r\n * generates geometry for what's on screen — no oversized static node sized for\r\n * the worst-case pan/zoom.\r\n *\r\n * With no ancestor `Camera` the node falls back to its own layout rect, so the\r\n * same pattern doubles as an ordinary full-bleed background.\r\n *\r\n * The pattern node is itself a camera child, laid out stack-style at the\r\n * camera's centre, so its local draw space shares the world origin its siblings\r\n * use. The visible region is therefore expressed directly in that space: centred\r\n * on the camera's `origin`, sized to the inverse of the camera transform.\r\n */\r\nexport abstract class ViewportPattern<P extends ShapeProps = ShapeProps> extends ShapeNode<P> {\r\n\r\n /**\r\n * Fill `bounds` (in this node's local draw space) with the pattern. Called\r\n * once per render with the currently-visible region. The `centerBounds` for\r\n * path ops drawn here is `[bounds.x - w/2, bounds.y - h/2, bounds.x + w/2,\r\n * bounds.y + h/2]`.\r\n */\r\n protected abstract renderPattern(draw: RenderContext2D, bounds: BoxBounds): void;\r\n\r\n protected renderSelf(draw: RenderContext2D): void {\r\n const bounds = this.visibleBounds();\r\n // Clip to the visible region so geometry overscanned past the edge (so\r\n // thick lines slide out instead of popping) trims cleanly. When inside a\r\n // camera the viewport already clips, but this keeps edge strokes clean\r\n // and bounds the work in the no-camera fallback too.\r\n draw.beginClip(new Clip().rect({ x: bounds.x, y: bounds.y, width: bounds.width, height: bounds.height }));\r\n this.renderPattern(draw, bounds);\r\n draw.endClip();\r\n }\r\n\r\n /**\r\n * The region this node should cover, in its own local draw space. Inside a\r\n * camera this is the world rect the camera currently sees; otherwise it's the\r\n * node's own layout rect (a normal background).\r\n */\r\n protected visibleBounds(): BoxBounds {\r\n const camera = this.findCamera();\r\n if (!camera) {\r\n // No camera — fill our own cell, centred on this node's origin.\r\n const w = this.layoutBounds?.width ?? 0;\r\n const h = this.layoutBounds?.height ?? 0;\r\n return { x: 0, y: 0, width: w, height: h };\r\n }\r\n\r\n const vw = camera.measuredWidth;\r\n const vh = camera.measuredHeight;\r\n const zoom = camera.zoom || 1;\r\n const heading = camera.heading;\r\n\r\n // Inverse of the camera scale: a viewport `vw×vh` shows `vw/zoom × vh/zoom`\r\n // of the world.\r\n const hw = vw / 2 / zoom;\r\n const hh = vh / 2 / zoom;\r\n\r\n // With a heading the visible world rect is rotated; take its axis-aligned\r\n // bounding box so the pattern covers the rotated viewport's full extent.\r\n let bw = hw;\r\n let bh = hh;\r\n if (heading !== 0) {\r\n const rad = (heading * Math.PI) / 180;\r\n const cos = Math.abs(Math.cos(rad));\r\n const sin = Math.abs(Math.sin(rad));\r\n bw = hw * cos + hh * sin;\r\n bh = hw * sin + hh * cos;\r\n }\r\n\r\n // The visible region centres on the camera's `lookAt`, returned in y-UP\r\n // world space (matching the descriptor convention; the renderer applies\r\n // the single y-up→canvas flip when the pattern's shapes are drawn). A\r\n // y-down consumer would have wanted -lookAt.y; we hand back the y-up value.\r\n const lookAt = camera.lookAt;\r\n return { x: lookAt.x, y: lookAt.y, width: bw * 2, height: bh * 2 };\r\n }\r\n\r\n /** Nearest ancestor {@link Camera}, or `null` when rendered outside one. */\r\n protected findCamera(): Camera | null {\r\n for (let n = this.parent; n; n = n.parent) {\r\n if (n instanceof Camera) return n;\r\n }\r\n return null;\r\n }\r\n}\r\n"],
5
+ "mappings": "AAAA,OAAS,aAAAA,MAAyE,oBAoE5E,SAAUC,EACZC,EACAC,EACAC,EACAC,EACAC,EAAQ,EAAC,CAET,IAAMC,EAA0B,CAAA,EAC1BC,EAA0B,CAAA,EAC1BC,EAA4B,CAAA,EAC5BC,EAA4B,CAAA,EAI5BC,EAAMC,EAAST,EAAE,IAAME,EAAUF,EAAE,KAAMA,EAAE,OAAQG,EAAO,KAAK,KAAK,EACpEO,EAASD,EAAST,EAAE,IAAME,EAAUF,EAAE,KAAMA,EAAE,OAAQG,EAAO,KAAK,IAAI,EACtEQ,EAAOF,EAASV,EAAE,IAAMG,EAAUH,EAAE,KAAMA,EAAE,OAAQI,EAAO,KAAK,KAAK,EACrES,EAAQH,EAASV,EAAE,IAAMG,EAAUH,EAAE,KAAMA,EAAE,OAAQI,EAAO,KAAK,IAAI,EAE3E,OAAAU,EAAcd,EAAE,IAAKA,EAAE,IAAKA,EAAE,KAAMA,EAAE,OAAQE,EAAcC,EAAU,CAACY,EAAIC,IAAW,EACjFA,EAAUX,EAAgBC,GAAe,KAAKS,CAAE,CACrD,EAAGf,EAAE,MAAM,EACXc,EAAcb,EAAE,IAAKA,EAAE,IAAKA,EAAE,KAAMA,EAAE,OAAQC,EAAcC,EAAU,CAACc,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AMC,CAAM,EAC/BD,EAAK,QAAO,CAChB,CAOU,eAAa,CACnB,IAAME,EAAS,KAAK,WAAU,EAC9B,GAAI,CAACA,EAAQ,CAET,IAAMC,EAAI,KAAK,cAAc,OAAS,EAChCC,EAAI,KAAK,cAAc,QAAU,EACvC,MAAO,CAAE,EAAG,EAAG,EAAG,EAAG,MAAOD,EAAG,OAAQC,CAAC,CAC5C,CAEA,IAAMC,EAAKH,EAAO,cACZI,EAAKJ,EAAO,eACZK,EAAOL,EAAO,MAAQ,EACtBM,EAAUN,EAAO,QAIjBO,EAAKJ,EAAK,EAAIE,EACdG,EAAKJ,EAAK,EAAIC,EAIhBI,EAAKF,EACLG,EAAKF,EACT,GAAIF,IAAY,EAAG,CACf,IAAMK,EAAOL,EAAU,KAAK,GAAM,IAC5BM,EAAM,KAAK,IAAI,KAAK,IAAID,CAAG,CAAC,EAC5BE,EAAM,KAAK,IAAI,KAAK,IAAIF,CAAG,CAAC,EAClCF,EAAKF,EAAKK,EAAMJ,EAAKK,EACrBH,EAAKH,EAAKM,EAAML,EAAKI,CACzB,CAMA,IAAME,EAASd,EAAO,OACtB,MAAO,CAAE,EAAGc,EAAO,EAAG,EAAGA,EAAO,EAAG,MAAOL,EAAK,EAAG,OAAQC,EAAK,CAAC,CACpE,CAGU,YAAU,CAChB,QAASK,EAAI,KAAK,OAAQA,EAAGA,EAAIA,EAAE,OAC/B,GAAIA,aAAarB,EAAQ,OAAOqB,EAEpC,OAAO,IACX",
6
+ "names": ["strokeOps", "gridLines", "x", "y", "subdivisions", "overscan", "cycle", "verticalMajor", "verticalMinor", "horizontalMajor", "horizontalMinor", "top", "snapSpan", "bottom", "left", "right", "addTiledLines", "px", "isMajor", "py", "gridLinePaths", "g", "major", "minor", "pos", "step", "offset", "round", "min", "max", "emit", "anchor", "eps", "startN", "endN", "n", "maxWeight", "strokes", "s", "centered", "dimStroke", "factor", "f", "Camera", "Clip", "ShapeNode", "ViewportPattern", "draw", "bounds", "camera", "w", "h", "vw", "vh", "zoom", "heading", "hw", "hh", "bw", "bh", "rad", "cos", "sin", "lookAt", "n"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{a as z,b as A,c as C,d as g,e as S,f as j,g as N}from"./chunks/chunk-EZEE76AY.js";import{Clip as V,Graphics2D as O,ShapeNode as K,lerpVector2 as E,node as H,property as L,strokeProperty as T}from"@motionscript/sdk";var P=function(h,t,e,r){var i=arguments.length,o=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(h,t,e,r);else for(var a=h.length-1;a>=0;a--)(s=h[a])&&(o=(i<3?s(o):i>3?s(t,e,o):s(t,e))||o);return i>3&&o&&Object.defineProperty(t,e,o),o},y=class extends K{get subStroke(){}set subStroke(t){}constructor(t){super(t),t.subStroke===void 0&&t.stroke!==void 0&&this.subdivisions>1&&this.set({subStroke:j(this.stroke,.5)})}declareAssets(t){super.declareAssets(t);for(let e of this.subStroke)t.fill(e.fill)}renderSelf(t){let e=this.layoutBounds.width,r=this.layoutBounds.height,i=[-e/2,-r/2,e/2,r/2];t.draw(new O().rect({width:e,height:r,start:this.start,end:this.end}).shadow(this.shadow).fill(this.fill));let o=Math.max(1,Math.floor(this.divisions)),s=Math.max(1,Math.floor(this.subdivisions)),a=S(this.stroke),l=S(this.subStroke),n=Math.max(g(a),g(l))/2,{major:f,minor:p}=this._gridPaths(e,r,o,s,n);t.beginClip(new V().rect({width:e,height:r})),s>1&&l.length>0&&p.length>0&&t.draw(new O().path({data:p,centerBounds:i}).stroke(l)),f.length>0&&t.draw(new O().path({data:f,centerBounds:i}).stroke(a)),t.endClip()}clipSelf(){return new V().rect({width:this.layoutBounds.width,height:this.layoutBounds.height})}_gridPaths(t,e,r,i,o){let s=r*i,a=Math.max(0,t-2*o),l=Math.max(0,e-2*o),n=t/2-o,f=e/2-o;return A({min:-n,max:n,step:a/s,offset:this.offset.x,anchor:-n},{min:-f,max:f,step:l/s,offset:this.offset.y,anchor:-f},i,o)}};P([L({default:4})],y.prototype,"divisions",void 0);P([L({default:1})],y.prototype,"subdivisions",void 0);P([T()],y.prototype,"subStroke",null);P([L({default:{x:0,y:0},tween:E})],y.prototype,"offset",void 0);y=P([H({key:"lineGridPattern",parentKey:"shape",forkable:!0})],y);import{Clip as q,Graphics2D as F,ShapeNode as I,lerpVector2 as J,node as Q,property as k}from"@motionscript/sdk";var M=function(h,t,e,r){var i=arguments.length,o=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(h,t,e,r);else for(var a=h.length-1;a>=0;a--)(s=h[a])&&(o=(i<3?s(o):i>3?s(t,e,o):s(t,e))||o);return i>3&&o&&Object.defineProperty(t,e,o),o};function W(h,t,e,r,i,o){let s=[];return C(h,t,e,r,i,o,(a,l)=>{s.push({pos:a,isMajor:l})},h),s}var u=class extends I{shapeGraphics(){let t=this.layoutBounds,e=t?.width??0,r=t?.height??0;if(e<=0||r<=0)return null;let i=Math.max(1,Math.floor(this.divisions)),o=Math.max(1,Math.floor(this.subdivisions)),s=Math.max(0,this.radius),a=s*Math.max(0,this.subScale);if(s<=0&&a<=0)return null;let l=i*o,n=Math.max(0,e/2-s),f=Math.max(0,r/2-s),p=W(-n,n,n*2/l,this.offset.x,o,s),x=W(-f,f,f*2/l,this.offset.y,o,s),c=new F,d=!1;for(let b of p)for(let v of x){let w=b.isMajor&&v.isMajor?s:a;w<=0||(c.ellipse({x:b.pos,y:v.pos,width:w*2,height:w*2}),d=!0)}return d?c:null}clipSelf(){let t=this.layoutBounds;return new q().rect({width:t?.width??0,height:t?.height??0})}};M([k({default:4})],u.prototype,"divisions",void 0);M([k({default:1})],u.prototype,"subdivisions",void 0);M([k({default:3})],u.prototype,"radius",void 0);M([k({default:.5})],u.prototype,"subScale",void 0);M([k({default:{x:0,y:0},tween:J})],u.prototype,"offset",void 0);u=M([Q({key:"dotGridPattern",parentKey:"shape",forkable:!0})],u);import{Graphics2D as _,lerpNumber as U,lerpVector2 as Y,node as Z,property as D,strokeProperty as $}from"@motionscript/sdk";var G=function(h,t,e,r){var i=arguments.length,o=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(h,t,e,r);else for(var a=h.length-1;a>=0;a--)(s=h[a])&&(o=(i<3?s(o):i>3?s(t,e,o):s(t,e))||o);return i>3&&o&&Object.defineProperty(t,e,o),o},m=class extends N{get subStroke(){}set subStroke(t){}constructor(t){super(t),t.subStroke===void 0&&t.stroke!==void 0&&this.subdivisions>1&&this.set({subStroke:j(this.stroke,.5)})}declareAssets(t){super.declareAssets(t);for(let e of this.subStroke)t.fill(e.fill)}renderPattern(t,e){let r=e.width/2,i=e.height/2,o=e.x-r,s=e.x+r,a=e.y-i,l=e.y+i;t.draw(new _().rect({x:e.x,y:e.y,width:e.width,height:e.height,start:this.start,end:this.end}).shadow(this.shadow).fill(this.fill));let n=Math.max(1,Math.floor(this.subdivisions)),f=this.cellSize,p=Math.max(.001,typeof f=="number"?f:f.x),x=Math.max(.001,typeof f=="number"?f:f.y),c=p/n,d=x/n,b=S(this.stroke),v=S(this.subStroke),w=Math.max(g(b),g(v))/2,R={min:o,max:s,step:c,offset:this.offset.x},B={min:a,max:l,step:d,offset:this.offset.y};n>1&&v.length>0&&this._drawGroup(t,R,B,n,w,v,!1),b.length>0&&this._drawGroup(t,R,B,n,w,b,!0)}_drawGroup(t,e,r,i,o,s,a){let l=tt(s),n=z(e,r,i,o,l),f=a?n.verticalMajor:n.verticalMinor,p=a?n.horizontalMajor:n.horizontalMinor,x=[-1,-1,1,1];if(l<=0){let c=[];for(let d of f)c.push({type:"M",x:d,y:n.top},{type:"L",x:d,y:n.bottom});for(let d of p)c.push({type:"M",x:n.left,y:d},{type:"L",x:n.right,y:d});c.length>0&&t.draw(new _().path({data:c,centerBounds:x}).stroke(s));return}for(let c of f){let d=[{type:"M",x:c,y:n.top},{type:"L",x:c,y:n.bottom}];t.draw(new _().path({data:d,centerBounds:x}).stroke(X(s,n.top)))}for(let c of p){let d=[{type:"M",x:n.left,y:c},{type:"L",x:n.right,y:c}];t.draw(new _().path({data:d,centerBounds:x}).stroke(X(s,n.left)))}}};G([D({default:100,tween:et})],m.prototype,"cellSize",void 0);G([D({default:1})],m.prototype,"subdivisions",void 0);G([$()],m.prototype,"subStroke",null);G([D({default:{x:0,y:0},tween:Y})],m.prototype,"offset",void 0);m=G([Z({key:"gridPattern",parentKey:"shape",forkable:!0})],m);function tt(h){let t=0;for(let e of h)if(e.dash&&e.dash.length>0){let r=e.dash.reduce((i,o)=>i+o,0);r>t&&(t=r)}return t}function X(h,t){return h.map(e=>e.dash&&e.dash.length>0?{...e,dashOffset:(e.dashOffset??0)-t}:e)}function et(h,t,e){return typeof h=="number"&&typeof t=="number"?U(h,t,e):Y(typeof h=="number"?{x:h,y:h}:h,typeof t=="number"?{x:t,y:t}:t,e)}var ot=[y,u,m];export{u as DotGridPattern,m as GridPattern,y as LineGridPattern,ot as NODES,N as ViewportPattern,C as addTiledLines,S as centered,j as dimStroke,A as gridLinePaths,z as gridLines,g as maxWeight};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/line-grid-pattern/line-grid-pattern.ts", "../../src/dot-grid-pattern/dot-grid-pattern.ts", "../../src/grid-pattern/grid-pattern.ts", "../../src/nodes.ts"],
4
+ "sourcesContent": ["import {\r\n Clip,\r\n Graphics2D,\r\n ShapeNode,\r\n lerpVector2,\r\n node,\r\n property,\r\n strokeProperty,\r\n type AssetScope,\r\n type NodeConfig,\r\n type PathBounds,\r\n type PathCommand,\r\n type RenderContext2D,\r\n type ShapeProps,\r\n type Stroke,\r\n type StrokeResolved,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\n\r\nimport { centered, dimStroke, gridLinePaths, maxWeight } from \"../kit\";\r\n\r\nexport interface LineGridPatternProps extends ShapeProps {\r\n /** Cells along each axis: `divisions` of 4 draws 5 major lines per axis. */\r\n divisions: number;\r\n /** Finer cells each division is split into. 1 draws no minor lines; 2 adds one per division. */\r\n subdivisions: number;\r\n /** Stroke for the minor lines. Defaults to the major `stroke` at half opacity when `subdivisions > 1`. */\r\n subStroke?: Stroke;\r\n /** Pans the grid. Lines wrap and tile, so the rect stays full while `offset` scrolls it. */\r\n offset: Vector2;\r\n}\r\n\r\n/**\r\n * A rectangular grid of lines filling the node's layout rect.\r\n *\r\n * `stroke` paints the major lines and `subStroke` the minor ones, each as a\r\n * single union path. `fill` and `shadow` cover the whole rect, behind the lines.\r\n */\r\n@node({ key: \"lineGridPattern\", parentKey: \"shape\", forkable: true })\r\nexport class LineGridPattern extends ShapeNode<LineGridPatternProps> {\r\n\r\n @property({ default: 4 }) declare readonly divisions: number;\r\n @property({ default: 1 }) declare readonly subdivisions: number;\r\n // Asymmetric accessor like `ShapeNode.stroke`: reads yield `StrokeResolved[]`, writes accept `Stroke`.\r\n @strokeProperty()\r\n get subStroke(): StrokeResolved[] { return undefined!; }\r\n set subStroke(value: Stroke) { /* installed by @property */ }\r\n @property({ default: { x: 0, y: 0 }, tween: lerpVector2 })\r\n declare readonly offset: Vector2;\r\n\r\n constructor(props: NodeConfig<LineGridPattern, LineGridPatternProps>) {\r\n super(props);\r\n\r\n if (props.subStroke === undefined && props.stroke !== undefined && this.subdivisions > 1) {\r\n this.set({ subStroke: dimStroke(this.stroke as StrokeResolved[], 0.5) });\r\n }\r\n }\r\n\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n for (const stroke of this.subStroke) assets.fill(stroke.fill);\r\n }\r\n\r\n protected renderSelf(draw: RenderContext2D): void {\r\n const width = this.layoutBounds.width;\r\n const height = this.layoutBounds.height;\r\n const centerBounds: PathBounds = [-width / 2, -height / 2, width / 2, height / 2];\r\n\r\n draw.draw(new Graphics2D()\r\n .rect({ width, height, start: this.start, end: this.end })\r\n .shadow(this.shadow)\r\n .fill(this.fill));\r\n\r\n const divisions = Math.max(1, Math.floor(this.divisions));\r\n const subdivisions = Math.max(1, Math.floor(this.subdivisions));\r\n\r\n // Lines overscan the rect by half the thickest stroke and are clipped to it, so a\r\n // thick line slides out under the clip instead of popping at the boundary.\r\n const major = centered(this.stroke as StrokeResolved[]);\r\n const minorStroke = centered(this.subStroke as StrokeResolved[]);\r\n const overscan = Math.max(maxWeight(major), maxWeight(minorStroke)) / 2;\r\n const { major: majorLines, minor: minorLines } = this._gridPaths(width, height, divisions, subdivisions, overscan);\r\n\r\n draw.beginClip(new Clip().rect({ width, height }));\r\n // Minor lines first so the major lines sit on top.\r\n if (subdivisions > 1 && minorStroke.length > 0 && minorLines.length > 0) {\r\n draw.draw(new Graphics2D()\r\n .path({ data: minorLines, centerBounds })\r\n .stroke(minorStroke));\r\n }\r\n if (majorLines.length > 0) {\r\n draw.draw(new Graphics2D()\r\n .path({ data: majorLines, centerBounds })\r\n .stroke(major));\r\n }\r\n draw.endClip();\r\n }\r\n\r\n protected override clipSelf(): Clip {\r\n return new Clip().rect({\r\n width: this.layoutBounds.width,\r\n height: this.layoutBounds.height,\r\n });\r\n }\r\n\r\n // One multi-subpath path per group, so each stroke paints its lines as a union with no\r\n // destructive boolean op (which would erase open lines).\r\n private _gridPaths(width: number, height: number, divisions: number, subdivisions: number, overscan: number): { major: PathCommand[]; minor: PathCommand[] } {\r\n // Inset by `overscan` so the outermost lines sit fully inside the rect and are not\r\n // trimmed to half weight by the clip.\r\n const cols = divisions * subdivisions;\r\n const innerW = Math.max(0, width - 2 * overscan);\r\n const innerH = Math.max(0, height - 2 * overscan);\r\n const insetX = width / 2 - overscan;\r\n const insetY = height / 2 - overscan;\r\n\r\n // Anchored at the near edge, so a line sits on each edge of the box for any count of cells.\r\n return gridLinePaths(\r\n { min: -insetX, max: insetX, step: innerW / cols, offset: this.offset.x, anchor: -insetX },\r\n { min: -insetY, max: insetY, step: innerH / cols, offset: this.offset.y, anchor: -insetY },\r\n subdivisions,\r\n overscan,\r\n );\r\n }\r\n}\r\n", "import {\r\n Clip,\r\n Graphics2D,\r\n ShapeNode,\r\n lerpVector2,\r\n node,\r\n property,\r\n type ShapeProps,\r\n type Vector2,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport { addTiledLines } from \"../kit\"\r\n\r\n/** One mark's place on an axis, and whether it lands on the coarse grid. */\r\ninterface GridPosition {\r\n pos: number\r\n isMajor: boolean\r\n}\r\n\r\n// Calls the tiling `LineGridPattern` uses, so dots stay on its intersections at every offset.\r\nfunction gridPositions(\r\n min: number,\r\n max: number,\r\n step: number,\r\n offset: number,\r\n subdivisions: number,\r\n overscan: number\r\n): GridPosition[] {\r\n const out: GridPosition[] = []\r\n // Anchored at the near edge, so a column or row sits on each edge of the box for any count of cells.\r\n addTiledLines(min, max, step, offset, subdivisions, overscan, (pos, isMajor) => {\r\n out.push({ pos, isMajor })\r\n }, min)\r\n return out\r\n}\r\n\r\nexport interface DotGridPatternProps extends ShapeProps {\r\n /** Cells along each axis, as in `LineGridPattern.divisions`: 4 puts 5 major dots on each axis. */\r\n divisions: number\r\n /** Splits each division again. `1` draws only the major dots; `2` puts one minor dot between each pair. */\r\n subdivisions: number\r\n /** Radius of a major dot. */\r\n radius: number\r\n /**\r\n * A minor dot's radius as a fraction of a major one's. A fraction rather than a\r\n * second paint stack, so the whole field stays one fill and a gradient crosses\r\n * every dot in it.\r\n */\r\n subScale: number\r\n /** Pans the field, as `LineGridPattern.offset` does, so the two stay aligned while both scroll. */\r\n offset: Vector2\r\n}\r\n\r\n/**\r\n * A field of dots on the same `divisions` / `subdivisions` / `offset` as\r\n * {@link LineGridPattern}, so laid over one the dots sit on its intersections.\r\n *\r\n * The silhouette is the dots (see {@link DotGridPattern.shapeGraphics}), so\r\n * `ShapeNode` paints `shadow`, `fill`, `overlay` and `stroke` with no render code\r\n * here. A dot grid has no \"paper\": a rectangle behind it is how it gets a\r\n * background.\r\n *\r\n * `clipSelf` is the node's box rather than the silhouette, which clips outer dots\r\n * as they pan out and keeps the node selectable between dots. `start` / `end` act\r\n * on nothing: trimming a disc leaves a crescent, not a partial grid.\r\n */\r\n@node({ key: \"dotGridPattern\", parentKey: \"shape\", forkable: true })\r\nexport class DotGridPattern extends ShapeNode<DotGridPatternProps> {\r\n @property({ default: 4 }) declare readonly divisions: number\r\n @property({ default: 1 }) declare readonly subdivisions: number\r\n @property({ default: 3 }) declare readonly radius: number\r\n @property({ default: 0.5 }) declare readonly subScale: number\r\n @property({ default: { x: 0, y: 0 }, tween: lerpVector2 })\r\n declare readonly offset: Vector2\r\n\r\n /** Every dot in the field as one un-painted union: the paint stacks belong to the grid, not to a dot. */\r\n protected override shapeGraphics(): Graphics2D | null {\r\n const bounds = this.layoutBounds\r\n const width = bounds?.width ?? 0\r\n const height = bounds?.height ?? 0\r\n if (width <= 0 || height <= 0) return null\r\n\r\n const divisions = Math.max(1, Math.floor(this.divisions))\r\n const subdivisions = Math.max(1, Math.floor(this.subdivisions))\r\n const major = Math.max(0, this.radius)\r\n const minor = major * Math.max(0, this.subScale)\r\n if (major <= 0 && minor <= 0) return null\r\n\r\n // Inset by a dot's radius so an edge dot sits inside the box rather than being halved by the clip.\r\n const cols = divisions * subdivisions\r\n const insetX = Math.max(0, width / 2 - major)\r\n const insetY = Math.max(0, height / 2 - major)\r\n const xs = gridPositions(\r\n -insetX,\r\n insetX,\r\n (insetX * 2) / cols,\r\n this.offset.x,\r\n subdivisions,\r\n major\r\n )\r\n const ys = gridPositions(\r\n -insetY,\r\n insetY,\r\n (insetY * 2) / cols,\r\n this.offset.y,\r\n subdivisions,\r\n major\r\n )\r\n\r\n const dots = new Graphics2D()\r\n let drew = false\r\n for (const column of xs) {\r\n for (const row of ys) {\r\n // A dot is major only where *both* axes are — an intersection of two\r\n // major rules, which is exactly the point a line grid draws heaviest.\r\n const size = column.isMajor && row.isMajor ? major : minor\r\n if (size <= 0) continue\r\n dots.ellipse({ x: column.pos, y: row.pos, width: size * 2, height: size * 2 })\r\n drew = true\r\n }\r\n }\r\n return drew ? dots : null\r\n }\r\n\r\n protected override clipSelf(): Clip {\r\n const bounds = this.layoutBounds\r\n return new Clip().rect({\r\n width: bounds?.width ?? 0,\r\n height: bounds?.height ?? 0,\r\n })\r\n }\r\n}\r\n", "import {\r\n Graphics2D,\r\n lerpNumber,\r\n lerpVector2,\r\n node,\r\n property,\r\n strokeProperty,\r\n type AssetScope,\r\n type BoxBounds,\r\n type NodeConfig,\r\n type PathCommand,\r\n type RenderContext2D,\r\n type ShapeProps,\r\n type Stroke,\r\n type StrokeResolved,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\n\r\nimport { centered, dimStroke, gridLines, maxWeight, ViewportPattern, type GridAxis } from \"../kit\";\r\n\r\nexport interface GridPatternProps extends ShapeProps {\r\n /** Spacing between grid lines in world units: one number for both axes, or `{ x, y }`. */\r\n cellSize: number | Vector2;\r\n /** Finer cells each cell is split into, as in {@link LineGridPattern.subdivisions}. */\r\n subdivisions: number;\r\n /** Stroke for the minor lines. Defaults to the major `stroke` at half opacity when `subdivisions > 1`. */\r\n subStroke?: Stroke;\r\n /** Scrolls the pattern relative to the world, which it is otherwise anchored to. */\r\n offset: Vector2;\r\n}\r\n\r\n/**\r\n * An infinite line grid that fills the camera's visible region. Like\r\n * {@link LineGridPattern} it draws major and minor strokes over a fill and pans\r\n * with `offset`, but it tiles a world-anchored grid (spacing `cellSize`) across\r\n * what the parent {@link Camera} can see, regenerated each frame. With no camera\r\n * it fills its own layout rect.\r\n */\r\n@node({ key: \"gridPattern\", parentKey: \"shape\", forkable: true })\r\nexport class GridPattern extends ViewportPattern<GridPatternProps> {\r\n\r\n @property({ default: 100, tween: lerpCellSize })\r\n declare readonly cellSize: number | Vector2;\r\n @property({ default: 1 }) declare readonly subdivisions: number;\r\n // Asymmetric accessor like `ShapeNode.stroke`: reads yield `StrokeResolved[]`, writes accept `Stroke`.\r\n @strokeProperty()\r\n get subStroke(): StrokeResolved[] { return undefined!; }\r\n set subStroke(value: Stroke) { /* installed by @property */ }\r\n @property({ default: { x: 0, y: 0 }, tween: lerpVector2 })\r\n declare readonly offset: Vector2;\r\n\r\n constructor(props: NodeConfig<GridPattern, GridPatternProps>) {\r\n super(props);\r\n\r\n if (props.subStroke === undefined && props.stroke !== undefined && this.subdivisions > 1) {\r\n this.set({ subStroke: dimStroke(this.stroke as StrokeResolved[], 0.5) });\r\n }\r\n }\r\n\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n for (const stroke of this.subStroke) assets.fill(stroke.fill);\r\n }\r\n\r\n protected renderPattern(draw: RenderContext2D, bounds: BoxBounds): void {\r\n const halfW = bounds.width / 2;\r\n const halfH = bounds.height / 2;\r\n // `bounds` is centred on (x, y) in y-up world space: descriptor coordinates are y-up\r\n // and the renderer applies the single flip.\r\n const left = bounds.x - halfW;\r\n const right = bounds.x + halfW;\r\n const top = bounds.y - halfH;\r\n const bottom = bounds.y + halfH;\r\n\r\n draw.draw(new Graphics2D()\r\n .rect({ x: bounds.x, y: bounds.y, width: bounds.width, height: bounds.height, start: this.start, end: this.end })\r\n .shadow(this.shadow)\r\n .fill(this.fill));\r\n\r\n const subdivisions = Math.max(1, Math.floor(this.subdivisions));\r\n const cell = this.cellSize;\r\n const cellX = Math.max(1e-3, typeof cell === \"number\" ? cell : cell.x);\r\n const cellY = Math.max(1e-3, typeof cell === \"number\" ? cell : cell.y);\r\n const stepX = cellX / subdivisions;\r\n const stepY = cellY / subdivisions;\r\n\r\n const major = centered(this.stroke as StrokeResolved[]);\r\n const minorStroke = centered(this.subStroke as StrokeResolved[]);\r\n const overscan = Math.max(maxWeight(major), maxWeight(minorStroke)) / 2;\r\n\r\n const xAxis: GridAxis = { min: left, max: right, step: stepX, offset: this.offset.x };\r\n const yAxis: GridAxis = { min: top, max: bottom, step: stepY, offset: this.offset.y };\r\n\r\n // Minor lines first so the major lines sit on top.\r\n if (subdivisions > 1 && minorStroke.length > 0) {\r\n this._drawGroup(draw, xAxis, yAxis, subdivisions, overscan, minorStroke, false);\r\n }\r\n if (major.length > 0) {\r\n this._drawGroup(draw, xAxis, yAxis, subdivisions, overscan, major, true);\r\n }\r\n }\r\n\r\n // A solid stroke paints the group as one union path. A dashed one draws each line on\r\n // its own with its dash phase anchored to the line's world coordinate, so dashes never\r\n // crawl as the camera pans or new lines scroll in.\r\n private _drawGroup(\r\n draw: RenderContext2D,\r\n xAxis: GridAxis,\r\n yAxis: GridAxis,\r\n subdivisions: number,\r\n overscan: number,\r\n stroke: StrokeResolved[],\r\n isMajor: boolean,\r\n ): void {\r\n // Each line spans a whole number of dash cycles, so the renderer's per-path dash-fit\r\n // is a no-op and every line dashes identically.\r\n const cycle = dashCycle(stroke);\r\n const g = gridLines(xAxis, yAxis, subdivisions, overscan, cycle);\r\n const verticals = isMajor ? g.verticalMajor : g.verticalMinor;\r\n const horizontals = isMajor ? g.horizontalMajor : g.horizontalMinor;\r\n\r\n // Symmetric centerBounds give a zero recentre offset, so local coordinates draw verbatim.\r\n const centerBounds = [-1, -1, 1, 1] as const;\r\n\r\n if (cycle <= 0) {\r\n const data: PathCommand[] = [];\r\n for (const px of verticals) data.push({ type: \"M\", x: px, y: g.top }, { type: \"L\", x: px, y: g.bottom });\r\n for (const py of horizontals) data.push({ type: \"M\", x: g.left, y: py }, { type: \"L\", x: g.right, y: py });\r\n if (data.length > 0) draw.draw(new Graphics2D().path({ data, centerBounds }).stroke(stroke));\r\n return;\r\n }\r\n\r\n for (const px of verticals) {\r\n const data: PathCommand[] = [{ type: \"M\", x: px, y: g.top }, { type: \"L\", x: px, y: g.bottom }];\r\n draw.draw(new Graphics2D().path({ data, centerBounds }).stroke(phaseShift(stroke, g.top)));\r\n }\r\n for (const py of horizontals) {\r\n const data: PathCommand[] = [{ type: \"M\", x: g.left, y: py }, { type: \"L\", x: g.right, y: py }];\r\n draw.draw(new Graphics2D().path({ data, centerBounds }).stroke(phaseShift(stroke, g.left)));\r\n }\r\n }\r\n}\r\n\r\n// The largest dash-array sum across the layers, or 0 when none is dashed.\r\nfunction dashCycle(strokes: StrokeResolved[]): number {\r\n let cycle = 0;\r\n for (const s of strokes) {\r\n if (s.dash && s.dash.length > 0) {\r\n const sum = s.dash.reduce((a, b) => a + b, 0);\r\n if (sum > cycle) cycle = sum;\r\n }\r\n }\r\n return cycle;\r\n}\r\n\r\n// `dashOffset` advances the pattern, so it is negated to put the \"on\" run at the phase one\r\n// infinite line would have at this world coordinate.\r\nfunction phaseShift(strokes: StrokeResolved[], worldStart: number): StrokeResolved[] {\r\n return strokes.map(s => (s.dash && s.dash.length > 0)\r\n ? { ...s, dashOffset: (s.dashOffset ?? 0) - worldStart }\r\n : s);\r\n}\r\n\r\n// A number and a vector tween by promoting the number to a uniform vector.\r\nfunction lerpCellSize(from: number | Vector2, to: number | Vector2, t: number): number | Vector2 {\r\n if (typeof from === \"number\" && typeof to === \"number\") return lerpNumber(from, to, t);\r\n const a = typeof from === \"number\" ? { x: from, y: from } : from;\r\n const b = typeof to === \"number\" ? { x: to, y: to } : to;\r\n return lerpVector2(a, b, t);\r\n}\r\n", "import { DotGridPattern } from \"./dot-grid-pattern\"\r\nimport { GridPattern } from \"./grid-pattern\"\r\nimport { LineGridPattern } from \"./line-grid-pattern\"\r\n\r\n/**\r\n * Every node type this package publishes.\r\n *\r\n * A host registers these by handing the array to an engine —\r\n * `new Engine(platform, { nodes: NODES })` — which reads each class's `@node()`\r\n * key. Listing class **values** is also what survives bundling: this package\r\n * declares `sideEffects: false`, and a document names a node type by string, so\r\n * an import kept only for its side effect is exactly what gets shaken out.\r\n */\r\nexport const NODES = [LineGridPattern, DotGridPattern, GridPattern]\r\n"],
5
+ "mappings": "yFAAA,OACI,QAAAA,EACA,cAAAC,EACA,aAAAC,EACA,eAAAC,EACA,QAAAC,EACA,YAAAC,EACA,kBAAAC,MAUG,8VAsBMC,EAAN,cAA8BC,CAA+B,CAMhE,IAAI,WAAS,CAA0C,CAC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Node", "lerpVector2", "node", "property", "strokeProperty", "LineGridPattern", "ShapeNode", "value", "props", "dimStroke", "assets", "stroke", "draw", "width", "height", "centerBounds", "Graphics2D", "divisions", "subdivisions", "major", "centered", "minorStroke", "overscan", "maxWeight", "majorLines", "minorLines", "Clip", "cols", "innerW", "innerH", "insetX", "insetY", "gridLinePaths", "__decorate", "property", "strokeProperty", "lerpVector2", "node", "Clip", "Graphics2D", "ShapeNode", "lerpVector2", "node", "property", "gridPositions", "min", "max", "step", "offset", "subdivisions", "overscan", "out", "addTiledLines", "pos", "isMajor", "DotGridPattern", "ShapeNode", "bounds", "width", "height", "divisions", "major", "minor", "cols", "insetX", "insetY", "xs", "ys", "dots", "Graphics2D", "drew", "column", "row", "size", "Clip", "__decorate", "property", "lerpVector2", "node", "Graphics2D", "lerpNumber", "lerpVector2", "node", "property", "strokeProperty", "GridPattern", "ViewportPattern", "value", "props", "dimStroke", "assets", "stroke", "draw", "bounds", "halfW", "halfH", "left", "right", "top", "bottom", "Graphics2D", "subdivisions", "cell", "cellX", "cellY", "stepX", "stepY", "major", "centered", "minorStroke", "overscan", "maxWeight", "xAxis", "yAxis", "isMajor", "cycle", "dashCycle", "g", "gridLines", "verticals", "horizontals", "centerBounds", "data", "px", "py", "phaseShift", "__decorate", "property", "lerpCellSize", "strokeProperty", "lerpVector2", "node", "dashCycle", "strokes", "cycle", "s", "sum", "a", "b", "phaseShift", "worldStart", "lerpCellSize", "from", "to", "t", "lerpNumber", "lerpVector2", "NODES", "LineGridPattern", "DotGridPattern", "GridPattern"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{a,b,c,d,e,f,g}from"./chunks/chunk-EZEE76AY.js";export{g as ViewportPattern,c as addTiledLines,e as centered,f as dimStroke,b as gridLinePaths,a as gridLines,d as maxWeight};
2
+ //# sourceMappingURL=kit.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@motionscript/patterns",
3
+ "version": "0.1.0-alpha.4",
4
+ "exports": {
5
+ ".": "dist/browser/index.js",
6
+ "./kit": "dist/browser/kit.js"
7
+ },
8
+ "peers": [
9
+ "@motionscript/sdk"
10
+ ],
11
+ "assets": {},
12
+ "thirdParty": []
13
+ }
@@ -0,0 +1,41 @@
1
+ import { Clip, Graphics2D, ShapeNode, type ShapeProps, type Vector2 } from "@motionscript/sdk";
2
+ export interface DotGridPatternProps extends ShapeProps {
3
+ /** Cells along each axis, as in `LineGridPattern.divisions`: 4 puts 5 major dots on each axis. */
4
+ divisions: number;
5
+ /** Splits each division again. `1` draws only the major dots; `2` puts one minor dot between each pair. */
6
+ subdivisions: number;
7
+ /** Radius of a major dot. */
8
+ radius: number;
9
+ /**
10
+ * A minor dot's radius as a fraction of a major one's. A fraction rather than a
11
+ * second paint stack, so the whole field stays one fill and a gradient crosses
12
+ * every dot in it.
13
+ */
14
+ subScale: number;
15
+ /** Pans the field, as `LineGridPattern.offset` does, so the two stay aligned while both scroll. */
16
+ offset: Vector2;
17
+ }
18
+ /**
19
+ * A field of dots on the same `divisions` / `subdivisions` / `offset` as
20
+ * {@link LineGridPattern}, so laid over one the dots sit on its intersections.
21
+ *
22
+ * The silhouette is the dots (see {@link DotGridPattern.shapeGraphics}), so
23
+ * `ShapeNode` paints `shadow`, `fill`, `overlay` and `stroke` with no render code
24
+ * here. A dot grid has no "paper": a rectangle behind it is how it gets a
25
+ * background.
26
+ *
27
+ * `clipSelf` is the node's box rather than the silhouette, which clips outer dots
28
+ * as they pan out and keeps the node selectable between dots. `start` / `end` act
29
+ * on nothing: trimming a disc leaves a crescent, not a partial grid.
30
+ */
31
+ export declare class DotGridPattern extends ShapeNode<DotGridPatternProps> {
32
+ readonly divisions: number;
33
+ readonly subdivisions: number;
34
+ readonly radius: number;
35
+ readonly subScale: number;
36
+ readonly offset: Vector2;
37
+ /** Every dot in the field as one un-painted union: the paint stacks belong to the grid, not to a dot. */
38
+ protected shapeGraphics(): Graphics2D | null;
39
+ protected clipSelf(): Clip;
40
+ }
41
+ //# sourceMappingURL=dot-grid-pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dot-grid-pattern.d.ts","sourceRoot":"","sources":["../../src/dot-grid-pattern/dot-grid-pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,UAAU,EACV,SAAS,EAIT,KAAK,UAAU,EACf,KAAK,OAAO,EACb,MAAM,mBAAmB,CAAA;AA2B1B,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,kGAAkG;IAClG,SAAS,EAAE,MAAM,CAAA;IACjB,2GAA2G;IAC3G,YAAY,EAAE,MAAM,CAAA;IACpB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,mGAAmG;IACnG,MAAM,EAAE,OAAO,CAAA;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,qBACa,cAAe,SAAQ,SAAS,CAAC,mBAAmB,CAAC;IAChE,SAA2C,SAAS,EAAE,MAAM,CAAA;IAC5D,SAA2C,YAAY,EAAE,MAAM,CAAA;IAC/D,SAA2C,MAAM,EAAE,MAAM,CAAA;IACzD,SAA6C,QAAQ,EAAE,MAAM,CAAA;IAC7D,SACiB,MAAM,EAAE,OAAO,CAAA;IAEhC,yGAAyG;cACtF,aAAa,IAAI,UAAU,GAAG,IAAI;cAgDlC,QAAQ,IAAI,IAAI;CAOpC"}