@lewismoten/gamemaker-sandbox-tools 0.0.0-stage → 3.4.0

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 (252) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE +24 -0
  3. package/NOTICE.md +121 -0
  4. package/README.md +362 -2
  5. package/dist/audio-files.js +82 -0
  6. package/dist/audio.js +25 -0
  7. package/dist/block-merge.js +43 -0
  8. package/dist/color-reduce.js +44 -0
  9. package/dist/colors.js +87 -0
  10. package/dist/delta.js +75 -0
  11. package/dist/disk-diff.js +220 -0
  12. package/dist/drawing.js +85 -0
  13. package/dist/embroidery/compile.js +85 -0
  14. package/dist/embroidery/dst.js +79 -0
  15. package/dist/embroidery/exp.js +26 -0
  16. package/dist/embroidery/fill.js +49 -0
  17. package/dist/embroidery/geom.js +82 -0
  18. package/dist/embroidery/pes.js +79 -0
  19. package/dist/embroidery/satin.js +29 -0
  20. package/dist/embroidery/simulate.js +30 -0
  21. package/dist/embroidery/strokeFont.js +253 -0
  22. package/dist/embroidery/svg.js +24 -0
  23. package/dist/embroidery/types.js +13 -0
  24. package/dist/embroidery/units.js +26 -0
  25. package/dist/embroidery/validate.js +15 -0
  26. package/dist/formats/blocks.js +1 -0
  27. package/dist/formats/character.js +1 -0
  28. package/dist/formats/cmf.js +1 -0
  29. package/dist/formats/fli.js +1 -0
  30. package/dist/formats/fliLimits.js +1 -0
  31. package/dist/formats/game.js +1 -0
  32. package/dist/formats/gif.js +1 -0
  33. package/dist/formats/graphicScripts.js +1 -0
  34. package/dist/formats/map.js +1 -0
  35. package/dist/formats/monster.js +1 -0
  36. package/dist/formats/palette.js +1 -0
  37. package/dist/formats/recording.js +1 -0
  38. package/dist/formats/sound.js +1 -0
  39. package/dist/formats/voc.js +1 -0
  40. package/dist/gif-shrink.js +56 -0
  41. package/dist/image/png.js +42 -0
  42. package/dist/images.js +88 -0
  43. package/dist/kit/actors.js +19 -0
  44. package/dist/kit/align.js +204 -0
  45. package/dist/kit/blit.js +45 -0
  46. package/dist/kit/blockRoles.js +97 -0
  47. package/dist/kit/clips.js +40 -0
  48. package/dist/kit/coverPaint.js +18 -0
  49. package/dist/kit/disk.js +76 -0
  50. package/dist/kit/fadeOut.js +13 -0
  51. package/dist/kit/fliClips.js +133 -0
  52. package/dist/kit/fliShrink.js +277 -0
  53. package/dist/kit/gameSim.js +235 -0
  54. package/dist/kit/hopBot.js +142 -0
  55. package/dist/kit/levelGen.js +1423 -0
  56. package/dist/kit/levelGrid.js +33 -0
  57. package/dist/kit/levelPicture.js +27 -0
  58. package/dist/kit/menuVersion.js +19 -0
  59. package/dist/kit/microText.js +35 -0
  60. package/dist/kit/mumble.js +74 -0
  61. package/dist/kit/music.js +8 -0
  62. package/dist/kit/palRamps.js +32 -0
  63. package/dist/kit/palette.js +49 -0
  64. package/dist/kit/pcText.js +72 -0
  65. package/dist/kit/photo.js +150 -0
  66. package/dist/kit/pixels.js +79 -0
  67. package/dist/kit/png.js +40 -0
  68. package/dist/kit/quantize.js +72 -0
  69. package/dist/kit/raytrace.js +379 -0
  70. package/dist/kit/recordedDemo.js +10 -0
  71. package/dist/kit/reel.js +77 -0
  72. package/dist/kit/road3d.js +67 -0
  73. package/dist/kit/routeChecks.js +8 -0
  74. package/dist/kit/saveSlots.js +11 -0
  75. package/dist/kit/sceneInit.js +13 -0
  76. package/dist/kit/sceneSim.js +112 -0
  77. package/dist/kit/screenText.js +15 -0
  78. package/dist/kit/sdftext.js +237 -0
  79. package/dist/kit/shading.js +69 -0
  80. package/dist/kit/song.js +251 -0
  81. package/dist/kit/songFx.js +179 -0
  82. package/dist/kit/sound.js +52 -0
  83. package/dist/kit/synthParts.js +20 -0
  84. package/dist/kit/tar.js +53 -0
  85. package/dist/kit/textBounds.js +84 -0
  86. package/dist/kit/textfit.js +246 -0
  87. package/dist/kit/transforms.js +57 -0
  88. package/dist/kit/tune.js +21 -0
  89. package/dist/look-alike.js +50 -0
  90. package/dist/menu-version.js +4 -0
  91. package/dist/mesh/colorBodies.js +137 -0
  92. package/dist/mesh/decimate.js +207 -0
  93. package/dist/mesh/meshCheck.js +51 -0
  94. package/dist/mesh/overhang.js +41 -0
  95. package/dist/mesh/sampledField.js +12 -0
  96. package/dist/mesh/stl.js +36 -0
  97. package/dist/mesh/surfaceNets.js +79 -0
  98. package/dist/mesh/tetraMesh.js +62 -0
  99. package/dist/mesh/threeMf.js +58 -0
  100. package/dist/mesh/zipFile.js +52 -0
  101. package/dist/microFont.js +101 -0
  102. package/dist/music/compose.js +72 -0
  103. package/dist/pack/meshPack.js +198 -0
  104. package/dist/pack/threeMfPack.js +92 -0
  105. package/dist/palette-reserve.js +116 -0
  106. package/dist/palettes.js +138 -0
  107. package/dist/release-notes.js +40 -0
  108. package/dist/simulation.js +18 -0
  109. package/dist/text.js +74 -0
  110. package/dist/types/audio.d.ts +4 -0
  111. package/dist/types/audioFiles.d.ts +22 -0
  112. package/dist/types/audioWav.d.ts +4 -0
  113. package/dist/types/blockMerge.d.ts +24 -0
  114. package/dist/types/colorReduce.d.ts +23 -0
  115. package/dist/types/colors.d.ts +26 -0
  116. package/dist/types/delta.d.ts +32 -0
  117. package/dist/types/diskDiff.d.ts +47 -0
  118. package/dist/types/drawing.d.ts +15 -0
  119. package/dist/types/embroidery/compile.d.ts +3 -0
  120. package/dist/types/embroidery/dst.d.ts +13 -0
  121. package/dist/types/embroidery/exp.d.ts +8 -0
  122. package/dist/types/embroidery/fill.d.ts +6 -0
  123. package/dist/types/embroidery/geom.d.ts +19 -0
  124. package/dist/types/embroidery/pes.d.ts +10 -0
  125. package/dist/types/embroidery/satin.d.ts +11 -0
  126. package/dist/types/embroidery/simulate.d.ts +19 -0
  127. package/dist/types/embroidery/strokeFont.d.ts +20 -0
  128. package/dist/types/embroidery/svg.d.ts +3 -0
  129. package/dist/types/embroidery/types.d.ts +70 -0
  130. package/dist/types/embroidery/units.d.ts +10 -0
  131. package/dist/types/embroidery/validate.d.ts +22 -0
  132. package/dist/types/formats/blocks.d.ts +1 -0
  133. package/dist/types/formats/character.d.ts +1 -0
  134. package/dist/types/formats/cmf.d.ts +1 -0
  135. package/dist/types/formats/fli.d.ts +1 -0
  136. package/dist/types/formats/fliLimits.d.ts +1 -0
  137. package/dist/types/formats/game.d.ts +1 -0
  138. package/dist/types/formats/gif.d.ts +1 -0
  139. package/dist/types/formats/graphicScripts.d.ts +1 -0
  140. package/dist/types/formats/map.d.ts +1 -0
  141. package/dist/types/formats/monster.d.ts +1 -0
  142. package/dist/types/formats/palette.d.ts +1 -0
  143. package/dist/types/formats/recording.d.ts +1 -0
  144. package/dist/types/formats/sound.d.ts +1 -0
  145. package/dist/types/formats/voc.d.ts +1 -0
  146. package/dist/types/gifShrink.d.ts +8 -0
  147. package/dist/types/image/animatedGif.d.ts +9 -0
  148. package/dist/types/image/png.d.ts +10 -0
  149. package/dist/types/image/surface.d.ts +26 -0
  150. package/dist/types/images.d.ts +13 -0
  151. package/dist/types/kit/actors.d.ts +7 -0
  152. package/dist/types/kit/align.d.ts +93 -0
  153. package/dist/types/kit/audioEvents.d.ts +26 -0
  154. package/dist/types/kit/blit.d.ts +20 -0
  155. package/dist/types/kit/blockRoles.d.ts +243 -0
  156. package/dist/types/kit/clips.d.ts +36 -0
  157. package/dist/types/kit/coverPaint.d.ts +7 -0
  158. package/dist/types/kit/disk.d.ts +15 -0
  159. package/dist/types/kit/fadeOut.d.ts +12 -0
  160. package/dist/types/kit/fliClips.d.ts +32 -0
  161. package/dist/types/kit/fliShrink.d.ts +149 -0
  162. package/dist/types/kit/gameSim.d.ts +112 -0
  163. package/dist/types/kit/hopBot.d.ts +72 -0
  164. package/dist/types/kit/laserClearance.d.ts +16 -0
  165. package/dist/types/kit/laserJoints.d.ts +39 -0
  166. package/dist/types/kit/laserLayout.d.ts +54 -0
  167. package/dist/types/kit/laserPixels.d.ts +52 -0
  168. package/dist/types/kit/laserPreview.d.ts +9 -0
  169. package/dist/types/kit/laserSvg.d.ts +35 -0
  170. package/dist/types/kit/levelGen/castle.d.ts +17 -0
  171. package/dist/types/kit/levelGen/dungeon.d.ts +11 -0
  172. package/dist/types/kit/levelGen/forest.d.ts +17 -0
  173. package/dist/types/kit/levelGen/furnish.d.ts +31 -0
  174. package/dist/types/kit/levelGen/grid.d.ts +46 -0
  175. package/dist/types/kit/levelGen/index.d.ts +138 -0
  176. package/dist/types/kit/levelGen/interior.d.ts +18 -0
  177. package/dist/types/kit/levelGen/jumpModel.d.ts +78 -0
  178. package/dist/types/kit/levelGen/needs.d.ts +44 -0
  179. package/dist/types/kit/levelGen/overworld.d.ts +21 -0
  180. package/dist/types/kit/levelGen/platform.d.ts +59 -0
  181. package/dist/types/kit/levelGen/platformCap.d.ts +13 -0
  182. package/dist/types/kit/levelGen/platformReach.d.ts +37 -0
  183. package/dist/types/kit/levelGen/props.d.ts +37 -0
  184. package/dist/types/kit/levelGen/town.d.ts +24 -0
  185. package/dist/types/kit/levelGrid.d.ts +16 -0
  186. package/dist/types/kit/levelPicture.d.ts +9 -0
  187. package/dist/types/kit/menuVersion.d.ts +7 -0
  188. package/dist/types/kit/microText.d.ts +18 -0
  189. package/dist/types/kit/mumble.d.ts +41 -0
  190. package/dist/types/kit/music.d.ts +1 -0
  191. package/dist/types/kit/palMerge.d.ts +10 -0
  192. package/dist/types/kit/palRamps.d.ts +28 -0
  193. package/dist/types/kit/palette.d.ts +16 -0
  194. package/dist/types/kit/pcText.d.ts +19 -0
  195. package/dist/types/kit/photo.d.ts +69 -0
  196. package/dist/types/kit/pixels.d.ts +26 -0
  197. package/dist/types/kit/png.d.ts +7 -0
  198. package/dist/types/kit/quantize.d.ts +20 -0
  199. package/dist/types/kit/raytrace.d.ts +169 -0
  200. package/dist/types/kit/recordedDemo.d.ts +1 -0
  201. package/dist/types/kit/reel.d.ts +34 -0
  202. package/dist/types/kit/road3d.d.ts +71 -0
  203. package/dist/types/kit/routeChecks.d.ts +6 -0
  204. package/dist/types/kit/saveSlots.d.ts +17 -0
  205. package/dist/types/kit/sceneInit.d.ts +11 -0
  206. package/dist/types/kit/sceneSim.d.ts +84 -0
  207. package/dist/types/kit/screenText.d.ts +3 -0
  208. package/dist/types/kit/sdftext.d.ts +34 -0
  209. package/dist/types/kit/shading.d.ts +23 -0
  210. package/dist/types/kit/shareBlocks.d.ts +20 -0
  211. package/dist/types/kit/song.d.ts +89 -0
  212. package/dist/types/kit/songFx.d.ts +99 -0
  213. package/dist/types/kit/sound.d.ts +29 -0
  214. package/dist/types/kit/synthParts.d.ts +7 -0
  215. package/dist/types/kit/tar.d.ts +13 -0
  216. package/dist/types/kit/textBounds.d.ts +51 -0
  217. package/dist/types/kit/textfit.d.ts +74 -0
  218. package/dist/types/kit/transforms.d.ts +8 -0
  219. package/dist/types/kit/tune.d.ts +6 -0
  220. package/dist/types/lookAlike.d.ts +31 -0
  221. package/dist/types/menuVersionEntry.d.ts +1 -0
  222. package/dist/types/mesh/colorBodies.d.ts +18 -0
  223. package/dist/types/mesh/decimate.d.ts +10 -0
  224. package/dist/types/mesh/fieldTrinket.d.ts +40 -0
  225. package/dist/types/mesh/figureShapes.d.ts +24 -0
  226. package/dist/types/mesh/mesh.d.ts +9 -0
  227. package/dist/types/mesh/meshCheck.d.ts +22 -0
  228. package/dist/types/mesh/overhang.d.ts +24 -0
  229. package/dist/types/mesh/pixelFigure.d.ts +41 -0
  230. package/dist/types/mesh/sampledField.d.ts +3 -0
  231. package/dist/types/mesh/sdfShapes.d.ts +20 -0
  232. package/dist/types/mesh/stl.d.ts +9 -0
  233. package/dist/types/mesh/strokeText.d.ts +8 -0
  234. package/dist/types/mesh/surfaceNets.d.ts +14 -0
  235. package/dist/types/mesh/tetraMesh.d.ts +4 -0
  236. package/dist/types/mesh/threeMf.d.ts +12 -0
  237. package/dist/types/mesh/trinketKinds.d.ts +72 -0
  238. package/dist/types/mesh/trinketTool.d.ts +26 -0
  239. package/dist/types/mesh/voxel.d.ts +10 -0
  240. package/dist/types/mesh/zipFile.d.ts +13 -0
  241. package/dist/types/microFont.d.ts +6 -0
  242. package/dist/types/music/compose.d.ts +51 -0
  243. package/dist/types/pack/meshPack.d.ts +26 -0
  244. package/dist/types/pack/threeMfPack.d.ts +11 -0
  245. package/dist/types/palettePresetData.d.ts +4 -0
  246. package/dist/types/palettePresets.d.ts +12 -0
  247. package/dist/types/paletteReserve.d.ts +52 -0
  248. package/dist/types/palettes.d.ts +4 -0
  249. package/dist/types/releaseNotes.d.ts +3 -0
  250. package/dist/types/simulation.d.ts +6 -0
  251. package/dist/types/text.d.ts +41 -0
  252. package/package.json +190 -4
