Skip to content

feat(background): add pixel_grid, a configurable lattice of square cells - #204

Merged
LeadcodeDev merged 1 commit into
mainfrom
feat/pixel-grid-background
Aug 12, 2026
Merged

feat(background): add pixel_grid, a configurable lattice of square cells#204
LeadcodeDev merged 1 commit into
mainfrom
feat/pixel-grid-background

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

What

grid_dots draws circles on a fixed lattice with a built-in pulse. There was no way to get a field of square tiles, to control how many of them appear, or to make the density vary across the frame — so reproducing a reference piece's texture meant settling for even dots where the reference has a scatter that thickens toward one edge.

pixel_grid covers two looks with one shape:

  • sparse tile field — one colour, density under 1, cells scattered;
  • checkerboard — two colours at density: 1.0, alternating by (col + row).
{ "preset": "pixel_grid", "speed": 1.0, "pixel_grid": {
    "colors": ["#FFFFFF26"], "size": 9, "spacing": 22,
    "density": 0.75, "density_ramp": "right", "radius": 1,
    "seed": 7, "motion": "none"
} }

Design decisions worth reviewing

  • Occupancy is a hash of (col, row, seed), not a random draw. The same cell has to resolve the same way on every frame or the field boils instead of holding still, and two renders of one scenario must match. seed is an input rather than process state for the same reason.
  • spacing is clamped to size. A smaller pitch draws a solid sheet and silently loses the lattice the preset exists for — better to clamp than to honour a value that erases the effect.
  • density_ramp exists because a uniform scatter reads as noise. The reference thickens toward one edge; that ramp is what makes it read as a texture.
  • tile_spacing reports the pitch, so a world view's camera wraps on it and the tiling stays seamless under a pan.

Tests

Six, no rendering needed except the degenerate-input one:

  • a cell resolves identically on repeated calls, in 0..1
  • two seeds actually scatter differently — otherwise seed is a lie
  • diagonal neighbours are uncorrelated (a hash walking with the coordinate draws stripes; the test fails outside 300–600 agreements in 900 cells)
  • each ramp runs the direction it names, radial full at the centre and zero at the corners, none uniform including at the edges
  • the spacing clamp
  • empty palette, zero size and density: 5.0 stay inert rather than panicking

Docs

SKILL.md gains the preset, its field table, and the two recipes.

cargo test --workspace green, cargo fmt --check and cargo clippy --all-targets -- -D warnings clean.

grid_dots draws circles on a fixed lattice with a built-in pulse — there was
no way to get a field of square tiles, to control how many of them appear, or
to make the density vary across the frame. Reproducing a reference piece's
texture with it meant settling for regular dots where the reference has a
scatter that thickens toward one edge.

pixel_grid covers two looks with one shape: one colour under density 1 gives a
sparse tile field; two colours at density 1.0 alternate by (col + row) and give
a real checkerboard.

Occupancy is a hash of (col, row, seed), not a random draw — the same cell must
resolve the same way on every frame or the whole field boils, and two renders
of one scenario have to match. `spacing` is clamped to `size`: a smaller pitch
would draw a solid sheet and silently lose the lattice the preset exists for.
`tile_spacing` reports the pitch so a world view's camera can wrap on it.

Six tests: cell stability, seed actually scattering, neighbours uncorrelated
(a hash that walks with the coordinate draws stripes, not a scatter), each
ramp running the direction it names, the spacing clamp, and degenerate configs
staying inert rather than panicking.
@LeadcodeDev LeadcodeDev added the enhancement New feature or request label Aug 12, 2026
@LeadcodeDev LeadcodeDev self-assigned this Aug 12, 2026
@LeadcodeDev
LeadcodeDev merged commit ffe7ec0 into main Aug 12, 2026
3 checks passed
@LeadcodeDev
LeadcodeDev deleted the feat/pixel-grid-background branch August 12, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant