Skip to content

Conversation

@big-nacho
Copy link
Collaborator

Description:

This PR updates the pipeline so that now:
trace -> convert to polygons -> perform boolean operations -> convert back to paths -> generate markup
is
trace -> perform boolean operations -> generate markup

This makes results much better and reduces path complexity a lot.

  • I have self-reviewed this PR, according to these points
  • This PR falls into maximum three of these categories
  • I feel comfortable taking responsibility for merging this code to production
  • The code is high quality, well-tested, follows styles guides (Frontend), clean, and well documented

@claas-c claas-c requested a review from Copilot May 30, 2025 13:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR streamlines the SVG generation pipeline by removing intermediate polygon representations and using SKPath + PathOps for boolean operations.

  • Directly performs boolean operations on SKPath objects instead of converting to/from polygons.
  • Revamps markup generation to iterate SKPath segments and truncate coordinates.
  • Cleans up unused geometry modules and updates dependencies (e.g., replacing pyclipper with skia-pathops).

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vectorizing/svg/markup.py Introduces truncate, to_SVG_color_string, and generate_SVG_markup using SKPath segments
vectorizing/solvers/color/clip.py Replaces pyclipper pipeline with pathops.op for difference
vectorizing/solvers/color/ColorSolver.py Removes tolerance parameter, updates solver call signatures
vectorizing/geometry/potrace.py Converts potrace paths to SKPath, removes old flattening helpers
vectorizing/geometry/bounds.py Adds compound_paths_bounds and drops legacy Bounds class use
vectorizing/init.py Switches to new generate_SVG_markup and compound_paths_bounds
requirements/* Bumps package versions, removes pyclipper, adds skia-pathops
Comments suppressed due to low confidence (2)

vectorizing/svg/markup.py:33

  • The variable name tuple shadows the built-in. Rename it to something like components or values for clarity.
tuple = "".join(

vectorizing/geometry/potrace.py:1

  • The numpy import is no longer used in this file. You can remove it to clean up unused dependencies.
import numpy as np

d = ""
for segment in segments:
command = segment[0]
if command == "moveTo":
Copy link

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using if/elif/else instead of multiple if blocks to avoid checking every condition once a match is found.

Copilot uses AI. Check for mistakes.
d = ""
for segment in segments:
command = segment[0]
if command == "moveTo":
Copy link

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no fallback for an unexpected segment command. Consider adding an else branch that raises or logs an error if command is unrecognized.

Copilot uses AI. Check for mistakes.
# NOTE: The clipper library uses integer coordinates only for numerical robustness.
# That's why coordinates are scaled by a big factor, to preserve precision.
def remove_layering(traced_bitmaps, tolerance):
def remove_layering(traced_bitmaps):
Copy link

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a docstring to remove_layering to explain its parameters and return value, matching the style of other utility functions.

Copilot uses AI. Check for mistakes.
@big-nacho big-nacho merged commit 43be3b5 into main May 30, 2025
0 of 2 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.

3 participants