@@ -0,0 +1,253 @@
1
+ import { arc as e, resample as M } from "./geom.js";
2
+ const s = Math.PI, P = {
3
+ A: {
4
+ w: 5.5,
5
+ strokes: [
6
+ [
7
+ [0, 0],
8
+ [2.75, 8],
9
+ [5.5, 0]
10
+ ],
11
+ [
12
+ [1, 2.8],
13
+ [4.5, 2.8]
14
+ ]
15
+ ]
16
+ },
17
+ B: {
18
+ w: 5,
19
+ strokes: [
20
+ [[0, 0], [0, 8], [3, 8], ...e(3, 6, 1.8, 2, s / 2, -s / 2, 8), [3, 4], [0, 4]],
21
+ [[3, 4], ...e(3, 2, 2, 2, s / 2, -s / 2, 8), [0, 0]]
22
+ ]
23
+ },
24
+ C: { w: 5.2, strokes: [e(2.6, 4, 2.6, 4, 0.25 * s, 1.75 * s, 20)] },
25
+ D: { w: 5, strokes: [[[0, 0], [0, 8], [2, 8], ...e(2, 4, 3, 4, s / 2, -s / 2, 12), [0, 0]]] },
26
+ E: {
27
+ w: 4.5,
28
+ strokes: [
29
+ [
30
+ [4.5, 8],
31
+ [0, 8],
32
+ [0, 0],
33
+ [4.5, 0]
34
+ ],
35
+ [
36
+ [0, 4],
37
+ [3.6, 4]
38
+ ]
39
+ ]
40
+ },
41
+ F: {
42
+ w: 4.5,
43
+ strokes: [
44
+ [
45
+ [4.5, 8],
46
+ [0, 8],
47
+ [0, 0]
48
+ ],
49
+ [
50
+ [0, 4],
51
+ [3.6, 4]
52
+ ]
53
+ ]
54
+ },
55
+ G: { w: 5.2, strokes: [[...e(2.6, 4, 2.6, 4, 0.25 * s, 1.75 * s, 20), [5.2, 3.6], [2.8, 3.6]]] },
56
+ H: {
57
+ w: 5,
58
+ strokes: [
59
+ [
60
+ [0, 8],
61
+ [0, 0]
62
+ ],
63
+ [
64
+ [5, 8],
65
+ [5, 0]
66
+ ],
67
+ [
68
+ [0, 4],
69
+ [5, 4]
70
+ ]
71
+ ]
72
+ },
73
+ I: {
74
+ w: 1,
75
+ strokes: [
76
+ [
77
+ [0.5, 8],
78
+ [0.5, 0]
79
+ ]
80
+ ]
81
+ },
82
+ J: { w: 4, strokes: [[[4, 8], [4, 2.5], ...e(2, 2.5, 2, 2.5, 0, -s, 8)]] },
83
+ K: {
84
+ w: 5,
85
+ strokes: [
86
+ [
87
+ [0, 8],
88
+ [0, 0]
89
+ ],
90
+ [
91
+ [5, 8],
92
+ [0, 3.4]
93
+ ],
94
+ [
95
+ [1.6, 4.6],
96
+ [5, 0]
97
+ ]
98
+ ]
99
+ },
100
+ L: {
101
+ w: 4.5,
102
+ strokes: [
103
+ [
104
+ [0, 8],
105
+ [0, 0],
106
+ [4.5, 0]
107
+ ]
108
+ ]
109
+ },
110
+ M: {
111
+ w: 6.5,
112
+ strokes: [
113
+ [
114
+ [0, 0],
115
+ [0, 8],
116
+ [3.25, 2.6],
117
+ [6.5, 8],
118
+ [6.5, 0]
119
+ ]
120
+ ]
121
+ },
122
+ N: {
123
+ w: 5,
124
+ strokes: [
125
+ [
126
+ [0, 0],
127
+ [0, 8],
128
+ [5, 0],
129
+ [5, 8]
130
+ ]
131
+ ]
132
+ },
133
+ O: { w: 5.4, strokes: [e(2.7, 4, 2.7, 4, s / 2, s / 2 + 2 * s, 28)] },
134
+ P: { w: 5, strokes: [[[0, 0], [0, 8], [2.8, 8], ...e(2.8, 5.8, 2.2, 2.2, s / 2, -s / 2, 10), [0, 3.6]]] },
135
+ Q: {
136
+ w: 5.4,
137
+ strokes: [
138
+ e(2.7, 4, 2.7, 4, s / 2, s / 2 + 2 * s, 28),
139
+ [
140
+ [3.2, 2.4],
141
+ [5.4, 0]
142
+ ]
143
+ ]
144
+ },
145
+ R: {
146
+ w: 5,
147
+ strokes: [
148
+ [[0, 0], [0, 8], [2.8, 8], ...e(2.8, 5.9, 2.2, 2.1, s / 2, -s / 2, 10), [0, 3.8]],
149
+ [
150
+ [2.2, 3.8],
151
+ [5, 0]
152
+ ]
153
+ ]
154
+ },
155
+ S: { w: 5, strokes: [[...e(2.5, 6, 2.4, 2, 0.2 * s, 1.5 * s, 12), ...e(2.5, 2, 2.4, 2, 0.5 * s, -0.85 * s, 12).slice(1)]] },
156
+ T: {
157
+ w: 5,
158
+ strokes: [
159
+ [
160
+ [0, 8],
161
+ [5, 8]
162
+ ],
163
+ [
164
+ [2.5, 8],
165
+ [2.5, 0]
166
+ ]
167
+ ]
168
+ },
169
+ U: { w: 5, strokes: [[[0, 8], [0, 2.6], ...e(2.5, 2.6, 2.5, 2.6, s, 2 * s, 12), [5, 8]]] },
170
+ V: {
171
+ w: 5.5,
172
+ strokes: [
173
+ [
174
+ [0, 8],
175
+ [2.75, 0],
176
+ [5.5, 8]
177
+ ]
178
+ ]
179
+ },
180
+ W: {
181
+ w: 7.5,
182
+ strokes: [
183
+ [
184
+ [0, 8],
185
+ [1.9, 0],
186
+ [3.75, 6],
187
+ [5.6, 0],
188
+ [7.5, 8]
189
+ ]
190
+ ]
191
+ },
192
+ X: {
193
+ w: 5.2,
194
+ strokes: [
195
+ [
196
+ [0, 8],
197
+ [5.2, 0]
198
+ ],
199
+ [
200
+ [0, 0],
201
+ [5.2, 8]
202
+ ]
203
+ ]
204
+ },
205
+ Y: {
206
+ w: 5.2,
207
+ strokes: [
208
+ [
209
+ [0, 8],
210
+ [2.6, 4]
211
+ ],
212
+ [
213
+ [5.2, 8],
214
+ [2.6, 4],
215
+ [2.6, 0]
216
+ ]
217
+ ]
218
+ },
219
+ Z: {
220
+ w: 5,
221
+ strokes: [
222
+ [
223
+ [0, 8],
224
+ [5, 8],
225
+ [0, 0],
226
+ [5, 0]
227
+ ]
228
+ ]
229
+ },
230
+ " ": { w: 3, strokes: [] }
231
+ };
232
+ function y(m, t) {
233
+ const k = t.height / 8, w = k * (t.stretch ?? 1), n = [...m.toUpperCase()].map((r) => {
234
+ const o = P[r];
235
+ if (!o) throw new Error(`no stroke glyph for "${r}"`);
236
+ return o;
237
+ }), x = n.reduce((r, o) => r + o.w * w, 0) + t.gap * (n.length - 1), a = t.baseline + (t.side === "top" ? t.height / 2 : -t.height / 2), c = t.side === "top", h = t.center ?? (c ? s / 2 : -s / 2), p = [];
238
+ let i = -x / 2;
239
+ for (const r of n) {
240
+ for (const o of r.strokes)
241
+ p.push(
242
+ M(o, 0.8).map(([d, g]) => {
243
+ const l = i + d * w, f = c ? t.baseline + g * k : t.baseline - g * k, u = c ? h - l / a : h + l / a;
244
+ return [t.cx + f * Math.cos(u), t.cy + f * Math.sin(u)];
245
+ })
246
+ );
247
+ i += r.w * w + t.gap;
248
+ }
249
+ return p;
250
+ }
251
+ export {
252
+ y as arcText
253
+ };
@@ -0,0 +1,24 @@
1
+ const a = (n) => `#${n.map((t) => t.toString(16).padStart(2, "0")).join("")}`, i = (n) => (Math.round(n * 100) / 100).toString(), d = (n, t) => `M${n.map((r) => `${i(r[0])} ${i(-r[1])}`).join("L")}${t ? "Z" : ""}`;
2
+ function p(n, t, r = [214, 208, 196]) {
3
+ const e = t / 2, h = n.blocks.map(($) => {
4
+ const l = a($.thread.rgb), s = $.items.map((o) => {
5
+ if (o.kind === "fill") return `<path d="${o.polys.map((m) => d(m, !0)).join("")}" fill="${l}" fill-rule="evenodd"/>`;
6
+ const c = o.kind === "satin" ? o.width : 0.4;
7
+ return `<path d="${d(o.path, !!o.closed)}" fill="none" stroke="${l}" stroke-width="${i(c)}" stroke-linejoin="round" stroke-linecap="butt"/>`;
8
+ });
9
+ return `<g id="${$.thread.name.replace(/\W+/g, "-")}">
10
+ ${s.join(`
11
+ `)}
12
+ </g>`;
13
+ });
14
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${t}mm" height="${t}mm" viewBox="${-e} ${-e} ${t} ${t}">
15
+ <title>${n.name}</title>
16
+ <rect x="${-e}" y="${-e}" width="${t}" height="${t}" fill="${a(r)}"/>
17
+ ${h.join(`
18
+ `)}
19
+ </svg>
20
+ `;
21
+ }
22
+ export {
23
+ p as designSvg
24
+ };
@@ -0,0 +1,13 @@
1
+ const l = {
2
+ fillSpacing: 0.4,
3
+ fillLength: 3.5,
4
+ satinDensity: 0.4,
5
+ pullComp: 0.3,
6
+ fillGrow: 0.15,
7
+ maxStitch: 7,
8
+ underlayRun: 2.5,
9
+ maxSatin: 7
10
+ };
11
+ export {
12
+ l as DEFAULTS
13
+ };
@@ -0,0 +1,26 @@
1
+ const l = 121;
2
+ function e(u, t = 121) {
3
+ const d = [];
4
+ let h = 0, o = 0;
5
+ for (const s of u.stitches) {
6
+ const r = Math.round(s.x * 10), a = Math.round(s.y * 10);
7
+ if (s.cmd === "color" || s.cmd === "end" || s.cmd === "trim") {
8
+ d.push({ dx: 0, dy: 0, cmd: s.cmd });
9
+ continue;
10
+ }
11
+ let c = r - h, n = a - o;
12
+ if (s.cmd === "jump")
13
+ for (; Math.abs(c) > t || Math.abs(n) > t; ) {
14
+ const i = Math.max(-t, Math.min(t, c)), m = Math.max(-t, Math.min(t, n));
15
+ d.push({ dx: i, dy: m, cmd: "jump" }), c -= i, n -= m;
16
+ }
17
+ else if (Math.abs(c) > t || Math.abs(n) > t)
18
+ throw new Error(`stitch of ${c / 10}, ${n / 10} mm is longer than the format allows`);
19
+ d.push({ dx: c, dy: n, cmd: s.cmd }), h = r, o = a;
20
+ }
21
+ return d;
22
+ }
23
+ export {
24
+ l as MAX_MOVE,
25
+ e as toRecords
26
+ };
@@ -0,0 +1,15 @@
1
+ function f(i, e) {
2
+ let r = 0, p = 0, s = 0, h = 0, c = 0;
3
+ const t = [0, 0, 0, 0];
4
+ let a = 0, x = 0;
5
+ for (const o of i) {
6
+ if (o.cmd === "color" && s++, o.cmd !== "stitch" && o.cmd !== "jump") continue;
7
+ const l = Math.max(Math.abs(o.x - a), Math.abs(o.y - x));
8
+ o.cmd === "stitch" ? (r++, h = Math.max(h, Math.hypot(o.x - a, o.y - x))) : p++, c = Math.max(c, l), t[0] = Math.min(t[0], o.x), t[1] = Math.min(t[1], o.y), t[2] = Math.max(t[2], o.x), t[3] = Math.max(t[3], o.y), a = o.x, x = o.y;
9
+ }
10
+ const m = [], d = t[2] - t[0], n = t[3] - t[1];
11
+ return (d > e.hoop[0] || n > e.hoop[1]) && m.push(`design ${d.toFixed(1)} x ${n.toFixed(1)} mm does not fit the ${e.hoop.join(" x ")} mm hoop`), s !== e.colors - 1 && m.push(`${s} color changes for ${e.colors} colors`), h > e.maxRecord + 1e-6 && m.push(`a stitch of ${h.toFixed(2)} mm is longer than ${e.maxRecord} mm`), c > e.maxRecord + 1e-6 && m.push(`a jump record of ${c.toFixed(2)} mm is longer than ${e.maxRecord} mm`), i[i.length - 1]?.cmd !== "end" && m.push("the data does not end with an end command"), { stitches: r, jumps: p, colorChanges: s, maxStitch: h, maxJump: c, extents: t, width: d, height: n, problems: m };
12
+ }
13
+ export {
14
+ f as validate
15
+ };
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/blocks";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/character";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/cmf";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/fli";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/fliLimits";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/game";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/gif";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/graphicScripts";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/map";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/monster";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/palette";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/recording";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/sound";
@@ -0,0 +1 @@
1
+ export * from "@lewismoten/gamemaker-sandbox-engine/formats/voc";
@@ -0,0 +1,56 @@
1
+ import { isGif as p, decodeGif as s, lzwEncode as d } from "@lewismoten/gamemaker-sandbox-engine/formats/gif";
2
+ function g(i) {
3
+ let t = 10;
4
+ const o = i[t];
5
+ t += 3;
6
+ let l;
7
+ for (o & 128 && (l = { count: 2 << (o & 7), at: t }, t += l.count * 3); ; ) {
8
+ const h = i[t++];
9
+ if (h === 33) {
10
+ for (t++; t < i.length && i[t] !== 0; ) t += i[t] + 1;
11
+ t++;
12
+ } else {
13
+ if (h === 44) break;
14
+ return;
15
+ }
16
+ }
17
+ t += 8;
18
+ const n = i[t++];
19
+ return n & 128 && (l = { count: 2 << (n & 7), at: t }), l;
20
+ }
21
+ function v(i) {
22
+ if (p(i))
23
+ try {
24
+ const t = g(i);
25
+ if (!t) return;
26
+ const o = s(i);
27
+ let l = 0;
28
+ for (const e of o.pixels) e > l && (l = e);
29
+ let n = 4;
30
+ for (; n <= l; ) n *= 2;
31
+ for (; n < t.count; n *= 2) {
32
+ let e = !0;
33
+ for (let r = n * 3; r < o.palette.length && e; r++) e = o.palette[r] === 0;
34
+ if (e) break;
35
+ }
36
+ if (n >= t.count) return;
37
+ const h = Math.log2(n), f = [71, 73, 70, 56, 55, 97, i[6], i[7], i[8], i[9], 240 | h - 1, 0, 0];
38
+ for (let e = 0; e < n * 3; e++) f.push(i[t.at + e] ?? 0);
39
+ f.push(44, 0, 0, 0, 0, o.width & 255, o.width >> 8, o.height & 255, o.height >> 8, 0, h);
40
+ const c = d(o.pixels, h);
41
+ for (let e = 0; e < c.length; e += 255) {
42
+ f.push(Math.min(255, c.length - e));
43
+ for (let r = e; r < Math.min(c.length, e + 255); r++) f.push(c[r]);
44
+ }
45
+ f.push(0, 59);
46
+ const a = Uint8Array.from(f);
47
+ if (a.length >= i.length) return;
48
+ const u = s(a);
49
+ return u.width !== o.width || u.height !== o.height || u.pixels.some((e, r) => e !== o.pixels[r]) || u.palette.some((e, r) => e !== o.palette[r]) ? void 0 : { bytes: a, from: t.count, to: n };
50
+ } catch {
51
+ return;
52
+ }
53
+ }
54
+ export {
55
+ v as shrinkGif
56
+ };
@@ -0,0 +1,42 @@
1
+ import { crc32 as m } from "@lewismoten/gamemaker-sandbox-archives/zip";
2
+ import { vga8 as A } from "@lewismoten/gamemaker-sandbox-engine/formats/palette";
3
+ async function p(e) {
4
+ const r = new Blob([e]).stream().pipeThrough(new CompressionStream("deflate"));
5
+ return new Uint8Array(await new Response(r).arrayBuffer());
6
+ }
7
+ function i(e, r) {
8
+ const t = new Uint8Array(12 + r.length), s = new DataView(t.buffer);
9
+ s.setUint32(0, r.length);
10
+ for (let o = 0; o < 4; o++) t[4 + o] = e.charCodeAt(o);
11
+ return t.set(r, 8), s.setUint32(8 + r.length, m(t.subarray(4, 8 + r.length)) >>> 0), t;
12
+ }
13
+ async function D(e, r = 1) {
14
+ const t = Math.max(1, Math.floor(r)), s = e.width * t, o = e.height * t, l = new Uint8Array((s + 1) * o);
15
+ for (let n = 0; n < o; n++) {
16
+ const c = n * (s + 1) | 0, U = Math.floor(n / t) * e.width;
17
+ for (let a = 0; a < s; a++) l[c + 1 + a] = e.pixels[U + Math.floor(a / t)];
18
+ }
19
+ const f = new Uint8Array(13), h = new DataView(f.buffer);
20
+ h.setUint32(0, s), h.setUint32(4, o), f.set([8, 3, 0, 0, 0], 8);
21
+ const w = new Uint8Array(768);
22
+ for (let n = 0; n < 768; n++) w[n] = A(e.palette[n] ?? 0);
23
+ const u = [
24
+ new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]),
25
+ i("IHDR", f),
26
+ i("PLTE", w),
27
+ i("IDAT", await p(l)),
28
+ i("IEND", new Uint8Array(0))
29
+ ], y = new Uint8Array(u.reduce((n, c) => n + c.length, 0));
30
+ let g = 0;
31
+ for (const n of u) y.set(n, g), g += n.length;
32
+ return y;
33
+ }
34
+ function x(e) {
35
+ let r = "";
36
+ for (let t = 0; t < e.length; t += 32768) r += String.fromCharCode(...e.subarray(t, t + 32768));
37
+ return btoa(r);
38
+ }
39
+ export {
40
+ x as base64,
41
+ D as encodePng
42
+ };
package/dist/images.js ADDED
@@ -0,0 +1,88 @@
1
+ import { encodePng as k } from "./image/png.js";
2
+ import { crc32 as q } from "@lewismoten/gamemaker-sandbox-archives/zip";
3
+ import { Pixels as w } from "./kit/pixels.js";
4
+ import { flipX as F, flipY as G, turn180 as U, turn90 as X } from "./kit/transforms.js";
5
+ function N(n, e, h, r, i) {
6
+ const u = [[n, e]];
7
+ return (i === "h" || i === "both") && u.push([h - 1 - n, e]), (i === "v" || i === "both") && u.push([n, r - 1 - e]), i === "both" && u.push([h - 1 - n, r - 1 - e]), u.filter(([c, g], t) => u.findIndex(([o, a]) => o === c && a === g) === t);
8
+ }
9
+ function E(n, e, h) {
10
+ const r = Math.max(Math.abs(e.x - n.x), Math.abs(e.y - n.y), 1);
11
+ for (let i = 0; i <= r; i++) h(Math.round(n.x + (e.x - n.x) * i / r), Math.round(n.y + (e.y - n.y) * i / r));
12
+ }
13
+ function R(n, e, h) {
14
+ for (let r = Math.min(n.x, e.x); r <= Math.max(n.x, e.x); r++)
15
+ h(r, n.y), h(r, e.y);
16
+ for (let r = Math.min(n.y, e.y); r <= Math.max(n.y, e.y); r++)
17
+ h(n.x, r), h(e.x, r);
18
+ }
19
+ function y(n, e, h, r, i, u, c = () => !0, g = (t, o, a) => {
20
+ n[o * e + t] = a;
21
+ }) {
22
+ if (!Number.isSafeInteger(e) || !Number.isSafeInteger(h) || e < 1 || h < 1 || n.length !== e * h)
23
+ throw new RangeError("Expected width × height indexed pixels");
24
+ if (!Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < 0 || r >= e || i >= h || !c(r, i)) return;
25
+ const t = n.slice(), o = t[i * e + r];
26
+ if (o === u) return;
27
+ const a = new Uint8Array(n.length), l = [r, i];
28
+ for (; l.length; ) {
29
+ const f = l.pop(), s = l.pop();
30
+ s < 0 || f < 0 || s >= e || f >= h || a[f * e + s] || t[f * e + s] !== o || !c(s, f) || (a[f * e + s] = 1, g(s, f, u), l.push(s + 1, f, s - 1, f, s, f + 1, s, f - 1));
31
+ }
32
+ }
33
+ function S(n, e, h) {
34
+ if (!Number.isInteger(e) || !Number.isInteger(h)) throw new RangeError("Pixel shifts must use whole numbers");
35
+ const r = (i, u) => (i % u + u) % u;
36
+ return new w(n.w, n.h).map((i, u) => n.get(r(i - e, n.w), r(u - h, n.h)));
37
+ }
38
+ function P(n, e = 256) {
39
+ if (!Number.isInteger(e) || e < 1 || e > 256) throw new RangeError("Color count must be 1..256");
40
+ if (n.some(
41
+ (t) => !Number.isSafeInteger(t.width) || !Number.isSafeInteger(t.height) || t.width < 0 || t.height < 0 || t.data.length !== t.width * t.height * 4
42
+ ))
43
+ throw new RangeError("Expected width × height RGBA pixels");
44
+ if (!n.some((t) => t.data.length)) return [];
45
+ const h = n.reduce((t, o) => t + o.width * o.height, 0), r = Math.max(1, Math.floor(h / 12e4)), i = [];
46
+ for (const t of n) for (let o = 0; o < t.data.length; o += 4 * r) i.push(t.data[o] << 16 | t.data[o + 1] << 8 | t.data[o + 2]);
47
+ const u = [...new Set(i)];
48
+ if (u.length <= e) return u.map((t) => [t >> 16 & 255, t >> 8 & 255, t & 255]);
49
+ const c = [i], g = (t, o) => t >> 16 - o * 8 & 255;
50
+ for (; c.length < e; ) {
51
+ let t = -1, o = -1, a = 0;
52
+ if (c.forEach((s, b) => {
53
+ if (!(s.length < 2))
54
+ for (let d = 0; d < 3; d++) {
55
+ let p = 255, x = 0;
56
+ for (const M of s) {
57
+ const m = g(M, d);
58
+ m < p && (p = m), m > x && (x = m);
59
+ }
60
+ x - p > o && (o = x - p, t = b, a = d);
61
+ }
62
+ }), t < 0 || o === 0) break;
63
+ const l = c[t].sort((s, b) => g(s, a) - g(b, a)), f = l.length >> 1;
64
+ c.splice(t, 1, l.slice(0, f), l.slice(f));
65
+ }
66
+ return c.map((t) => {
67
+ let o = 0, a = 0, l = 0;
68
+ for (const s of t)
69
+ o += s >> 16 & 255, a += s >> 8 & 255, l += s & 255;
70
+ const f = Math.max(1, t.length);
71
+ return [Math.round(o / f), Math.round(a / f), Math.round(l / f)];
72
+ });
73
+ }
74
+ export {
75
+ w as Pixels,
76
+ R as box,
77
+ q as crc32,
78
+ k as encodePng,
79
+ F as flipX,
80
+ G as flipY,
81
+ y as floodFill,
82
+ E as line,
83
+ P as medianCutRgba,
84
+ N as mirrorAll,
85
+ S as shiftPixels,
86
+ U as turn180,
87
+ X as turn90
88
+ };
@@ -0,0 +1,19 @@
1
+ import { emptyFrame as a } from "@lewismoten/gamemaker-sandbox-engine/formats/character";
2
+ import { emptyMonster as f } from "@lewismoten/gamemaker-sandbox-engine/formats/monster";
3
+ function h(r, o, n = {}) {
4
+ if (o.length > 10) throw new Error("Too many frames");
5
+ o.forEach((t, e) => r.frames[e] = t);
6
+ for (let t = o.length; t < r.frames.length; t++) r.frames[t] = a(!0);
7
+ Object.assign(r, { sound: 255, jstkBut: 4, jstkMov: 0, ...n });
8
+ }
9
+ function u(r, o, n = []) {
10
+ const t = f();
11
+ return t.used = 1, r.forEach((e, c) => t.pic[c] = e), Object.assign(t, o), n.forEach((e, c) => t.march[0][c] = e), t;
12
+ }
13
+ const m = (r, o, n, t = 0) => ({ x: r, y: o, pic: n, orient: t }), p = (r, o, n = 0) => [m(0, 0, o), m(r, n, o, 0), m(0, 0, o, 4)];
14
+ export {
15
+ m as corner,
16
+ u as mon,
17
+ p as pace,
18
+ h as set
19
+ };