feat(background): add pixel_grid, a configurable lattice of square cells - #204
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
grid_dotsdraws 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_gridcovers two looks with one shape:densityunder 1, cells scattered;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
(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.seedis an input rather than process state for the same reason.spacingis clamped tosize. 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_rampexists because a uniform scatter reads as noise. The reference thickens toward one edge; that ramp is what makes it read as a texture.tile_spacingreports the pitch, so aworldview's camera wraps on it and the tiling stays seamless under a pan.Tests
Six, no rendering needed except the degenerate-input one:
0..1seedis a lieradialfull at the centre and zero at the corners,noneuniform including at the edgesdensity: 5.0stay inert rather than panickingDocs
SKILL.mdgains the preset, its field table, and the two recipes.cargo test --workspacegreen,cargo fmt --checkandcargo clippy --all-targets -- -D warningsclean.