castle-web-cli 0.4.115 → 0.4.116
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/agent-prompts.js +2 -2
- package/dist/agent.d.ts +9 -9
- package/dist/agent.js +590 -589
- package/dist/castleJson.d.ts +6 -0
- package/dist/castleJson.js +10 -0
- package/dist/editorConfig.js +27 -3
- package/dist/imports.d.ts +4 -0
- package/dist/imports.js +59 -10
- package/dist/init.d.ts +3 -0
- package/dist/init.js +99 -87
- package/dist/install.d.ts +1 -1
- package/dist/install.js +26 -24
- package/dist/shell/assets/{index-CUamb8rK.js → index-DiPlPGyg.js} +2 -2
- package/dist/shell/index.html +1 -1
- package/dist/vitePlugins.js +1 -1
- package/kits/physics-2d/CLAUDE.md +28 -16
- package/kits/physics-2d/behaviors/Joints.jsx +1 -1
- package/kits/physics-2d/behaviors/Sprite.jsx +17 -12
- package/kits/physics-2d/blueprints/ball.scene +1 -1
- package/kits/physics-2d/blueprints/block.scene +1 -1
- package/kits/physics-2d/blueprints/cauldron.scene +1 -1
- package/kits/physics-2d/blueprints/crate.scene +1 -1
- package/kits/physics-2d/castle.json +11 -3
- package/kits/physics-2d/docs/pxart-format.md +537 -51
- package/kits/physics-2d/editors/PxArtEditor.jsx +1794 -65
- package/kits/physics-2d/editors/brushFit.js +535 -0
- package/kits/physics-2d/editors/brushShapes.js +140 -0
- package/kits/physics-2d/editors/mediaFile.js +12 -1
- package/kits/physics-2d/editors/pathOverlay.js +340 -0
- package/kits/physics-2d/editors/pathTools.js +1906 -0
- package/kits/physics-2d/editors/pixelCanvas.js +13 -0
- package/kits/physics-2d/editors/pixelEditorChrome.jsx +2 -2
- package/kits/physics-2d/editors/pixelGeometry.js +4 -2
- package/kits/physics-2d/editors/pixelInspector.jsx +410 -37
- package/kits/physics-2d/editors/pxArtEditorModel.js +172 -16
- package/kits/physics-2d/editors/pxArtTimeline.jsx +163 -43
- package/kits/physics-2d/editors/pxArtTimeline.module.css +31 -5
- package/kits/physics-2d/engine/assets.js +1 -1
- package/kits/physics-2d/engine/blueprint.js +3 -3
- package/kits/physics-2d/engine/files.js +3 -1
- package/kits/physics-2d/engine/liveReload.js +1 -1
- package/kits/physics-2d/engine/physics/jointArt.js +3 -3
- package/kits/physics-2d/engine/pxart.js +153 -35
- package/kits/physics-2d/engine/pxartPath.js +1356 -0
- package/kits/physics-2d/engine/pxartSmooth.js +276 -125
- package/kits/physics-2d/engine/ui.jsx +22 -1
- package/kits/physics-2d/engine/ui.module.css +36 -12
- package/kits/physics-2d/package-lock.json +1 -1
- package/kits/physics-2d/scripts/draw.mjs +7 -7
- package/kits/physics-2d/scripts/import-svg.mjs +1231 -0
- package/kits/physics-2d/scripts/svg-emission-guide.md +92 -0
- package/package.json +1 -1
- /package/kits/physics-2d/drawings/{block.pxart → block.sprite} +0 -0
- /package/kits/physics-2d/drawings/{cauldron.pxart → cauldron.sprite} +0 -0
- /package/kits/physics-2d/drawings/{joint-rope.pxart → joint-rope.sprite} +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
## Path-layer sprites (SVG paths → stacked path-layer `.sprite`)
|
|
2
|
+
|
|
3
|
+
Emit a tiny vector SVG — silhouette-first shapes on a design grid — and pipe it
|
|
4
|
+
to `node scripts/import-svg.mjs <name>`. The importer turns each SVG element into
|
|
5
|
+
one **shape** in document order (painter's order). Coordinates are stored as
|
|
6
|
+
floats in cubic segment form (`{ closed, start, segs: [{ to, c1?, c2? }] }`).
|
|
7
|
+
The layer's `grid` is always baked from the shape stack on write — pixels remain
|
|
8
|
+
truth.
|
|
9
|
+
|
|
10
|
+
> The legacy extension `.pxart` names the same format and remains readable; emit
|
|
11
|
+
> and create new art as `.sprite`.
|
|
12
|
+
|
|
13
|
+
- **Resolution is 16×16.** Use `viewBox="0 0 16 16"`. Coordinates are in that
|
|
14
|
+
design grid (pixel corners at integers, centers at `n+0.5`). Prefer a modest
|
|
15
|
+
anchor count; curves are cheap (a `C` segment is still just its two endpoint
|
|
16
|
+
anchors) — what to avoid is tracing detail with many tiny segments.
|
|
17
|
+
- **Palette is the agent 16-color subset** — every `fill` / `stroke` should be
|
|
18
|
+
one of:
|
|
19
|
+
|
|
20
|
+
`#e69c69` `#bf6f4a` `#8a4836` `#391f21` `#891e2b` `#ea323c` `#ffa214` `#ffeb57`
|
|
21
|
+
`#5ac54f` `#1e6f50` `#134c4c` `#657392` `#c7cfdd` `#ffffff` `#0cf1ff` `#0098dc`
|
|
22
|
+
|
|
23
|
+
(Off-palette colors snap to the nearest of these. Prefer staying on-palette.)
|
|
24
|
+
- **Curves are encouraged — use them for anything organic.** Bodies, leaves,
|
|
25
|
+
canopies, bellies, petals: use `C`/`Q`/`A` path segments (or a `circle`/`ellipse`).
|
|
26
|
+
A curve segment costs only its two anchors. Reserve straight-line polygons for
|
|
27
|
+
genuinely hard-edged subjects (blades, boxes, buildings). Curves import as cubic
|
|
28
|
+
segments with relative handles; S-curves split at inflections automatically.
|
|
29
|
+
Circles and ellipses materialize as four kappa cubics.
|
|
30
|
+
- **Supported elements:** `<path d>`, `<polygon points>`, `<polyline points>`,
|
|
31
|
+
`<rect>` (rx/ry ignored), `<circle>`, `<ellipse>`, plain `<g>` (grouping only).
|
|
32
|
+
- **Supported path commands:** `M L H V Q C A Z` (absolute and relative). Smooth
|
|
33
|
+
`S`/`T` are accepted (normalized to `C`/`Q`). Arcs (`A`/`a`) split into ≤90°
|
|
34
|
+
cubic segments.
|
|
35
|
+
- **Presentation:** `fill` and `stroke` as attributes or in `style` — when both
|
|
36
|
+
are present, inline `style` wins (SVG spec). Use `fill="none"` for unfilled
|
|
37
|
+
outlines. Strokes are always 1px after import — ignore `stroke-width` / opacity
|
|
38
|
+
/ filters. Stroke is per-shape (whole outline or none) — not per segment.
|
|
39
|
+
- **Fill rule:** Castle renders multi-subpath fills with **even-odd** winding.
|
|
40
|
+
SVG defaults to nonzero. For holes and compound silhouettes, emit
|
|
41
|
+
`fill-rule="evenodd"` (or structure art so even-odd matches your intent).
|
|
42
|
+
Importer notes warn when multiple closed subpaths arrive without an explicit
|
|
43
|
+
even-odd rule.
|
|
44
|
+
- **Optional dark outline:** a 1px stroke in `#391f21` (or another dark agent
|
|
45
|
+
color) around a filled silhouette reads well at 16×16.
|
|
46
|
+
- **Overlap and occlusion are native.** Later shapes paint over earlier ones
|
|
47
|
+
(fill then stroke within each shape). Same-color stacks union visually; later
|
|
48
|
+
fills correctly hide earlier strokes. You do **not** need to merge same-color
|
|
49
|
+
blobs or avoid stroking stretches that will be covered.
|
|
50
|
+
- **Underlap idiom.** Build art as a ground shape plus overlays that extend
|
|
51
|
+
generously underneath. A shared boundary should be owned by the **top** shape.
|
|
52
|
+
Avoid stroking both of two abutting shapes along a shared seam — that
|
|
53
|
+
double-strokes the seam and looks thicker than intended. Prefer: bottom shape
|
|
54
|
+
fill (optional stroke on its outer silhouette only); top shape fill that
|
|
55
|
+
overlaps the seam; stroke only the top shape's visible outline when needed.
|
|
56
|
+
- **Fill vs stroke phase.** Storage accepts floats — no lattice snap at import.
|
|
57
|
+
Fill-only shapes may use integer corners freely. Stroked shapes with any
|
|
58
|
+
integer-phase coordinate get a uniform +0.05 cell nudge so 1px strokes avoid
|
|
59
|
+
bad rasterization at pixel corners; fill-only shapes are not nudged. The
|
|
60
|
+
half-cell magnetic lattice is an **editor-only** guide (§6.1.2), not enforced
|
|
61
|
+
on import.
|
|
62
|
+
- **Minimum feature size is one cell at 16×16.** Draw eyes and dots as a
|
|
63
|
+
1×1 `<rect>` on a whole cell (or a circle with `r ≥ 0.8` centered on a
|
|
64
|
+
pixel center — coordinates like `5.5`), never tiny sub-cell circles. A
|
|
65
|
+
two-tone detail (eye + pupil) needs at least 2 cells or it cannot survive.
|
|
66
|
+
Keep enclosed shapes at least ~2 cells across their narrow axis.
|
|
67
|
+
- **Do not emit:** `transform` attributes, transformed `<g>`, gradients,
|
|
68
|
+
`<text>`, `<image>`, or anything outside the subset above.
|
|
69
|
+
|
|
70
|
+
**Run it** (sprite name as the arg; stdin is the svg):
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
printf '<svg viewBox="0 0 16 16"><circle cx="8" cy="8" r="5" fill="#5ac54f" stroke="#391f21"/></svg>' \
|
|
74
|
+
| node scripts/import-svg.mjs blob
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
writes `drawings/blob.sprite`. You can also pass `--from file.svg` instead of
|
|
78
|
+
stdin. Use `--size 32` only when you intentionally author a 32×32 viewBox.
|
|
79
|
+
Use `--pixel` to bake to a compact pixel-only `.sprite` (no path source).
|
|
80
|
+
|
|
81
|
+
A curvy silhouette with an overlay accent (later shape covers earlier stroke):
|
|
82
|
+
|
|
83
|
+
```xml
|
|
84
|
+
<svg viewBox="0 0 16 16">
|
|
85
|
+
<path d="M 3 13 C 3 7 6 3 13 3 C 13 9 10 13 3 13 Z"
|
|
86
|
+
fill="#5ac54f" stroke="#1e6f50"/>
|
|
87
|
+
<circle cx="6" cy="7" r="1.2" fill="#391f21"/>
|
|
88
|
+
</svg>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**After writing new sprites referenced by the scene, `npm run restart`** so the
|
|
92
|
+
deck's file glob picks them up.
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|