feat(assets): #81 namespaced spritesheet/atlas API (Sprite.* / Assets.*)
Sprite loading was a bare png_load — one file per 16x16 sprite, no way to load one sheet and address a cell by grid coords or name. Adds a Sprite.*/Assets.* runtime (atlas.ludic) over the variable-size image loader, so a cell is a sub-rect of the kept image and is NOT restricted to the 16x16 sprite table: Sprite.sheet(path,cw,ch), Sprite.cell(sheet,col,row), Sprite.cell_span(sheet,col,row,cols,rows) (a sprite may span >1 cell), Sprite.define/named (name + lookup), Sprite.draw/draw_scaled (through camera/zoom/clip like Screen.sprite), Sprite.width/height, and Assets.image/load/get. Spliced on demand (Sprite.sheet/… or Assets.*), so a program using neither is byte-identical. Example examples/library/atlas.ludic (verified against a real 12x11 Kenney sheet, incl. a 2x3 multi-cell span and named lookup). 14 docs pages. Full suite 114/0, goldens byte-identical, fixpoint holds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ab4546e365
commit
f3f1336882
21 changed files with 34542 additions and 32915 deletions
7
docs/language/assets/_section.md
Normal file
7
docs/language/assets/_section.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
id: assets
|
||||
title: Assets
|
||||
order: 34
|
||||
---
|
||||
|
||||
Loading and lookup for whole-file assets, paired with the <a href="sprite-sheet"><code>Sprite.*</code></a> atlas API. <a href="assets-image"><code>Assets.image</code></a> (and its alias <a href="assets-load"><code>Assets.load</code></a>) loads a whole image file as one sprite; <a href="assets-get"><code>Assets.get</code></a> looks a named sprite up.
|
||||
14
docs/language/assets/assets-get.md
Normal file
14
docs/language/assets/assets-get.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: assets-get
|
||||
name: Assets.get
|
||||
category: assets
|
||||
kind: namespace-method
|
||||
tokens: Assets.get
|
||||
sig: Assets.get(name) -> int
|
||||
tip: Look up a named sprite's id (alias of Sprite.named).
|
||||
order: 3
|
||||
ns: Assets
|
||||
member: get
|
||||
---
|
||||
|
||||
Alias of <a href="sprite-named"><code>Sprite.named</code></a>: returns the sprite id registered under <code>name</code>, or <code>-1</code>.
|
||||
14
docs/language/assets/assets-image.md
Normal file
14
docs/language/assets/assets-image.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: assets-image
|
||||
name: Assets.image
|
||||
category: assets
|
||||
kind: namespace-method
|
||||
tokens: Assets.image
|
||||
sig: Assets.image(path) -> int
|
||||
tip: Load a whole image file as one sprite; returns its id.
|
||||
order: 1
|
||||
ns: Assets
|
||||
member: image
|
||||
---
|
||||
|
||||
Loads the image at <code>path</code> as a single atlas sprite the size of the image, returning its id — the namespaced replacement for a bare <code>png_load</code>. Draw it with <a href="sprite-draw"><code>Sprite.draw</code></a>.
|
||||
14
docs/language/assets/assets-load.md
Normal file
14
docs/language/assets/assets-load.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: assets-load
|
||||
name: Assets.load
|
||||
category: assets
|
||||
kind: namespace-method
|
||||
tokens: Assets.load
|
||||
sig: Assets.load(path) -> int
|
||||
tip: Alias of Assets.image.
|
||||
order: 2
|
||||
ns: Assets
|
||||
member: load
|
||||
---
|
||||
|
||||
Alias of <a href="assets-image"><code>Assets.image</code></a>: loads a whole image file as one sprite and returns its id.
|
||||
Loading…
Add table
Add a link
Reference in a new issue