Repository navigation
ritmo-tools pixel: one-pixel outlines, bent grids, a shrink that keeps strokes - #179
Merged
Merged
Conversation
…s strokes After ToPixel (https://github.com/daisuqe/ToPixel): - Outlines (recipe `outlines`, --outlines, on by "auto" when the dark strokes are about one cell wide): a stroke split between two pixels goes back to one, guarded so outlines, corners, and stroke ends never break; followed lines keep off dark strokes. - Follow lines is "off" | "straight" | "bend": straight places every cut at once (dynamic programming) instead of one after another; bend places them in each row and column of cells, for warped grids. - Keep outlines when shrinking carries strokes over, thins them without breaking, and turns one-pixel steps into diagonals. Breaking: a recipe's `follow` is "off" | "straight" | "bend", not a boolean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Ideas taken from ToPixel (https://github.com/daisuqe/ToPixel), a one-file browser tool that turns upscaled pixel art back into 1 dot = 1 px. That repository has no license, so this PR takes the ideas only and rewrites the code to fit the fixer's pipeline. Its sample image was used for local evaluation only and is not committed.
What changes
Outlines (recipe
outlines: "auto" | "on" | "off",--outlines, Outlines on the page; default"auto"). When the picture's dark strokes are about one cell wide, a stroke that a grid line split between two pixels goes back to one pixel, and followed lines keep off dark strokes. On top of ToPixel's rule there are three guards, each added after it broke the reference sprites in testing:The report's
grid.outlinessays whether it ran.Follow lines is now
"off" | "straight" | "bend":straightplaces every cut at once with dynamic programming: each cut on an edge, every gap near the cell size, and the cell count kept. Before, each cut was placed one after another.bendplaces the cuts separately in each row and column of cells, using that band's edges plus its neighbours'. That fits a grid the generator warped. The page and the preview draw bent lines.Keep outlines when shrinking now carries outlines over as strokes:
A lone dark pixel still does not grow into a block.
Breaking: a recipe's
followis no longer a boolean.truebecomes"straight", andfalsebecomes"off"(or the field is left out). The changeset carries the fix.Measured
References: synthetic outlined sprites with ground truth, scaled by non-whole factors, then blurred and noised, with strokes drawn off the grid, cells uneven, and grid lines bent. Six seeds per case, with each sprite's own palette, so the error comes from the grid alone.
bend)bend), outline recall 76% → 84%bend+ outlines), 5.4% (outlines alone)bend)Shrinking 48 → 32 px, outlined sprites (8 seeds): the old shrink broke 12 strokes into 95 pieces; the new one keeps 11 (stair steps 25 → 11). A one-pixel ring shrunk from 16 to 11 px used to lose its sides; now it stays whole (this is a test).
Honest limits:
bendcleans a few muddy cells.Verify
pnpm run checkpasses.pnpm --dir website buildpasses.packages/tools/test/outline.test.ts.🤖 Generated with Claude Code