Skip to content

Add UI 9-slice sprite kit for redesign (T7) - #796

Open
Shombith03 wants to merge 1 commit into
bleeding-edgefrom
claude/9-slice-sprite-kit-tp0g7t
Open

Add UI 9-slice sprite kit for redesign (T7)#796
Shombith03 wants to merge 1 commit into
bleeding-edgefrom
claude/9-slice-sprite-kit-tp0g7t

Conversation

@Shombith03

Copy link
Copy Markdown
Collaborator

Summary

Implements the component sprite kit for the UI redesign (task T7), delivering 26 white+alpha 9-slice sprites with procedurally-generated PNG assets, metadata, and a test scene. All sprites are authored from a declarative geometry table, enabling verification that shipped assets match the specification exactly.

Key Changes

  • Sprite authoring pipeline: Three Python tools that generate and verify the sprite kit:

    • author_ui_sprite_kit.py: Main entry point; generates PNG assets and .meta files from the KIT table
    • ui_sprite_kit_geometry.py: Pure-stdlib geometry engine and PNG codec; computes corner slivers (45° diagonal cuts on opposite corners per Style Foundation §5) and encodes RGBA pixels
    • verify_ui_sprite_kit.py: Post-generation verification; proves each PNG is white+alpha, validates spriteBorder metadata, and confirms partially-transparent pixels lie strictly inside border corners (the invariant that makes 9-slice scaling preserve diagonals)
  • 26 generated sprite assets under Assets/_Graphics/UI/SpriteKit/:

    • Banner, Button, ButtonSmall, Card, CurrencyPill, HexHandle, HexTile, Panel families
    • Fill and Border variants; Border variants include flipped versions for corner sliver orientation
    • All RGB 255,255,255 with shape carried entirely in alpha (enables runtime tinting from UIThemeSO)
  • Test scene Assets/_Scenes/Game_TestDesign/UISpriteKitTestScene.unity:

    • One full-screen page per sprite family; page 1 active, rest inactive (toggle in Hierarchy)
    • Each row displays one sprite at three widths (plus fourth sample at double height for vertical-border sprites)
    • Each sample tinted a different Style Foundation Sec.2 colour to demonstrate the asset carries no colour
  • Documentation Docs/UI_SPRITE_KIT.md: Overview, usage, and verification instructions

Implementation Details

  • No hand-edited pixels or YAML: Everything derives from the KIT table in author_ui_sprite_kit.py, so --check mode can prove committed files are exactly what the table specifies
  • Coordinate system: Pixel space, x right, y DOWN from top-left (matching PNG row order); Unity sprite borders are {x=left, y=bottom, z=right, w=top}
  • Corner sliver geometry: 45° diagonal cuts on TWO OPPOSITE corners per Style Foundation v0.3.1 §5 (supersedes earlier single-chamfer shapes in shipped Button_Flat_*.png)
  • No new C# code: Scene is entirely declarative UGUI, keeping it outside the /verify-unity compile gate
  • Standard library only: Authoring tools use only Python stdlib for reproducibility across build machines, CI, and designer laptops

Spec References

  • Style Foundation §5 (geometry) and §10 (components)
  • Docs/UI_REDESIGN_TASKS.md task T7

https://claude.ai/code/session_01H4Lq17kBtCJ2LbQGQ8ikfw

26 white+alpha 9-slice sprites under Assets/_Graphics/UI/SpriteKit/ implementing
Style Foundation §5's corner sliver — a 45° diagonal cut on two opposite corners,
flippable — across the §10 components: buttons (two sliver sizes × two
orientations, fill and 1px frame), panel/popup, card, currency pill, hexagon tile,
hexagon slider handle, and the §10.9 angled banner with its triangular end caps.

No colour is baked: every pixel is RGB 255,255,255 with the shape entirely in
alpha, so one asset serves every state under an Image.color tint from UIThemeSO
(T4). No shipping prefab or scene is touched.

The 9-slice border is measured off the rasterised shape, not chosen. A slice is
exact when every column it stretches is identical to its neighbours; the nominal
sliver is the right inset for a filled shape and too small for an outlined one,
because eroding the polygon pushes the mitre past the sliver line by
stroke × (√2 − 1). Authored at the nominal, every outline variant leaked
antialiased pixels into a stretched region.

Assets and the test scene are generated from one table, so --check covers both:

  Tools/Build/ui_sprite_kit_geometry.py  convex geometry, exact coverage, PNG
                                         codec, measure_border
  Tools/Build/author_ui_sprite_kit.py    the kit table; --check, --table
  Tools/Build/ui_sprite_kit_scene.py     test scene YAML
  Tools/Build/verify_ui_sprite_kit.py    proves the shipped bytes

verify reports 26/26 at maxdiff 0/255: each shipped sprite, 9-sliced to a target
size, is byte-identical to the same geometry rasterised natively at that size —
at the minimum legal size, 1:1, 3× wide, 409 wide, and at double height where the
sprite carries vertical insets.

Test scene: Assets/_Scenes/Game_TestDesign/UISpriteKitTestScene.unity, five pages,
each row one sprite at three widths (plus double height), each sample a different
§2 tint. Declarative UGUI, no new C#. Not in Build Settings.

Reference: Docs/UI_SPRITE_KIT.md. Four design questions filed as queue #10-#13.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4Lq17kBtCJ2LbQGQ8ikfw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants