mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 02:07:09 -06:00
Flat Logo found its colours only from solid pixels (a uniform 3 x 3 neighbourhood). Line art on paper has no solid area but the paper's: a stroke one or two pixels wide never fills one, so its colour was a handful of pixels among tens of thousands of white and was cut as noise (under 0.1% of the solid pixels). The palette came back empty and trace_logo returned an empty TraceResult, which imageTrace.make reported as a success with paths 0, anchors 0, colors 0. Cause: logo::palette::auto_palette had no way to find a colour that has no solid area, and logo::pipeline::trace_logo treats an empty palette as nothing to trace. Fix: when the solid pixels give no colour but white, auto_palette reads the colours from the strokes' cores instead (line_art_palette): the opaque ink pixels at least as far from white as each of their four neighbours, the middle of each stroke where it is least blended with the paper. Two guards keep that fallback to line art: - Ink is a colour at least 48 below white in one channel, and the page must have ink on at least 1% of its opaque pixels. Light grain and a few sparse marks on otherwise blank paper stay blank, as plain white does. - The lighter shades along a stroke's anti-aliased edge are local maxima of their own; a colour that lies on the line from white to a darker colour of the palette (within 20) is a blend of that ink with the paper and is folded into it (fold_fringes), the ink keeping its colour. The rest of the pipeline (unmixing, the flat-colour check and its NotFlat refusal) is unchanged, and images with a solid colour other than white never reach the fallback. Tests (code-drawn inputs): - thin_line_art_on_paper_is_traced_not_blank: four 2.4 px dark strokes and two red marks on white. Before: palette [], no paths. After: dark and red paths along the middle of every stroke and mark. - anti_aliased_coloured_lettering_has_only_its_inks: rings, slants and bars 1.6 px wide in red, blue and green. Without the fold: six colours besides white; after: exactly the three inks. - sparse_marks_on_paper_are_not_promoted_to_colours: 24 grey 12 x 2 px marks of 239, 223 or 191 on a 256 x 256 page (under 1% ink). Without the guard: palette [white, #efefef]; after: empty palette, no paths. - grainy_blank_paper_has_no_ink: paper grain 243-255 traces to nothing. - edge_shades_fold_into_their_ink_and_other_colours_stay (unit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tBcdwNhptqtmX32JCGFzB