mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
contour::trace_mask built a table of outgoing directions for every pixel corner in a raster pass and then followed it. It now works out each turn during the walk from the two pixels ahead of the current corner: right if the one ahead on the right is outside, straight if the one ahead on the left is, else left (so at a saddle it still turns right and diagonal pixels stay apart). Loop starts are found by scanning the pixels for a top edge on the outline, with one flag per pixel for a top edge already walked. The walk is bounded by the grid size, and a mask of the wrong length now gives no loops instead of failing an assert_eq!. The output is identical: the_walk_equals_the_stored_direction_walk compares it with a test-only copy of the previous walk on all 65,536 4x4 masks and 400 seeded 23x17 masks. Time (best of 7, release, 4 cores): the walk alone on 2000x2000 masks 19.1 vs 26.6 ms (smooth pattern), 81.3 vs 93.2 ms (12% random pixels), 223.1 vs 238.1 ms (50% random); whole 1000x1000 traces 73.1 vs 77.1 ms (Black and White), 249.6 vs 251.7 ms (Color, 6 colours), 214.1 vs 218.6 ms (Color, 6 colours, Noise 1), same segment counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tBcdwNhptqtmX32JCGFzB