Add image atlas and nine-slice support

This commit is contained in:
gem
2026-06-09 12:30:44 +08:00
parent 409942b4af
commit e2a584d4dc
12 changed files with 453 additions and 24 deletions

View File

@@ -54,6 +54,21 @@ Text-capable nodes may use flat shadow fields:
The shadow color alpha is multiplied by `RuntimeNode.alpha` and any runtime animation alpha.
### Image regions and nine-slice
Image-capable nodes (`image`, `sprite`, and image-backed `button`) may draw only part of an asset by setting source region fields in image pixels:
- `sourceX` / `sourceY`: top-left source position inside the loaded image.
- `sourceWidth` / `sourceHeight`: source region size.
When source fields are omitted, the full image is used. This supports atlas-style usage where multiple sprites are packed into one image and nodes reference different source rectangles.
Image-capable nodes may also use nine-slice scaling with source-pixel insets:
- `sliceLeft` / `sliceTop` / `sliceRight` / `sliceBottom`.
Nine-slice keeps corners unscaled, stretches edges on one axis, and stretches the center on both axes. Insets are clamped to the selected source region and destination size.
## RuntimeCommand
Runtime commands request generic side effects owned by Dart/Flame.