Repository navigation
Image Trace: Flat Logo traces a gray between black and white as one shape - #7451
Merged
bflatastic merged 3 commits intoNov 14, 2026
Merged
bflatastic merged 3 commits into
bflatastic merged 3 commits into
Conversation
…hape With a gray among the colors, an anti-aliased edge pixel of black on white is also a mix of black and gray, or of gray and white, and the unmixing took the mix with the smallest error, which often held the gray. A black disc and a gray square on white traced the gray as the square plus 8 to 24 slivers around the disc, with the colors found or named exactly. When another mix of two classes also reproduces an edge pixel, the pixel now takes it if that mix's classes lie nearer in the flat areas around the pixel and the pixel has a neighbor on each side of the left-out class, along the line between the other two. Pixels within a few levels of a class outside a flat area are checked the same way, and they now count toward the number of pixel values that decides when a busy image is averaged down further. A flat area that stands for no class, as with colors named some levels off, counts as holding the classes of its mix, and so do the pixels of exactly its color joined to it. Whether a hard-edged image is softened is still judged from each pixel's best mix. The slivers are removed around sharp edges and edges blurred by up to about half a pixel; an edge blurred by a pixel or more, or pixel noise of a level or more, can still leave some. Gray strokes two and three pixels wide beside black stay gray, and so does a one-pixel gray line between black and white of at least 13 joined pixels. These trace as black and white: a shorter one-pixel line, or one that falls between pixels or is blurred; a soft-edged gray stroke about two pixels wide touching black; and most or all of a soft-edged stroke about three pixels wide touching black, 12 pixels long or less. Docs: docs/image-trace-adjustments.md, docs/target-app-parity.md.
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 18 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
3 of 4 tasks
This was referenced Nov 14, 2026
Member
|
Merged, thanks @dotCooCoo! It passed its CI checks. |
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 and why
With a gray among Flat Logo's colors, an anti-aliased edge pixel of black on white is also a mix of black and gray, or of gray and white. The unmixing took the mix with the smallest error, which often held the gray, so a black disc beside a gray square on white traced the gray as the square plus 8 to 24 thin slivers around the disc (colors found automatically or named exactly; grays 230 and 200, sharp and slightly soft edges, measured on
mainatf062dd7ed2).crates/trace/src/logo/unmix.rs: when another mix of two classes also reproduces an edge pixel, the pixel takes that mix if its classes lie nearer in the flat areas within 6 pixels, and the pixel has a neighbor on each side of the left-out class along the line between the other two. A gray stroke on white has no darker neighbor and keeps its gray.count_ambiguous), sinceunmixchecks them too. A busy image can therefore be averaged down sooner than before.crates/trace/src/logo/pipeline.rs: whether a hard-edged image is softened is still judged from each pixel's best mix, so the pixels that take another mix do not change that decision.docs/image-trace-adjustments.mddescribes the behavior and its limits, anddocs/target-app-parity.mdhas one line for it.Limits, stated in the docs:
How it was tested
New tests in
crates/trace/src/logo/tests.rs, all drawn in code: the disc and square with grays 230 and 200, sharp and blurred, colors found, named and named 52 levels off; a one-pixel gray line between black and white; gray strokes touching the disc; gray stripes beside a black disc with colors named off; thin gray strokes near black; and the disc and a mid-gray square with 2 levels of noise. Unit tests inunmix.rscover the mix choice, the 13-pixel line and the row distances.With the switch disabled, the touching-stroke, disc-and-square, edge-pixel and column tests fail. With the softening judged from the switched pixels instead, the noise test fails with 27 gray paths.
Focused checks on Linux, on the head
3ea1524618. The branch is one commit onmainatf062dd7ed2and merges cleanly withmainat1e4e3534f5; the merged tree was checked as well.cargo test -p vectorcraft-trace: 285 + 1 + 2 + 11 passed, 0 failed, 3 ignoredcargo test -p vectorcraft-engine trace: 53 passed, 0 failedcargo fmt --all -- --checkcargo clippy -p vectorcraft-trace --all-targets -- -D warningscargo check --workspace --testsmainat1e4e3534f5:cargo check --workspace --tests,cargo clippy -p vectorcraft-trace --all-targets -- -D warnings,cargo test -p vectorcraft-trace(337 + 1 + 2 + 11 passed, 0 failed, 3 ignored) andcargo test -p vectorcraft-engine trace(56 passed, 0 failed)cargo xtask ciruns in this pull request's CI.Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md.