@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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Grzegorz Otto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # @flare-engine/shapes
2
+
3
+ Procedural 2D shape primitives for [react-native-skia](https://shopify.github.io/react-native-skia/). 12 named atomic shapes + an SVG path escape hatch — designed for fast 2D game prototyping where you compose entities from primitives instead of importing sprite art.
4
+
5
+ ## Why
6
+
7
+ Mobile and indie game prototypes don't need sprite sheets to start. Compose ships, enemies, pickups, and UI shapes from primitives, ship a playable build, and replace shapes with art only after the mechanics lock — exactly the workflow Unity Shapes2D and Defold prototyping threads document. Used in production by [Pan Tvardowski](https://github.com/grzott/flare-engine/tree/main/apps/pan-tvardowski) (29 ships + 10 pickups, all data-only).
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ bun add @flare-engine/shapes @shopify/react-native-skia
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { drawShape, type ShapeSpec } from '@flare-engine/shapes';
19
+
20
+ // Compose any entity from primitives.
21
+ const shape: ShapeSpec = { kind: 'circle', r: 24, fill: 0xff8844cc };
22
+ drawShape(Skia, canvas, paint, shape, /* x */ 100, /* y */ 200, /* rot */ 0);
23
+
24
+ // Need a custom shape? Use the SVG escape hatch:
25
+ const star: ShapeSpec = {
26
+ kind: 'path',
27
+ d: 'M 128 0 L 168 80 L 256 93 L 192 155 L 207 244 L 128 202 L 49 244 L 64 155 L 0 93 L 88 80 Z',
28
+ boundsR: 256,
29
+ fill: 0xffc9a24a,
30
+ };
31
+ drawShape(Skia, canvas, paint, star, 0, 0, 0);
32
+ ```
33
+
34
+ ## Primitives
35
+
36
+ 13 spec kinds covering every common 2D shape. All accept optional `fill` (ARGB int), `stroke`, `strokeWidth`, `ox`/`oy` (local offset), `rot` (radians), and `glow: 'friendly' | 'hazard'`.
37
+
38
+ | Kind | Fields | Use case |
39
+ |---|---|---|
40
+ | `circle` | `r` | Bullets, pickups, eyes |
41
+ | `rect` | `w`, `h` | Weapons, HUD bars, frames |
42
+ | `triangle` | `size` | Ship hulls, arrows, sigils |
43
+ | `ngon` | `n`, `r` | Hex/pentagon/octagon hulls |
44
+ | `star` | `points`, `rOuter`, `rInner` | Sigils, sparks, pickups |
45
+ | `ring` | `r` | Auras, target markers |
46
+ | `polyline` | `points: number[]` | Bolts, freehand strokes |
47
+ | `gradient-rect` | `w`, `h`, `colorA`, `colorB`, `axis: 0\|1` | HP bars, sky strips |
48
+ | `arc` | `r`, `startAngle`, `endAngle`, `sector?` | Half-circle, 1/4-moon, 1/8-moon |
49
+ | `annulus` | `rOuter`, `rInner`, `startAngle?`, `endAngle?` | Donut, half-donut, partial rings |
50
+ | `trapezoid` | `topW`, `botW`, `h` | Ship cockpits, pedestals |
51
+ | `path` | `d`, `boundsR` | **Escape hatch** — any SVG path string |
52
+ | `ship` | `hull`, `weapons[]`, `engine` | Composite (3-element rule) |
53
+
54
+ ## Composing entities
55
+
56
+ ```ts
57
+ import type { ShapeSpec } from '@flare-engine/shapes';
58
+
59
+ // A ship: hull + 2 weapons + engine, painted back-to-front.
60
+ const playerShip: ShapeSpec = {
61
+ kind: 'ship',
62
+ hull: { kind: 'triangle', size: 28, fill: 0xffc9a24a },
63
+ weapons: [
64
+ { kind: 'rect', w: 6, h: 12, fill: 0xffc9a24a, ox: -14, oy: 8 },
65
+ { kind: 'rect', w: 6, h: 12, fill: 0xffc9a24a, ox: 14, oy: 8 },
66
+ ],
67
+ engine: { kind: 'square', size: 20, fill: 0xff806020 },
68
+ };
69
+
70
+ // A pickup: ring + inner glow circle.
71
+ const amulet: readonly ShapeSpec[] = [
72
+ { kind: 'ring', r: 9, stroke: 0xffc9a24a, strokeWidth: 2, glow: 'friendly' },
73
+ { kind: 'circle', r: 3, fill: 0xffff2b2b },
74
+ ];
75
+ ```
76
+
77
+ ## Bounds
78
+
79
+ ```ts
80
+ import { shapeBoundsRadius, singleShapeRadius } from '@flare-engine/shapes';
81
+
82
+ // For atlas tile sizing — max half-extent across a composition.
83
+ const tileRadius = shapeBoundsRadius([playerShip]);
84
+
85
+ // For glow halo sizing — radius of one primitive.
86
+ const glowR = singleShapeRadius({ kind: 'circle', r: 14 });
87
+ ```
88
+
89
+ ## Adding a new primitive
90
+
91
+ Three ways, in order of friction:
92
+
93
+ 1. **Use the `path` escape hatch.** SVG `d="..."` strings parse natively via `Skia.Path.MakeFromSVGString`. Same syntax as Figma / Inkscape / `<path>`. Zero engine change.
94
+
95
+ 2. **Author a composition.** Wrap multiple primitives in a `ShapeSpec[]` array. No new code at all.
96
+
97
+ 3. **Add a named primitive.** When (1)/(2) aren't ergonomic enough or you need a perf-optimized branch:
98
+
99
+ 1. Extend the `ShapeSpec` union in `src/types.ts`
100
+ 2. Add a `case 'kind':` branch in `drawShape` (`src/draw.ts`)
101
+ 3. Add a bounds branch in `singleShapeRadius` (`src/bounds.ts`)
102
+ 4. Add tests in `tests/draw.test.ts` and `tests/bounds.test.ts`
103
+
104
+ Tsc enforces exhaustiveness — forgetting any of these fails the build.
105
+
106
+ ## Glow tags
107
+
108
+ Two visual halos for free, set `glow: 'friendly' | 'hazard'` on any primitive:
109
+
110
+ | Tag | Color | Use |
111
+ |---|---|---|
112
+ | `friendly` | safe-green `#6FA66B` at α=0.25, single 3 px ring at `r+4` | Player ships, pickups, safe markers |
113
+ | `hazard` | hazard-orange `#E84B2A` at α=0.6, double 0.5 px ring at `r+1` and `r+2` | Enemy bullets, danger cues |
114
+
115
+ ## License
116
+
117
+ MIT
@@ -0,0 +1,194 @@
1
+ import { Skia as Skia$1, SkCanvas, SkPaint } from '@shopify/react-native-skia';
2
+
3
+ /**
4
+ * Shape primitive vocabulary. 12 named atomic shapes + 1 SVG escape hatch.
5
+ *
6
+ * Adding a new named primitive requires changes in 4 places:
7
+ * 1. extend the `ShapeSpec` union here
8
+ * 2. add a draw branch in `draw.ts`
9
+ * 3. add a bounds branch in `bounds.ts`
10
+ * 4. add tests in `tests/`
11
+ *
12
+ * Adding an arbitrary shape *without* a new named primitive is data-only:
13
+ * use `{ kind: 'path', d: '<SVG path string>' }`. Skia parses SVG path data
14
+ * natively via `Path.MakeFromSVGString` — same syntax as Figma / Inkscape /
15
+ * `<path d="...">`.
16
+ *
17
+ * All colors are 32-bit ARGB ints (alpha in high byte). Use `argbTo()` from
18
+ * `draw.ts` to feed Skia paints.
19
+ */
20
+ interface BaseSpec {
21
+ readonly fill?: number;
22
+ readonly stroke?: number;
23
+ readonly strokeWidth?: number;
24
+ /** Local offset applied when composing multiple shapes per entity. */
25
+ readonly ox?: number;
26
+ readonly oy?: number;
27
+ /** Local rotation in radians, composed with the entity rotation. */
28
+ readonly rot?: number;
29
+ /**
30
+ * Optional glow tag. When present, `drawShape` emits the corresponding glow
31
+ * ring behind the body geometry.
32
+ *
33
+ * 'friendly' — safe-green rim (player ship, weapon/upgrade pickups)
34
+ * 'hazard' — orange double-stroke (danger cues, enemy bullets)
35
+ */
36
+ readonly glow?: 'friendly' | 'hazard';
37
+ }
38
+ interface CircleSpec extends BaseSpec {
39
+ readonly kind: 'circle';
40
+ readonly r: number;
41
+ }
42
+ interface RectSpec extends BaseSpec {
43
+ readonly kind: 'rect';
44
+ readonly w: number;
45
+ readonly h: number;
46
+ }
47
+ interface TriangleSpec extends BaseSpec {
48
+ readonly kind: 'triangle';
49
+ readonly size: number;
50
+ }
51
+ interface NgonSpec extends BaseSpec {
52
+ readonly kind: 'ngon';
53
+ readonly n: number;
54
+ readonly r: number;
55
+ }
56
+ interface StarSpec extends BaseSpec {
57
+ readonly kind: 'star';
58
+ readonly points: number;
59
+ readonly rOuter: number;
60
+ readonly rInner: number;
61
+ }
62
+ interface RingSpec extends BaseSpec {
63
+ readonly kind: 'ring';
64
+ readonly r: number;
65
+ }
66
+ interface PolylineSpec extends BaseSpec {
67
+ readonly kind: 'polyline';
68
+ readonly points: readonly number[];
69
+ }
70
+ interface GradientRectSpec extends BaseSpec {
71
+ readonly kind: 'gradient-rect';
72
+ readonly w: number;
73
+ readonly h: number;
74
+ readonly colorA: number;
75
+ readonly colorB: number;
76
+ /** 0 = horizontal, 1 = vertical. */
77
+ readonly axis: 0 | 1;
78
+ }
79
+ /**
80
+ * Sector or arc. Angles in radians, 0 = +X axis, increasing CCW.
81
+ *
82
+ * Use cases:
83
+ * - half-circle: startAngle: 0, endAngle: Math.PI, sector: true
84
+ * - 1/4-moon: startAngle: Math.PI*1.5, endAngle: 0, sector: true
85
+ * - 1/8-moon: startAngle: -Math.PI/8, endAngle: Math.PI/8, sector: true
86
+ */
87
+ interface ArcSpec extends BaseSpec {
88
+ readonly kind: 'arc';
89
+ readonly r: number;
90
+ readonly startAngle: number;
91
+ readonly endAngle: number;
92
+ /** Closed wedge (true) or open arc stroke (false). Default false. */
93
+ readonly sector?: boolean;
94
+ }
95
+ /**
96
+ * Annulus (ring with thickness). When `startAngle`+`endAngle` are set,
97
+ * renders a partial annulus (half-donut, quarter-donut, etc.).
98
+ *
99
+ * Implementation note: rendered as a thick stroked circle/arc at the
100
+ * mid-radius with width = `rOuter - rInner`. The `fill` colour is used as
101
+ * the ring colour.
102
+ */
103
+ interface AnnulusSpec extends BaseSpec {
104
+ readonly kind: 'annulus';
105
+ readonly rOuter: number;
106
+ readonly rInner: number;
107
+ /** If set together with `endAngle`, renders a partial annulus. */
108
+ readonly startAngle?: number;
109
+ readonly endAngle?: number;
110
+ }
111
+ /**
112
+ * Trapezoid (4-sided, parallel top and bottom edges). Apex up — `topW` is
113
+ * the narrow edge at -h/2, `botW` is the wide edge at +h/2. Use `rot: Math.PI`
114
+ * to flip apex-down.
115
+ */
116
+ interface TrapezoidSpec extends BaseSpec {
117
+ readonly kind: 'trapezoid';
118
+ readonly topW: number;
119
+ readonly botW: number;
120
+ readonly h: number;
121
+ }
122
+ /**
123
+ * SVG path escape hatch. `d` is the standard SVG path-data string (M, L, C,
124
+ * Q, A, Z, etc.) parsed by `Skia.Path.MakeFromSVGString`. Same syntax as
125
+ * Figma / Inkscape / `<path d="...">`.
126
+ *
127
+ * If the path string is malformed and Skia returns null, the draw call is
128
+ * silently skipped (does not throw).
129
+ */
130
+ interface PathSpec extends BaseSpec {
131
+ readonly kind: 'path';
132
+ readonly d: string;
133
+ /**
134
+ * Bounding-radius hint for atlas tile sizing. Required because parsing
135
+ * `d` to compute bounds is non-trivial outside Skia. Treat as "max
136
+ * distance from origin to any point on the path".
137
+ */
138
+ readonly boundsR: number;
139
+ }
140
+ /** Used exclusively as `ShipSpec.engine`. Not part of the flat `ShapeSpec` union. */
141
+ interface SquareSpec extends BaseSpec {
142
+ readonly kind: 'square';
143
+ readonly size: number;
144
+ }
145
+ /**
146
+ * Composite ship spec per the folio XIIIa 3-element rule:
147
+ * hull + N rect weapons + 1 square engine.
148
+ *
149
+ * Pan-Tvardowski's `visual-spec/ShipDef` will eventually replace direct use
150
+ * of `ShipSpec` with hull-preset references; for now this remains the
151
+ * rendering composite consumed by `drawShip`.
152
+ */
153
+ interface ShipSpec extends BaseSpec {
154
+ readonly kind: 'ship';
155
+ readonly hull: ShapeSpec;
156
+ readonly weapons: readonly RectSpec[];
157
+ readonly engine: SquareSpec;
158
+ }
159
+ type ShapeSpec = CircleSpec | RectSpec | TriangleSpec | NgonSpec | StarSpec | RingSpec | PolylineSpec | GradientRectSpec | ArcSpec | AnnulusSpec | TrapezoidSpec | PathSpec | ShipSpec;
160
+
161
+ /**
162
+ * Shape drawing dispatcher — consumes a `ShapeSpec` and emits Skia draw
163
+ * calls on a canvas. All shapes draw relative to (x + ox, y + oy), rotated
164
+ * by (rot + spec.rot).
165
+ *
166
+ * The dispatcher is allocation-free per call except where Skia itself
167
+ * allocates path objects. Glow ring is emitted before the shape body so it
168
+ * renders behind the geometry.
169
+ */
170
+
171
+ type Skia = typeof Skia$1;
172
+ /** ARGB for safe #6FA66B at α ≈ 0.25 (0x40 / 255). */
173
+ declare function friendlyGlowArgb(): number;
174
+ /** ARGB for hazardOrange #E84B2A at α ≈ 0.6 (0x99 / 255). */
175
+ declare function hazardGlowArgb(): number;
176
+ declare function applyFriendlyGlow(_Skia: Skia, canvas: SkCanvas, paint: SkPaint, cx: number, cy: number, r: number): void;
177
+ declare function applyHazardGlow(_Skia: Skia, canvas: SkCanvas, paint: SkPaint, cx: number, cy: number, r: number): void;
178
+ declare function argbTo(out: Float32Array, argb: number): void;
179
+ declare function drawShape(Skia: Skia, canvas: SkCanvas, paint: SkPaint, spec: ShapeSpec, x: number, y: number, rot: number): void;
180
+
181
+ /**
182
+ * Approximate bounding radius for a single primitive. Used to size glow
183
+ * rings and atlas tiles. Returned values are deliberately a touch generous
184
+ * to avoid clipping.
185
+ */
186
+ declare function singleShapeRadius(spec: ShapeSpec): number;
187
+ /**
188
+ * Compute axis-aligned bounding radius for a shape composition. Used to
189
+ * size atlas tiles. Returns the max half-extent from origin across all
190
+ * shapes (including their `ox`/`oy` offsets and stroke widths).
191
+ */
192
+ declare function shapeBoundsRadius(specs: readonly ShapeSpec[]): number;
193
+
194
+ export { type AnnulusSpec, type ArcSpec, type BaseSpec, type CircleSpec, type GradientRectSpec, type NgonSpec, type PathSpec, type PolylineSpec, type RectSpec, type RingSpec, type ShapeSpec, type ShipSpec, type SquareSpec, type StarSpec, type TrapezoidSpec, type TriangleSpec, applyFriendlyGlow, applyHazardGlow, argbTo, drawShape, friendlyGlowArgb, hazardGlowArgb, shapeBoundsRadius, singleShapeRadius };
@@ -0,0 +1,194 @@
1
+ import { Skia as Skia$1, SkCanvas, SkPaint } from '@shopify/react-native-skia';
2
+
3
+ /**
4
+ * Shape primitive vocabulary. 12 named atomic shapes + 1 SVG escape hatch.
5
+ *
6
+ * Adding a new named primitive requires changes in 4 places:
7
+ * 1. extend the `ShapeSpec` union here
8
+ * 2. add a draw branch in `draw.ts`
9
+ * 3. add a bounds branch in `bounds.ts`
10
+ * 4. add tests in `tests/`
11
+ *
12
+ * Adding an arbitrary shape *without* a new named primitive is data-only:
13
+ * use `{ kind: 'path', d: '<SVG path string>' }`. Skia parses SVG path data
14
+ * natively via `Path.MakeFromSVGString` — same syntax as Figma / Inkscape /
15
+ * `<path d="...">`.
16
+ *
17
+ * All colors are 32-bit ARGB ints (alpha in high byte). Use `argbTo()` from
18
+ * `draw.ts` to feed Skia paints.
19
+ */
20
+ interface BaseSpec {
21
+ readonly fill?: number;
22
+ readonly stroke?: number;
23
+ readonly strokeWidth?: number;
24
+ /** Local offset applied when composing multiple shapes per entity. */
25
+ readonly ox?: number;
26
+ readonly oy?: number;
27
+ /** Local rotation in radians, composed with the entity rotation. */
28
+ readonly rot?: number;
29
+ /**
30
+ * Optional glow tag. When present, `drawShape` emits the corresponding glow
31
+ * ring behind the body geometry.
32
+ *
33
+ * 'friendly' — safe-green rim (player ship, weapon/upgrade pickups)
34
+ * 'hazard' — orange double-stroke (danger cues, enemy bullets)
35
+ */
36
+ readonly glow?: 'friendly' | 'hazard';
37
+ }
38
+ interface CircleSpec extends BaseSpec {
39
+ readonly kind: 'circle';
40
+ readonly r: number;
41
+ }
42
+ interface RectSpec extends BaseSpec {
43
+ readonly kind: 'rect';
44
+ readonly w: number;
45
+ readonly h: number;
46
+ }
47
+ interface TriangleSpec extends BaseSpec {
48
+ readonly kind: 'triangle';
49
+ readonly size: number;
50
+ }
51
+ interface NgonSpec extends BaseSpec {
52
+ readonly kind: 'ngon';
53
+ readonly n: number;
54
+ readonly r: number;
55
+ }
56
+ interface StarSpec extends BaseSpec {
57
+ readonly kind: 'star';
58
+ readonly points: number;
59
+ readonly rOuter: number;
60
+ readonly rInner: number;
61
+ }
62
+ interface RingSpec extends BaseSpec {
63
+ readonly kind: 'ring';
64
+ readonly r: number;
65
+ }
66
+ interface PolylineSpec extends BaseSpec {
67
+ readonly kind: 'polyline';
68
+ readonly points: readonly number[];
69
+ }
70
+ interface GradientRectSpec extends BaseSpec {
71
+ readonly kind: 'gradient-rect';
72
+ readonly w: number;
73
+ readonly h: number;
74
+ readonly colorA: number;
75
+ readonly colorB: number;
76
+ /** 0 = horizontal, 1 = vertical. */
77
+ readonly axis: 0 | 1;
78
+ }
79
+ /**
80
+ * Sector or arc. Angles in radians, 0 = +X axis, increasing CCW.
81
+ *
82
+ * Use cases:
83
+ * - half-circle: startAngle: 0, endAngle: Math.PI, sector: true
84
+ * - 1/4-moon: startAngle: Math.PI*1.5, endAngle: 0, sector: true
85
+ * - 1/8-moon: startAngle: -Math.PI/8, endAngle: Math.PI/8, sector: true
86
+ */
87
+ interface ArcSpec extends BaseSpec {
88
+ readonly kind: 'arc';
89
+ readonly r: number;
90
+ readonly startAngle: number;
91
+ readonly endAngle: number;
92
+ /** Closed wedge (true) or open arc stroke (false). Default false. */
93
+ readonly sector?: boolean;
94
+ }
95
+ /**
96
+ * Annulus (ring with thickness). When `startAngle`+`endAngle` are set,
97
+ * renders a partial annulus (half-donut, quarter-donut, etc.).
98
+ *
99
+ * Implementation note: rendered as a thick stroked circle/arc at the
100
+ * mid-radius with width = `rOuter - rInner`. The `fill` colour is used as
101
+ * the ring colour.
102
+ */
103
+ interface AnnulusSpec extends BaseSpec {
104
+ readonly kind: 'annulus';
105
+ readonly rOuter: number;
106
+ readonly rInner: number;
107
+ /** If set together with `endAngle`, renders a partial annulus. */
108
+ readonly startAngle?: number;
109
+ readonly endAngle?: number;
110
+ }
111
+ /**
112
+ * Trapezoid (4-sided, parallel top and bottom edges). Apex up — `topW` is
113
+ * the narrow edge at -h/2, `botW` is the wide edge at +h/2. Use `rot: Math.PI`
114
+ * to flip apex-down.
115
+ */
116
+ interface TrapezoidSpec extends BaseSpec {
117
+ readonly kind: 'trapezoid';
118
+ readonly topW: number;
119
+ readonly botW: number;
120
+ readonly h: number;
121
+ }
122
+ /**
123
+ * SVG path escape hatch. `d` is the standard SVG path-data string (M, L, C,
124
+ * Q, A, Z, etc.) parsed by `Skia.Path.MakeFromSVGString`. Same syntax as
125
+ * Figma / Inkscape / `<path d="...">`.
126
+ *
127
+ * If the path string is malformed and Skia returns null, the draw call is
128
+ * silently skipped (does not throw).
129
+ */
130
+ interface PathSpec extends BaseSpec {
131
+ readonly kind: 'path';
132
+ readonly d: string;
133
+ /**
134
+ * Bounding-radius hint for atlas tile sizing. Required because parsing
135
+ * `d` to compute bounds is non-trivial outside Skia. Treat as "max
136
+ * distance from origin to any point on the path".
137
+ */
138
+ readonly boundsR: number;
139
+ }
140
+ /** Used exclusively as `ShipSpec.engine`. Not part of the flat `ShapeSpec` union. */
141
+ interface SquareSpec extends BaseSpec {
142
+ readonly kind: 'square';
143
+ readonly size: number;
144
+ }
145
+ /**
146
+ * Composite ship spec per the folio XIIIa 3-element rule:
147
+ * hull + N rect weapons + 1 square engine.
148
+ *
149
+ * Pan-Tvardowski's `visual-spec/ShipDef` will eventually replace direct use
150
+ * of `ShipSpec` with hull-preset references; for now this remains the
151
+ * rendering composite consumed by `drawShip`.
152
+ */
153
+ interface ShipSpec extends BaseSpec {
154
+ readonly kind: 'ship';
155
+ readonly hull: ShapeSpec;
156
+ readonly weapons: readonly RectSpec[];
157
+ readonly engine: SquareSpec;
158
+ }
159
+ type ShapeSpec = CircleSpec | RectSpec | TriangleSpec | NgonSpec | StarSpec | RingSpec | PolylineSpec | GradientRectSpec | ArcSpec | AnnulusSpec | TrapezoidSpec | PathSpec | ShipSpec;
160
+
161
+ /**
162
+ * Shape drawing dispatcher — consumes a `ShapeSpec` and emits Skia draw
163
+ * calls on a canvas. All shapes draw relative to (x + ox, y + oy), rotated
164
+ * by (rot + spec.rot).
165
+ *
166
+ * The dispatcher is allocation-free per call except where Skia itself
167
+ * allocates path objects. Glow ring is emitted before the shape body so it
168
+ * renders behind the geometry.
169
+ */
170
+
171
+ type Skia = typeof Skia$1;
172
+ /** ARGB for safe #6FA66B at α ≈ 0.25 (0x40 / 255). */
173
+ declare function friendlyGlowArgb(): number;
174
+ /** ARGB for hazardOrange #E84B2A at α ≈ 0.6 (0x99 / 255). */
175
+ declare function hazardGlowArgb(): number;
176
+ declare function applyFriendlyGlow(_Skia: Skia, canvas: SkCanvas, paint: SkPaint, cx: number, cy: number, r: number): void;
177
+ declare function applyHazardGlow(_Skia: Skia, canvas: SkCanvas, paint: SkPaint, cx: number, cy: number, r: number): void;
178
+ declare function argbTo(out: Float32Array, argb: number): void;
179
+ declare function drawShape(Skia: Skia, canvas: SkCanvas, paint: SkPaint, spec: ShapeSpec, x: number, y: number, rot: number): void;
180
+
181
+ /**
182
+ * Approximate bounding radius for a single primitive. Used to size glow
183
+ * rings and atlas tiles. Returned values are deliberately a touch generous
184
+ * to avoid clipping.
185
+ */
186
+ declare function singleShapeRadius(spec: ShapeSpec): number;
187
+ /**
188
+ * Compute axis-aligned bounding radius for a shape composition. Used to
189
+ * size atlas tiles. Returns the max half-extent from origin across all
190
+ * shapes (including their `ox`/`oy` offsets and stroke widths).
191
+ */
192
+ declare function shapeBoundsRadius(specs: readonly ShapeSpec[]): number;
193
+
194
+ export { type AnnulusSpec, type ArcSpec, type BaseSpec, type CircleSpec, type GradientRectSpec, type NgonSpec, type PathSpec, type PolylineSpec, type RectSpec, type RingSpec, type ShapeSpec, type ShipSpec, type SquareSpec, type StarSpec, type TrapezoidSpec, type TriangleSpec, applyFriendlyGlow, applyHazardGlow, argbTo, drawShape, friendlyGlowArgb, hazardGlowArgb, shapeBoundsRadius, singleShapeRadius };