docs: migrate README to API-Doc-Convention (S2-cascade.libs)
Restructured per ADR-0038: Abstract + bold-list Badges + Topology H2 + H3-API-Subsections (one per public function) + Conventions/Consumer pattern/CHANGELOG/References. Topology auto-populated via Sporel.exe --lint --fix. Pre-commit hook installed via --install-hooks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
77
README.md
77
README.md
@@ -1,30 +1,71 @@
|
||||
# lib-core.render
|
||||
|
||||
P.0 colored-quad tile-grid renderer. Reads `lib-core.maps`'s current map +
|
||||
its tilemap, iterates tiles, draws a colored rect per tile via
|
||||
`engine.render.draw_rect`. Fallback to magenta `[255, 0, 255]` for tiles
|
||||
with missing/malformed color.
|
||||
Colored-quad tile-grid renderer. Reads `lib-core.maps`'s current (or specified) map + its tilemap, iterates tiles, draws one colored rect per tile via `engine.render.draw_rect`. Fallback to magenta `[255, 0, 255]` for tiles with missing or malformed color.
|
||||
|
||||
- Lib-ID: `lib-core.render`
|
||||
- Version: `0.1.0`
|
||||
- Spec: `meta/docs/superpowers/specs/2026-05-09-p0-lib-render-design.md`
|
||||
**Version:** 0.1.0
|
||||
**Lib-ID:** lib-core.render
|
||||
**Requires:** lib-core.maps v>=0.1.1
|
||||
**Tags:** render, tiles, draw, colored-quads
|
||||
|
||||
Forward-compat stubs (DEPRECATED-MVP) for texture-rendering,
|
||||
PROTOTYPE-Lib-Pattern, camera, layers, post-processing, parallax,
|
||||
shaders, hot-reload. See `meta/docs/architecture/render-pipeline.md`
|
||||
for the full target spec (941 lines).
|
||||
## Topology
|
||||
|
||||
<!-- topology:start (auto-generated; do not edit) -->
|
||||
```mermaid
|
||||
graph LR
|
||||
this["lib-core.render"]
|
||||
lib_core_maps["lib-core.maps"]
|
||||
this --> lib_core_maps
|
||||
engine["engine.*"]
|
||||
this --> engine
|
||||
```
|
||||
<!-- topology:end -->
|
||||
|
||||
## API
|
||||
- `r_lib.draw_map(map_id?)` — iterates current (or specified) map's tiles,
|
||||
draws colored rect per tile. Must be called inside a render hook.
|
||||
Returns count of tiles drawn.
|
||||
|
||||
## Consumer pattern
|
||||
### `render.draw_map(map_id)`
|
||||
**Syntax:** `render.draw_map(map_id: string | nil) -> integer`
|
||||
|
||||
**Example:**
|
||||
```lua
|
||||
local maps = require("lib-core.maps")
|
||||
local r_lib = require("lib-core.render")
|
||||
function render(ctx)
|
||||
engine.render.clear_color(engine.render.rgb(20, 20, 30))
|
||||
r_lib.draw_map()
|
||||
local n = render.draw_map() -- uses current-map
|
||||
end
|
||||
```
|
||||
|
||||
**Description:** Iterates the tiles of the specified map (or current-map when nil), drawing one colored rect per tile at `(tx * tile_size, ty * tile_size)`. Tile color is read from the tilemap's `tile.color = {r, g, b}`; if missing or malformed, falls back to magenta as a visible "missing-color" debug-marker. Must be called from inside a render hook. Returns the number of tiles drawn (for smoke verification + debug).
|
||||
|
||||
## Conventions
|
||||
|
||||
- Colored-quads only in v0.1.0. Texture-rendering, multi-layer composition, post-processing, parallax, shaders, hot-reload all DEPRECATED-MVP.
|
||||
- World-space coords; pair with `lib-core.camera` to support panning + zoom.
|
||||
- Magenta fallback `[255, 0, 255]` is intentional: high-visibility debug-marker for malformed color-data.
|
||||
- Y-down-positive per ADR-0031.
|
||||
|
||||
## Consumer pattern
|
||||
|
||||
```lua
|
||||
local maps = require("lib-core.maps")
|
||||
local render = require("lib-core.render")
|
||||
local camera = require("lib-core.camera")
|
||||
|
||||
function render_fn(ctx)
|
||||
engine.render.clear_color(engine.render.rgb(20, 20, 30))
|
||||
camera.begin()
|
||||
render.draw_map()
|
||||
camera.finish()
|
||||
end
|
||||
```
|
||||
|
||||
## CHANGELOG
|
||||
|
||||
### v0.1.0 (P.0)
|
||||
- Initial release: `draw_map` colored-quad iterator.
|
||||
|
||||
## References
|
||||
|
||||
- Spec v0.1.0 (P.0): `meta/docs/superpowers/specs/2026-05-09-p0-lib-render-design.md`
|
||||
- Architecture: `meta/docs/architecture/render-pipeline.md`
|
||||
- ADR-0001 (engine knows verbs, libs bring nouns)
|
||||
- ADR-0031 (pixel-convention: Y-down-positive)
|
||||
- ADR-0038 (API-Doc-Convention)
|
||||
|
||||
Reference in New Issue
Block a user