Skip to content

fix: preserve accent colors and reduce SVG cutout seams - #42

Merged
Microck merged 1 commit into
mainfrom
fix/palette-and-svg-seams
Nov 26, 2026
Merged

Microck merged 1 commit into
mainfrom
fix/palette-and-svg-seams

Conversation

@Microck

@Microck Microck commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

auto can flatten a small accent into the dominant color, and adjacent opaque fills can leave a faint seam in SVG cutouts.

  • auto now reconsiders two-color picks using the reconstruction scores it already computes.
  • SVG cutouts add backing behind enclosed opaque fills. hidden and translucent regions keep their cutouts.

Evidence

  • Before: mean RGB error was 3.502 across 16 inputs. the thin orange arc came out blue.
  • After: mean error was 3.143, down 10.2%. 11 inputs improved and five tied. the orange arc kept its color.
  • the source checks passed on this branch. the benchmark candidate also passed the nested-opacity regression and the checked-in export byte fixtures.

Merge Danger

Door Two-way

Blast Radius Tracing and SVG export

the benchmark SVGs grew by 20.1% in total. backing only covers enclosed opaque cutouts, so seams can still show between other shapes.

Summary by Sourcery

Improve automatic color selection and SVG cutout rendering to preserve accents and minimize seams.

Bug Fixes:

  • Preserve small accent colors during automatic palette selection by reconsidering two-color results against reconstruction quality.
  • Reduce visible seams in SVG cutouts while retaining hidden and translucent regions.

Enhancements:

  • Add regression coverage for SVG cutout backing behavior and nested opacity handling.

Tests:

  • Add SVG export tests covering enclosed opaque, hidden, and translucent cutout regions.

@sourcery-ai

sourcery-ai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Sorry @Microck, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 20 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Review the automatic palette-selection changes, which use reconstruction scores to promote an automatic two-color pick when a larger palette scores better.

  • rust/crates/openvector/src/image_document.rs L291-309, L314-317, L330-338

Review the SVG cutout backing logic, which adds backing only for enclosed opaque fills while preserving clear cutouts for hidden or translucent descendants.

  • rust/crates/openvector/src/svg.rs L8-9, L39, L52
  • rust/crates/openvector/src/vector_output.rs L206, L236-292, L313

Documentation

Review the updated automatic and vector-output contracts alongside the behavior changes they describe.

  • docs/automatic-contract.json L11
  • docs/vector-output-contract.json L155-157

Tests

Check the SVG cutout output retains expected paths for hidden and translucent descendants.

  • rust/crates/openvector/src/svg.rs L67-111

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

This PR keeps small accent colors in auto tracing and adds backing fills behind enclosed opaque SVG cutouts.

  • Automatic palette: a candidate with more than two colors replaces the two-color pick only when its color-penalized score strictly improves.
  • Backing: holes whose descendants are all visible and opaque receive a fill of the average child color at alpha 255. Other shape boundaries can still show seams.
  • Reviewer action: check the SVG size increase, which the author reports as 20.1%. Confirm test coverage for the palette promotion, which the summary does not show.

Walkthrough

Automatic palette selection now compares evaluated candidates against the two-color recommendation and can promote to a fixed palette for single-image and default batch processing. Vector output now adds opaque backing shapes to eligible cutout holes. SVG output supplies the alpha threshold, and tests cover nested opaque, hidden, and translucent regions.

Merge Risk: Minimal · up to 06f26

Automatic palette selection can now keep small accent colors, and SVG cutouts get backing behind enclosed opaque fills. No concrete defect was found. One test assertion on two-color palette counts could not be executed here, so it is worth confirming in CI.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.1)

Clippy execution timed out
Clippy (1.99.1) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d33daf25-2b47-41e7-a3b7-25e2fbf76a2d
Commits

Reviewing files that changed from the base of the PR and between 2990a57 and 06f2630.

Files selected for processing: 5

  • docs/automatic-contract.json
  • docs/vector-output-contract.json
  • rust/crates/openvector/src/image_document.rs
  • rust/crates/openvector/src/svg.rs
  • rust/crates/openvector/src/vector_output.rs

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@Microck
Microck merged commit cfebb61 into main Nov 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant