hitbox-tool: per-frame collision boxes from sprite sheet alpha -> JSON

- parses the spritec _WxH_CxR naming convention incl. auto-detection of
  integer-upscaled sheets (256x64 named 8x8_4x1 -> 64x64 cells)
- tight alpha bbox per frame with threshold/shrink/pad tuning, row-major
  indices, empty-frame flags; boxes relative to frame origin
- show command draws frames + box outline in the terminal for verification
- go tests: scanning, threshold, shrink/pad clamping, name parsing,
  scale inference, JSON roundtrip

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmdG9GqfSWCzts7AkDwRDh
This commit is contained in:
2026-07-14 07:12:05 +02:00
parent dc78c791df
commit f8924d89f7
7 changed files with 698 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
{
"image": "examples/walk_8x8_4x1.png",
"cellW": 64,
"cellH": 64,
"cols": 4,
"rows": 1,
"alphaThreshold": 1,
"frames": [
{
"index": 0,
"col": 0,
"row": 0,
"empty": false,
"box": {
"x": 8,
"y": 0,
"w": 40,
"h": 64
}
},
{
"index": 1,
"col": 1,
"row": 0,
"empty": false,
"box": {
"x": 8,
"y": 0,
"w": 40,
"h": 64
}
},
{
"index": 2,
"col": 2,
"row": 0,
"empty": false,
"box": {
"x": 8,
"y": 0,
"w": 40,
"h": 64
}
},
{
"index": 3,
"col": 3,
"row": 0,
"empty": false,
"box": {
"x": 8,
"y": 0,
"w": 40,
"h": 64
}
}
]
}