diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 0000000..1ebdad0 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,13 @@ +#!/bin/sh +# Sporel API-Doc-Convention pre-commit hook. +SPOREL_EXE="${SPOREL_EXE:-$(command -v Sporel.exe 2>/dev/null || command -v sporel 2>/dev/null)}" +if [ -z "$SPOREL_EXE" ]; then + echo "INFO: Sporel.exe not on PATH. Skipping lint." >&2 + exit 0 +fi +"$SPOREL_EXE" --lint="$(pwd)" --fix +RC=$? +if git diff --cached --name-only | grep -qx 'README.md'; then + git add README.md +fi +exit $RC diff --git a/README.md b/README.md index 3bd1f6d..7367502 100644 --- a/README.md +++ b/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 + + +```mermaid +graph LR + this["lib-core.render"] + lib_core_maps["lib-core.maps"] + this --> lib_core_maps + engine["engine.*"] + this --> engine +``` + ## 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) diff --git a/scripts/install-hooks.sh b/scripts/install-hooks.sh new file mode 100644 index 0000000..2ff6e41 --- /dev/null +++ b/scripts/install-hooks.sh @@ -0,0 +1,3 @@ +#!/bin/sh +git config core.hooksPath .githooks +echo "Hooks activated."