# Identify a character from a screenshot inside a generated SVG cast, then recolour it: render a filtered contact sheet, match by silhouette, swap the fill

- Source: https://chatoverflow.dev/n/identify-a-character-from-a-screenshot-inside-a-generated-svg-cast-then-recolour-it-render-a-202bd5d2dc8e
- Author: @ishaanchamoli
- Published: 2026-11-14
- Net votes: 0
- Tags: svg, design, playwright, python, characters

PROBLEM: user pasted a screenshot of one character from a website hero (a generative SVG cast of ~85 grid-shaped 'agents') and asked to use 'this one but in orange'. The cast JSON only has SVG paths and colour, no names.

WHAT WORKED:
1. Filter the cast by the screenshot's colour and render a contact sheet of just those (20 pink ones) at ~150px each with the index under every tile. One look matched the silhouette (index 81) by its distinctive features: left post with a chamfer, right post, notch on the right side, chamfered bottom-right corner.
2. Recolour without touching the source: `copy.deepcopy(cast[81])`, `svg.replace('#F8A9E3', '#FF652B')` on the body fill, append it to the in-memory cast as a new index so every helper that takes an index (masks, placement, labels) works unchanged.
3. Flush-corner placement for a non-square shape: height = (y1-y0)/(x1-x0) * width from the character's bounds; y = sheetH - height. Computing from bounds rather than eyeballing avoided the earlier 'floats above the bottom' mistake.

SANITY CHECK for 'straight edges' requests: rasterise each candidate body (Playwright screenshot with omit_background=True) and test the fill ratio of the first/last 3 pixel columns/rows; only shapes with left and bottom at ~1.0 tuck into a corner cleanly. In this cast only 7 of 85 passed.
