@flare-engine/shapes 0.1.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.
package/dist/index.js ADDED
@@ -0,0 +1,431 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ applyFriendlyGlow: () => applyFriendlyGlow,
24
+ applyHazardGlow: () => applyHazardGlow,
25
+ argbTo: () => argbTo,
26
+ drawShape: () => drawShape,
27
+ friendlyGlowArgb: () => friendlyGlowArgb,
28
+ hazardGlowArgb: () => hazardGlowArgb,
29
+ shapeBoundsRadius: () => shapeBoundsRadius,
30
+ singleShapeRadius: () => singleShapeRadius
31
+ });
32
+ module.exports = __toCommonJS(index_exports);
33
+
34
+ // src/bounds.ts
35
+ function singleShapeRadius(spec) {
36
+ switch (spec.kind) {
37
+ case "circle":
38
+ case "ring":
39
+ case "ngon":
40
+ return spec.r;
41
+ case "triangle":
42
+ return spec.size;
43
+ case "star":
44
+ return spec.rOuter;
45
+ case "rect":
46
+ case "gradient-rect":
47
+ return Math.max(spec.w, spec.h) * 0.6;
48
+ case "polyline": {
49
+ let max = 0;
50
+ for (let i = 0; i < spec.points.length; i += 2) {
51
+ const px = spec.points[i] ?? 0;
52
+ const py = spec.points[i + 1] ?? 0;
53
+ const m = Math.hypot(px, py);
54
+ if (m > max) max = m;
55
+ }
56
+ return max + (spec.strokeWidth ?? 1);
57
+ }
58
+ case "arc":
59
+ return spec.r;
60
+ case "annulus":
61
+ return spec.rOuter;
62
+ case "trapezoid":
63
+ return Math.max(spec.topW, spec.botW, spec.h) * 0.6;
64
+ case "path":
65
+ return spec.boundsR;
66
+ case "ship":
67
+ return singleShapeRadius(spec.hull);
68
+ }
69
+ }
70
+ function shapeBoundsRadius(specs) {
71
+ let max = 0;
72
+ for (const s of specs) {
73
+ const ox = s.ox ?? 0;
74
+ const oy = s.oy ?? 0;
75
+ const r = boundsR(s);
76
+ const reach = Math.hypot(ox, oy) + r + 2;
77
+ if (reach > max) max = reach;
78
+ }
79
+ return Math.max(4, max);
80
+ }
81
+ function boundsR(spec) {
82
+ switch (spec.kind) {
83
+ case "rect":
84
+ case "gradient-rect":
85
+ return Math.max(spec.w, spec.h) * 0.75;
86
+ case "trapezoid":
87
+ return Math.max(spec.topW, spec.botW, spec.h) * 0.75;
88
+ case "ship":
89
+ return shapeBoundsRadius([spec.hull]);
90
+ default:
91
+ return singleShapeRadius(spec);
92
+ }
93
+ }
94
+
95
+ // src/draw.ts
96
+ function friendlyGlowArgb() {
97
+ return 64 << 24 | 7317099;
98
+ }
99
+ function hazardGlowArgb() {
100
+ return 153 << 24 | 15223594;
101
+ }
102
+ function applyFriendlyGlow(_Skia, canvas, paint, cx, cy, r) {
103
+ applyStroke(paint, friendlyGlowArgb(), 3);
104
+ canvas.drawCircle(cx, cy, r + 4, paint);
105
+ }
106
+ function applyHazardGlow(_Skia, canvas, paint, cx, cy, r) {
107
+ const argb = hazardGlowArgb();
108
+ applyStroke(paint, argb, 0.5);
109
+ canvas.drawCircle(cx, cy, r + 1, paint);
110
+ canvas.drawCircle(cx, cy, r + 2, paint);
111
+ }
112
+ var COLOR = new Float32Array(4);
113
+ function argbTo(out, argb) {
114
+ out[0] = (argb >>> 16 & 255) / 255;
115
+ out[1] = (argb >>> 8 & 255) / 255;
116
+ out[2] = (argb & 255) / 255;
117
+ out[3] = (argb >>> 24 & 255) / 255;
118
+ }
119
+ function applyFill(paint, argb) {
120
+ argbTo(COLOR, argb);
121
+ paint.setColor(COLOR);
122
+ paint.setStyle(0);
123
+ }
124
+ function applyStroke(paint, argb, width) {
125
+ argbTo(COLOR, argb);
126
+ paint.setColor(COLOR);
127
+ paint.setStyle(1);
128
+ paint.setStrokeWidth(width);
129
+ }
130
+ function drawShape(Skia, canvas, paint, spec, x, y, rot) {
131
+ const cx = x + (spec.ox ?? 0);
132
+ const cy = y + (spec.oy ?? 0);
133
+ const r = rot + (spec.rot ?? 0);
134
+ if (spec.glow !== void 0) {
135
+ const gr = singleShapeRadius(spec);
136
+ if (spec.glow === "friendly") {
137
+ applyFriendlyGlow(Skia, canvas, paint, cx, cy, gr);
138
+ } else {
139
+ applyHazardGlow(Skia, canvas, paint, cx, cy, gr);
140
+ }
141
+ }
142
+ switch (spec.kind) {
143
+ case "circle": {
144
+ if (spec.fill !== void 0) {
145
+ applyFill(paint, spec.fill);
146
+ canvas.drawCircle(cx, cy, spec.r, paint);
147
+ }
148
+ if (spec.stroke !== void 0) {
149
+ applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);
150
+ canvas.drawCircle(cx, cy, spec.r, paint);
151
+ }
152
+ return;
153
+ }
154
+ case "ring": {
155
+ applyStroke(paint, spec.stroke ?? 4278190080, spec.strokeWidth ?? 1);
156
+ canvas.drawCircle(cx, cy, spec.r, paint);
157
+ return;
158
+ }
159
+ case "rect":
160
+ drawRect(Skia, canvas, paint, spec, cx, cy, r);
161
+ return;
162
+ case "triangle":
163
+ drawTriangle(Skia, canvas, paint, spec, cx, cy, r);
164
+ return;
165
+ case "ngon":
166
+ drawNgon(Skia, canvas, paint, spec, cx, cy, r);
167
+ return;
168
+ case "star":
169
+ drawStar(Skia, canvas, paint, spec, cx, cy, r);
170
+ return;
171
+ case "polyline":
172
+ drawPolyline(Skia, canvas, paint, spec, cx, cy, r);
173
+ return;
174
+ case "gradient-rect":
175
+ drawGradientRect(Skia, canvas, paint, spec, cx, cy, r);
176
+ return;
177
+ case "arc":
178
+ drawArc(Skia, canvas, paint, spec, cx, cy, r);
179
+ return;
180
+ case "annulus":
181
+ drawAnnulus(Skia, canvas, paint, spec, cx, cy, r);
182
+ return;
183
+ case "trapezoid":
184
+ drawTrapezoid(Skia, canvas, paint, spec, cx, cy, r);
185
+ return;
186
+ case "path":
187
+ drawPath(Skia, canvas, paint, spec, cx, cy, r);
188
+ return;
189
+ case "ship":
190
+ drawShip(Skia, canvas, paint, spec, cx, cy, r);
191
+ return;
192
+ }
193
+ }
194
+ function drawRect(Skia, canvas, paint, spec, cx, cy, rot) {
195
+ canvas.save();
196
+ canvas.translate(cx, cy);
197
+ if (rot !== 0) canvas.rotate(rot * 180 / Math.PI, 0, 0);
198
+ const rect = Skia.XYWHRect(-spec.w / 2, -spec.h / 2, spec.w, spec.h);
199
+ if (spec.fill !== void 0) {
200
+ applyFill(paint, spec.fill);
201
+ canvas.drawRect(rect, paint);
202
+ }
203
+ if (spec.stroke !== void 0) {
204
+ applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);
205
+ canvas.drawRect(rect, paint);
206
+ }
207
+ canvas.restore();
208
+ }
209
+ function drawTriangle(Skia, canvas, paint, spec, cx, cy, rot) {
210
+ const s = spec.size;
211
+ const path = Skia.Path.Make();
212
+ path.moveTo(0, -s);
213
+ path.lineTo(-s * 0.6, s * 0.4);
214
+ path.lineTo(s * 0.6, s * 0.4);
215
+ path.close();
216
+ canvas.save();
217
+ canvas.translate(cx, cy);
218
+ if (rot !== 0) canvas.rotate(rot * 180 / Math.PI, 0, 0);
219
+ if (spec.fill !== void 0) {
220
+ applyFill(paint, spec.fill);
221
+ canvas.drawPath(path, paint);
222
+ }
223
+ if (spec.stroke !== void 0) {
224
+ applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);
225
+ canvas.drawPath(path, paint);
226
+ }
227
+ canvas.restore();
228
+ }
229
+ function drawNgon(Skia, canvas, paint, spec, cx, cy, rot) {
230
+ const path = Skia.Path.Make();
231
+ for (let i = 0; i < spec.n; i++) {
232
+ const a = i / spec.n * Math.PI * 2 - Math.PI / 2;
233
+ const px = Math.cos(a) * spec.r;
234
+ const py = Math.sin(a) * spec.r;
235
+ if (i === 0) path.moveTo(px, py);
236
+ else path.lineTo(px, py);
237
+ }
238
+ path.close();
239
+ canvas.save();
240
+ canvas.translate(cx, cy);
241
+ if (rot !== 0) canvas.rotate(rot * 180 / Math.PI, 0, 0);
242
+ if (spec.fill !== void 0) {
243
+ applyFill(paint, spec.fill);
244
+ canvas.drawPath(path, paint);
245
+ }
246
+ if (spec.stroke !== void 0) {
247
+ applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);
248
+ canvas.drawPath(path, paint);
249
+ }
250
+ canvas.restore();
251
+ }
252
+ function drawStar(Skia, canvas, paint, spec, cx, cy, rot) {
253
+ const path = Skia.Path.Make();
254
+ const total = spec.points * 2;
255
+ for (let i = 0; i < total; i++) {
256
+ const a = i / total * Math.PI * 2 - Math.PI / 2;
257
+ const r = i % 2 === 0 ? spec.rOuter : spec.rInner;
258
+ const px = Math.cos(a) * r;
259
+ const py = Math.sin(a) * r;
260
+ if (i === 0) path.moveTo(px, py);
261
+ else path.lineTo(px, py);
262
+ }
263
+ path.close();
264
+ canvas.save();
265
+ canvas.translate(cx, cy);
266
+ if (rot !== 0) canvas.rotate(rot * 180 / Math.PI, 0, 0);
267
+ if (spec.fill !== void 0) {
268
+ applyFill(paint, spec.fill);
269
+ canvas.drawPath(path, paint);
270
+ }
271
+ if (spec.stroke !== void 0) {
272
+ applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);
273
+ canvas.drawPath(path, paint);
274
+ }
275
+ canvas.restore();
276
+ }
277
+ function drawPolyline(Skia, canvas, paint, spec, cx, cy, rot) {
278
+ const pts = spec.points;
279
+ if (pts.length < 4) return;
280
+ const path = Skia.Path.Make();
281
+ path.moveTo(pts[0] ?? 0, pts[1] ?? 0);
282
+ for (let i = 2; i < pts.length; i += 2) {
283
+ path.lineTo(pts[i] ?? 0, pts[i + 1] ?? 0);
284
+ }
285
+ canvas.save();
286
+ canvas.translate(cx, cy);
287
+ if (rot !== 0) canvas.rotate(rot * 180 / Math.PI, 0, 0);
288
+ applyStroke(paint, spec.stroke ?? 4278190080, spec.strokeWidth ?? 1);
289
+ canvas.drawPath(path, paint);
290
+ canvas.restore();
291
+ }
292
+ function drawGradientRect(Skia, canvas, paint, spec, cx, cy, rot) {
293
+ canvas.save();
294
+ canvas.translate(cx, cy);
295
+ if (rot !== 0) canvas.rotate(rot * 180 / Math.PI, 0, 0);
296
+ const half = spec.axis === 1 ? spec.h / 2 : spec.w / 2;
297
+ if (spec.axis === 1) {
298
+ applyFill(paint, spec.colorA);
299
+ canvas.drawRect(Skia.XYWHRect(-spec.w / 2, -spec.h / 2, spec.w, half), paint);
300
+ applyFill(paint, spec.colorB);
301
+ canvas.drawRect(Skia.XYWHRect(-spec.w / 2, 0, spec.w, half), paint);
302
+ } else {
303
+ applyFill(paint, spec.colorA);
304
+ canvas.drawRect(Skia.XYWHRect(-spec.w / 2, -spec.h / 2, half, spec.h), paint);
305
+ applyFill(paint, spec.colorB);
306
+ canvas.drawRect(Skia.XYWHRect(0, -spec.h / 2, half, spec.h), paint);
307
+ }
308
+ canvas.restore();
309
+ }
310
+ function radToDeg(rad) {
311
+ return rad * 180 / Math.PI;
312
+ }
313
+ function drawArc(Skia, canvas, paint, spec, cx, cy, rot) {
314
+ const path = Skia.Path.Make();
315
+ const oval = Skia.XYWHRect(-spec.r, -spec.r, spec.r * 2, spec.r * 2);
316
+ const startDeg = radToDeg(spec.startAngle);
317
+ const sweepDeg = radToDeg(spec.endAngle - spec.startAngle);
318
+ if (spec.sector === true) {
319
+ path.moveTo(0, 0);
320
+ path.addArc(oval, startDeg, sweepDeg);
321
+ path.close();
322
+ } else {
323
+ path.addArc(oval, startDeg, sweepDeg);
324
+ }
325
+ canvas.save();
326
+ canvas.translate(cx, cy);
327
+ if (rot !== 0) canvas.rotate(radToDeg(rot), 0, 0);
328
+ if (spec.fill !== void 0) {
329
+ applyFill(paint, spec.fill);
330
+ canvas.drawPath(path, paint);
331
+ }
332
+ if (spec.stroke !== void 0) {
333
+ applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);
334
+ canvas.drawPath(path, paint);
335
+ }
336
+ canvas.restore();
337
+ }
338
+ function drawAnnulus(Skia, canvas, paint, spec, cx, cy, rot) {
339
+ const midR = (spec.rOuter + spec.rInner) / 2;
340
+ const thickness = spec.rOuter - spec.rInner;
341
+ const ringColor = spec.fill ?? spec.stroke ?? 4278190080;
342
+ canvas.save();
343
+ canvas.translate(cx, cy);
344
+ if (rot !== 0) canvas.rotate(radToDeg(rot), 0, 0);
345
+ if (spec.startAngle !== void 0 && spec.endAngle !== void 0) {
346
+ const path = Skia.Path.Make();
347
+ const oval = Skia.XYWHRect(-midR, -midR, midR * 2, midR * 2);
348
+ path.addArc(oval, radToDeg(spec.startAngle), radToDeg(spec.endAngle - spec.startAngle));
349
+ applyStroke(paint, ringColor, thickness);
350
+ canvas.drawPath(path, paint);
351
+ } else {
352
+ applyStroke(paint, ringColor, thickness);
353
+ canvas.drawCircle(0, 0, midR, paint);
354
+ }
355
+ canvas.restore();
356
+ }
357
+ function drawTrapezoid(Skia, canvas, paint, spec, cx, cy, rot) {
358
+ const path = Skia.Path.Make();
359
+ const halfTopW = spec.topW / 2;
360
+ const halfBotW = spec.botW / 2;
361
+ const halfH = spec.h / 2;
362
+ path.moveTo(-halfTopW, -halfH);
363
+ path.lineTo(halfTopW, -halfH);
364
+ path.lineTo(halfBotW, halfH);
365
+ path.lineTo(-halfBotW, halfH);
366
+ path.close();
367
+ canvas.save();
368
+ canvas.translate(cx, cy);
369
+ if (rot !== 0) canvas.rotate(radToDeg(rot), 0, 0);
370
+ if (spec.fill !== void 0) {
371
+ applyFill(paint, spec.fill);
372
+ canvas.drawPath(path, paint);
373
+ }
374
+ if (spec.stroke !== void 0) {
375
+ applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);
376
+ canvas.drawPath(path, paint);
377
+ }
378
+ canvas.restore();
379
+ }
380
+ function drawPath(Skia, canvas, paint, spec, cx, cy, rot) {
381
+ const path = Skia.Path.MakeFromSVGString(spec.d);
382
+ if (path === null) return;
383
+ canvas.save();
384
+ canvas.translate(cx, cy);
385
+ if (rot !== 0) canvas.rotate(radToDeg(rot), 0, 0);
386
+ if (spec.fill !== void 0) {
387
+ applyFill(paint, spec.fill);
388
+ canvas.drawPath(path, paint);
389
+ }
390
+ if (spec.stroke !== void 0) {
391
+ applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);
392
+ canvas.drawPath(path, paint);
393
+ }
394
+ canvas.restore();
395
+ }
396
+ function drawSquare(Skia, canvas, paint, spec, cx, cy, rot) {
397
+ const rectSpec = {
398
+ kind: "rect",
399
+ w: spec.size,
400
+ h: spec.size,
401
+ fill: spec.fill,
402
+ stroke: spec.stroke,
403
+ strokeWidth: spec.strokeWidth,
404
+ ox: spec.ox,
405
+ oy: spec.oy,
406
+ rot: spec.rot
407
+ };
408
+ drawRect(Skia, canvas, paint, rectSpec, cx, cy, rot);
409
+ }
410
+ function drawShip(Skia, canvas, paint, spec, cx, cy, rot) {
411
+ drawSquare(Skia, canvas, paint, spec.engine, cx, cy, rot);
412
+ drawShape(Skia, canvas, paint, spec.hull, cx, cy, rot);
413
+ for (let i = 0; i < spec.weapons.length; i++) {
414
+ const w = spec.weapons[i];
415
+ if (w !== void 0) {
416
+ drawShape(Skia, canvas, paint, w, cx, cy, rot);
417
+ }
418
+ }
419
+ }
420
+ // Annotate the CommonJS export names for ESM import in node:
421
+ 0 && (module.exports = {
422
+ applyFriendlyGlow,
423
+ applyHazardGlow,
424
+ argbTo,
425
+ drawShape,
426
+ friendlyGlowArgb,
427
+ hazardGlowArgb,
428
+ shapeBoundsRadius,
429
+ singleShapeRadius
430
+ });
431
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/bounds.ts","../src/draw.ts"],"sourcesContent":["export type {\n AnnulusSpec,\n ArcSpec,\n BaseSpec,\n CircleSpec,\n GradientRectSpec,\n NgonSpec,\n PathSpec,\n PolylineSpec,\n RectSpec,\n RingSpec,\n ShapeSpec,\n ShipSpec,\n SquareSpec,\n StarSpec,\n TrapezoidSpec,\n TriangleSpec,\n} from './types.js';\n\nexport {\n applyFriendlyGlow,\n applyHazardGlow,\n argbTo,\n drawShape,\n friendlyGlowArgb,\n hazardGlowArgb,\n} from './draw.js';\n\nexport { shapeBoundsRadius, singleShapeRadius } from './bounds.js';\n","import type { ShapeSpec } from './types.js';\n\n/**\n * Approximate bounding radius for a single primitive. Used to size glow\n * rings and atlas tiles. Returned values are deliberately a touch generous\n * to avoid clipping.\n */\nexport function singleShapeRadius(spec: ShapeSpec): number {\n switch (spec.kind) {\n case 'circle':\n case 'ring':\n case 'ngon':\n return spec.r;\n case 'triangle':\n return spec.size;\n case 'star':\n return spec.rOuter;\n case 'rect':\n case 'gradient-rect':\n return Math.max(spec.w, spec.h) * 0.6;\n case 'polyline': {\n let max = 0;\n for (let i = 0; i < spec.points.length; i += 2) {\n const px = spec.points[i] ?? 0;\n const py = spec.points[i + 1] ?? 0;\n const m = Math.hypot(px, py);\n if (m > max) max = m;\n }\n return max + (spec.strokeWidth ?? 1);\n }\n case 'arc':\n return spec.r;\n case 'annulus':\n return spec.rOuter;\n case 'trapezoid':\n return Math.max(spec.topW, spec.botW, spec.h) * 0.6;\n case 'path':\n return spec.boundsR;\n case 'ship':\n return singleShapeRadius(spec.hull);\n }\n}\n\n/**\n * Compute axis-aligned bounding radius for a shape composition. Used to\n * size atlas tiles. Returns the max half-extent from origin across all\n * shapes (including their `ox`/`oy` offsets and stroke widths).\n */\nexport function shapeBoundsRadius(specs: readonly ShapeSpec[]): number {\n let max = 0;\n for (const s of specs) {\n const ox = s.ox ?? 0;\n const oy = s.oy ?? 0;\n const r = boundsR(s);\n const reach = Math.hypot(ox, oy) + r + 2;\n if (reach > max) max = reach;\n }\n return Math.max(4, max);\n}\n\n/** Tighter atlas-tile-sizing radius (rect/gradient-rect use 0.75 to fit corners). */\nfunction boundsR(spec: ShapeSpec): number {\n switch (spec.kind) {\n case 'rect':\n case 'gradient-rect':\n return Math.max(spec.w, spec.h) * 0.75;\n case 'trapezoid':\n return Math.max(spec.topW, spec.botW, spec.h) * 0.75;\n case 'ship':\n return shapeBoundsRadius([spec.hull]);\n default:\n return singleShapeRadius(spec);\n }\n}\n","/**\n * Shape drawing dispatcher — consumes a `ShapeSpec` and emits Skia draw\n * calls on a canvas. All shapes draw relative to (x + ox, y + oy), rotated\n * by (rot + spec.rot).\n *\n * The dispatcher is allocation-free per call except where Skia itself\n * allocates path objects. Glow ring is emitted before the shape body so it\n * renders behind the geometry.\n */\n\nimport type { SkCanvas, SkPaint, Skia as SkiaModule } from '@shopify/react-native-skia';\nimport { singleShapeRadius } from './bounds.js';\nimport type {\n AnnulusSpec,\n ArcSpec,\n GradientRectSpec,\n NgonSpec,\n PathSpec,\n PolylineSpec,\n RectSpec,\n ShapeSpec,\n ShipSpec,\n SquareSpec,\n StarSpec,\n TrapezoidSpec,\n TriangleSpec,\n} from './types.js';\n\ntype Skia = typeof SkiaModule;\n\n// ---- Glow recipes -----------------------------------------------------------\n\n/** ARGB for safe #6FA66B at α ≈ 0.25 (0x40 / 255). */\nexport function friendlyGlowArgb(): number {\n return (0x40 << 24) | 0x6fa66b;\n}\n\n/** ARGB for hazardOrange #E84B2A at α ≈ 0.6 (0x99 / 255). */\nexport function hazardGlowArgb(): number {\n return (0x99 << 24) | 0xe84b2a;\n}\n\nexport function applyFriendlyGlow(\n _Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n cx: number,\n cy: number,\n r: number,\n): void {\n applyStroke(paint, friendlyGlowArgb(), 3);\n canvas.drawCircle(cx, cy, r + 4, paint);\n}\n\nexport function applyHazardGlow(\n _Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n cx: number,\n cy: number,\n r: number,\n): void {\n const argb = hazardGlowArgb();\n applyStroke(paint, argb, 0.5);\n canvas.drawCircle(cx, cy, r + 1, paint);\n canvas.drawCircle(cx, cy, r + 2, paint);\n}\n\n// ---- Color plumbing ---------------------------------------------------------\n\nconst COLOR = new Float32Array(4);\n\nexport function argbTo(out: Float32Array, argb: number): void {\n out[0] = ((argb >>> 16) & 0xff) / 255;\n out[1] = ((argb >>> 8) & 0xff) / 255;\n out[2] = (argb & 0xff) / 255;\n out[3] = ((argb >>> 24) & 0xff) / 255;\n}\n\nfunction applyFill(paint: SkPaint, argb: number): void {\n argbTo(COLOR, argb);\n paint.setColor(COLOR);\n paint.setStyle(0); // Fill\n}\n\nfunction applyStroke(paint: SkPaint, argb: number, width: number): void {\n argbTo(COLOR, argb);\n paint.setColor(COLOR);\n paint.setStyle(1); // Stroke\n paint.setStrokeWidth(width);\n}\n\n// ---- Dispatcher -------------------------------------------------------------\n\nexport function drawShape(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: ShapeSpec,\n x: number,\n y: number,\n rot: number,\n): void {\n const cx = x + (spec.ox ?? 0);\n const cy = y + (spec.oy ?? 0);\n const r = rot + (spec.rot ?? 0);\n\n if (spec.glow !== undefined) {\n const gr = singleShapeRadius(spec);\n if (spec.glow === 'friendly') {\n applyFriendlyGlow(Skia, canvas, paint, cx, cy, gr);\n } else {\n applyHazardGlow(Skia, canvas, paint, cx, cy, gr);\n }\n }\n\n switch (spec.kind) {\n case 'circle': {\n if (spec.fill !== undefined) {\n applyFill(paint, spec.fill);\n canvas.drawCircle(cx, cy, spec.r, paint);\n }\n if (spec.stroke !== undefined) {\n applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);\n canvas.drawCircle(cx, cy, spec.r, paint);\n }\n return;\n }\n case 'ring': {\n applyStroke(paint, spec.stroke ?? 0xff000000, spec.strokeWidth ?? 1);\n canvas.drawCircle(cx, cy, spec.r, paint);\n return;\n }\n case 'rect':\n drawRect(Skia, canvas, paint, spec, cx, cy, r);\n return;\n case 'triangle':\n drawTriangle(Skia, canvas, paint, spec, cx, cy, r);\n return;\n case 'ngon':\n drawNgon(Skia, canvas, paint, spec, cx, cy, r);\n return;\n case 'star':\n drawStar(Skia, canvas, paint, spec, cx, cy, r);\n return;\n case 'polyline':\n drawPolyline(Skia, canvas, paint, spec, cx, cy, r);\n return;\n case 'gradient-rect':\n drawGradientRect(Skia, canvas, paint, spec, cx, cy, r);\n return;\n case 'arc':\n drawArc(Skia, canvas, paint, spec, cx, cy, r);\n return;\n case 'annulus':\n drawAnnulus(Skia, canvas, paint, spec, cx, cy, r);\n return;\n case 'trapezoid':\n drawTrapezoid(Skia, canvas, paint, spec, cx, cy, r);\n return;\n case 'path':\n drawPath(Skia, canvas, paint, spec, cx, cy, r);\n return;\n case 'ship':\n drawShip(Skia, canvas, paint, spec, cx, cy, r);\n return;\n }\n}\n\n// ---- Per-primitive renderers -----------------------------------------------\n\nfunction drawRect(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: RectSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n canvas.save();\n canvas.translate(cx, cy);\n if (rot !== 0) canvas.rotate((rot * 180) / Math.PI, 0, 0);\n const rect = Skia.XYWHRect(-spec.w / 2, -spec.h / 2, spec.w, spec.h);\n if (spec.fill !== undefined) {\n applyFill(paint, spec.fill);\n canvas.drawRect(rect, paint);\n }\n if (spec.stroke !== undefined) {\n applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);\n canvas.drawRect(rect, paint);\n }\n canvas.restore();\n}\n\nfunction drawTriangle(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: TriangleSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n const s = spec.size;\n const path = Skia.Path.Make();\n path.moveTo(0, -s);\n path.lineTo(-s * 0.6, s * 0.4);\n path.lineTo(s * 0.6, s * 0.4);\n path.close();\n canvas.save();\n canvas.translate(cx, cy);\n if (rot !== 0) canvas.rotate((rot * 180) / Math.PI, 0, 0);\n if (spec.fill !== undefined) {\n applyFill(paint, spec.fill);\n canvas.drawPath(path, paint);\n }\n if (spec.stroke !== undefined) {\n applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);\n canvas.drawPath(path, paint);\n }\n canvas.restore();\n}\n\nfunction drawNgon(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: NgonSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n const path = Skia.Path.Make();\n for (let i = 0; i < spec.n; i++) {\n const a = (i / spec.n) * Math.PI * 2 - Math.PI / 2;\n const px = Math.cos(a) * spec.r;\n const py = Math.sin(a) * spec.r;\n if (i === 0) path.moveTo(px, py);\n else path.lineTo(px, py);\n }\n path.close();\n canvas.save();\n canvas.translate(cx, cy);\n if (rot !== 0) canvas.rotate((rot * 180) / Math.PI, 0, 0);\n if (spec.fill !== undefined) {\n applyFill(paint, spec.fill);\n canvas.drawPath(path, paint);\n }\n if (spec.stroke !== undefined) {\n applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);\n canvas.drawPath(path, paint);\n }\n canvas.restore();\n}\n\nfunction drawStar(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: StarSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n const path = Skia.Path.Make();\n const total = spec.points * 2;\n for (let i = 0; i < total; i++) {\n const a = (i / total) * Math.PI * 2 - Math.PI / 2;\n const r = i % 2 === 0 ? spec.rOuter : spec.rInner;\n const px = Math.cos(a) * r;\n const py = Math.sin(a) * r;\n if (i === 0) path.moveTo(px, py);\n else path.lineTo(px, py);\n }\n path.close();\n canvas.save();\n canvas.translate(cx, cy);\n if (rot !== 0) canvas.rotate((rot * 180) / Math.PI, 0, 0);\n if (spec.fill !== undefined) {\n applyFill(paint, spec.fill);\n canvas.drawPath(path, paint);\n }\n if (spec.stroke !== undefined) {\n applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);\n canvas.drawPath(path, paint);\n }\n canvas.restore();\n}\n\nfunction drawPolyline(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: PolylineSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n const pts = spec.points;\n if (pts.length < 4) return;\n const path = Skia.Path.Make();\n path.moveTo(pts[0] ?? 0, pts[1] ?? 0);\n for (let i = 2; i < pts.length; i += 2) {\n path.lineTo(pts[i] ?? 0, pts[i + 1] ?? 0);\n }\n canvas.save();\n canvas.translate(cx, cy);\n if (rot !== 0) canvas.rotate((rot * 180) / Math.PI, 0, 0);\n applyStroke(paint, spec.stroke ?? 0xff000000, spec.strokeWidth ?? 1);\n canvas.drawPath(path, paint);\n canvas.restore();\n}\n\nfunction drawGradientRect(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: GradientRectSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n // Cheap two-half approximation; true shader gradient is overkill at atlas-build time.\n canvas.save();\n canvas.translate(cx, cy);\n if (rot !== 0) canvas.rotate((rot * 180) / Math.PI, 0, 0);\n const half = spec.axis === 1 ? spec.h / 2 : spec.w / 2;\n if (spec.axis === 1) {\n applyFill(paint, spec.colorA);\n canvas.drawRect(Skia.XYWHRect(-spec.w / 2, -spec.h / 2, spec.w, half), paint);\n applyFill(paint, spec.colorB);\n canvas.drawRect(Skia.XYWHRect(-spec.w / 2, 0, spec.w, half), paint);\n } else {\n applyFill(paint, spec.colorA);\n canvas.drawRect(Skia.XYWHRect(-spec.w / 2, -spec.h / 2, half, spec.h), paint);\n applyFill(paint, spec.colorB);\n canvas.drawRect(Skia.XYWHRect(0, -spec.h / 2, half, spec.h), paint);\n }\n canvas.restore();\n}\n\n// Skia uses degrees, 0° at +X, increasing clockwise. We accept radians (math\n// convention CCW positive) and convert; visual result matches expectations\n// when rotated through the canvas transform.\nfunction radToDeg(rad: number): number {\n return (rad * 180) / Math.PI;\n}\n\nfunction drawArc(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: ArcSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n const path = Skia.Path.Make();\n const oval = Skia.XYWHRect(-spec.r, -spec.r, spec.r * 2, spec.r * 2);\n const startDeg = radToDeg(spec.startAngle);\n const sweepDeg = radToDeg(spec.endAngle - spec.startAngle);\n if (spec.sector === true) {\n path.moveTo(0, 0);\n path.addArc(oval, startDeg, sweepDeg);\n path.close();\n } else {\n path.addArc(oval, startDeg, sweepDeg);\n }\n canvas.save();\n canvas.translate(cx, cy);\n if (rot !== 0) canvas.rotate(radToDeg(rot), 0, 0);\n if (spec.fill !== undefined) {\n applyFill(paint, spec.fill);\n canvas.drawPath(path, paint);\n }\n if (spec.stroke !== undefined) {\n applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);\n canvas.drawPath(path, paint);\n }\n canvas.restore();\n}\n\nfunction drawAnnulus(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: AnnulusSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n // Render as a thick stroked circle/arc at the mid-radius. The fill colour\n // becomes the ring colour (more ergonomic than even-odd path subtraction).\n const midR = (spec.rOuter + spec.rInner) / 2;\n const thickness = spec.rOuter - spec.rInner;\n const ringColor = spec.fill ?? spec.stroke ?? 0xff000000;\n\n canvas.save();\n canvas.translate(cx, cy);\n if (rot !== 0) canvas.rotate(radToDeg(rot), 0, 0);\n\n if (spec.startAngle !== undefined && spec.endAngle !== undefined) {\n const path = Skia.Path.Make();\n const oval = Skia.XYWHRect(-midR, -midR, midR * 2, midR * 2);\n path.addArc(oval, radToDeg(spec.startAngle), radToDeg(spec.endAngle - spec.startAngle));\n applyStroke(paint, ringColor, thickness);\n canvas.drawPath(path, paint);\n } else {\n applyStroke(paint, ringColor, thickness);\n canvas.drawCircle(0, 0, midR, paint);\n }\n\n canvas.restore();\n}\n\nfunction drawTrapezoid(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: TrapezoidSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n const path = Skia.Path.Make();\n const halfTopW = spec.topW / 2;\n const halfBotW = spec.botW / 2;\n const halfH = spec.h / 2;\n // Apex up: narrow top edge at -h/2, wide bottom edge at +h/2.\n path.moveTo(-halfTopW, -halfH);\n path.lineTo(halfTopW, -halfH);\n path.lineTo(halfBotW, halfH);\n path.lineTo(-halfBotW, halfH);\n path.close();\n canvas.save();\n canvas.translate(cx, cy);\n if (rot !== 0) canvas.rotate(radToDeg(rot), 0, 0);\n if (spec.fill !== undefined) {\n applyFill(paint, spec.fill);\n canvas.drawPath(path, paint);\n }\n if (spec.stroke !== undefined) {\n applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);\n canvas.drawPath(path, paint);\n }\n canvas.restore();\n}\n\nfunction drawPath(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: PathSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n const path = Skia.Path.MakeFromSVGString(spec.d);\n // Malformed SVG returns null — skip silently rather than throw.\n if (path === null) return;\n canvas.save();\n canvas.translate(cx, cy);\n if (rot !== 0) canvas.rotate(radToDeg(rot), 0, 0);\n if (spec.fill !== undefined) {\n applyFill(paint, spec.fill);\n canvas.drawPath(path, paint);\n }\n if (spec.stroke !== undefined) {\n applyStroke(paint, spec.stroke, spec.strokeWidth ?? 1);\n canvas.drawPath(path, paint);\n }\n canvas.restore();\n}\n\nfunction drawSquare(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: SquareSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n const rectSpec: RectSpec = {\n kind: 'rect',\n w: spec.size,\n h: spec.size,\n fill: spec.fill,\n stroke: spec.stroke,\n strokeWidth: spec.strokeWidth,\n ox: spec.ox,\n oy: spec.oy,\n rot: spec.rot,\n };\n drawRect(Skia, canvas, paint, rectSpec, cx, cy, rot);\n}\n\n/**\n * Draw a ShipSpec by painting engine → hull → weapons (engine deepest,\n * weapons foremost — painter's algorithm). Zero allocation in the weapons\n * loop: classic indexed for-loop over the readonly array.\n */\nfunction drawShip(\n Skia: Skia,\n canvas: SkCanvas,\n paint: SkPaint,\n spec: ShipSpec,\n cx: number,\n cy: number,\n rot: number,\n): void {\n drawSquare(Skia, canvas, paint, spec.engine, cx, cy, rot);\n drawShape(Skia, canvas, paint, spec.hull, cx, cy, rot);\n for (let i = 0; i < spec.weapons.length; i++) {\n const w = spec.weapons[i];\n if (w !== undefined) {\n drawShape(Skia, canvas, paint, w, cx, cy, rot);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,SAAS,kBAAkB,MAAyB;AACzD,UAAQ,KAAK,MAAM;AAAA,IACjB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,KAAK;AAAA,IACd,KAAK;AACH,aAAO,KAAK;AAAA,IACd,KAAK;AACH,aAAO,KAAK;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AACH,aAAO,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI;AAAA,IACpC,KAAK,YAAY;AACf,UAAI,MAAM;AACV,eAAS,IAAI,GAAG,IAAI,KAAK,OAAO,QAAQ,KAAK,GAAG;AAC9C,cAAM,KAAK,KAAK,OAAO,CAAC,KAAK;AAC7B,cAAM,KAAK,KAAK,OAAO,IAAI,CAAC,KAAK;AACjC,cAAM,IAAI,KAAK,MAAM,IAAI,EAAE;AAC3B,YAAI,IAAI,IAAK,OAAM;AAAA,MACrB;AACA,aAAO,OAAO,KAAK,eAAe;AAAA,IACpC;AAAA,IACA,KAAK;AACH,aAAO,KAAK;AAAA,IACd,KA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