Repository navigation
Pixel Lab: a prototype page that turns any picture into an SNES PNG - #95
Merged
Merged
Conversation
tools/pixel_lab.html converts a photo or painting into an indexed PNG for superdevkit png: crop and downscale (8:7 pixels), colour ramps with a hue shift or k-means, ordered or error-diffusion dithering, outlines, merging similar tiles. A person picks the steps per picture and compares them side by side; the page shows the budget and saves the PNG and a recipe of its settings. One palette per picture so far. Playwright tests in tools/lab_test (pixel_lab.spec.js), run by BrrLabTest; the last one converts the saved PNG with the installed superdevkit png and compares the palette. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
skerkewitz
approved these changes
Nov 29, 2026
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
A new page,
tools/pixel_lab.html, that turns any picture (a photo, a painting, a picture from an image model) into an indexed PNG the SNES can show.superdevkit pngthen cuts it into tiles as before.Reducing the colours of a picture is easy, but the result looks like a photo with few colours, not like SNES graphics. What makes the retro look are choices an artist makes: palettes as ramps of a few steps with shadows shifted towards blue and lights towards yellow, dithering only inside a ramp and only in gradients, a dark outline, no lone pixels, tiles that repeat. Which of them suit a picture depends on the picture, so the page offers them all and a person chooses per picture, with the result next to the original and next to a kept result B.
It is a prototype, like the BRR Lab: a single page, no server, no network, no libraries.
How
The page works through five stages, recomputing only what a changed setting touches (the downscaled picture and the palette are cached):
Four presets show the range: "Technical" (k-means and Floyd-Steinberg, what a plain converter gives), "Retro: sprite", "Retro: background", "Retro: soft".
The tests are Playwright tests next to the BRR Lab's, in
tools/lab_test/pixel_lab.spec.js;BrrLabTestruns every spec there, so it runs them too.Verified
npx playwright test pixel_lab: 9 tests pass. They cover opening a picture through the file dialog, every preset (palette within its limit, every colour exactly 15 bits), bits per pixel, transparency and the outline, editing a colour, the snapshot and view options, and the recipe round trip. The last test saves the PNG, runs the installedsuperdevkit png tileson it and compares the tile count and the palette words with what the page shows../gradlew build: 1269 tests, 12 skipped as usual,BrrLabTest(both labs) passed in 19 s. One test failed:RandomProgramTest.loopProgramsMatchGcc, seed 20786007, today's random loop program, where the MIR backend's ROM differs from gcc. That is a dampf bug ondevelopthat today's date happens to hit, not this change (no file of the compiler is touched); it gets a change of its own../gradlew build -x :compiler:testpasses.Not checked: Firefox and Safari (the PNG export uses
CompressionStream, which both have); CI does not install Playwright, so there the tests skip as the BRR Lab's do.What follows
StyleGuideTestrules: unchanged; dampf is not touched.docs/game-findings.mdgot no entry.tools/README.md(a row for the page),tools/lab_test/README.md,docs/testing.md(the row is now "The labs"),README.md(requirements and the folder list).tools/already, so the page comes with the next release.guide/getting-started.md(its table oftools/) andguide/graphics-and-sound.md(which could say how to use the page).Open
docs/studio-editor-proposal.mddescribes.BrrLabTestnow runs both labs' tests; a rename (for example toLabsTest) would be a separate small change.🤖 Generated with Claude Code