Skip to content

Add low-level implementation for path joining and merging optimization#183

Merged
abey79 merged 9 commits into
masterfrom
pr1-join-path
Mar 1, 2026
Merged

Add low-level implementation for path joining and merging optimization#183
abey79 merged 9 commits into
masterfrom
pr1-join-path

Conversation

@abey79

@abey79 abey79 commented Jan 4, 2026

Copy link
Copy Markdown
Owner

This PR adds support for joining to paths, and path merging optimisation to layers. This is only the low-level machinery. It is not exposed yet to either the CLI or whiskers.

Constants

  • SAME_POINT_EPSILON: f64 = 1e-10 — point coincidence threshold (crate-level, in vsvg::lib.rs)

Polyline

  • join(&mut self, other: &Polyline, epsilon: f64) — append polyline, skipping duplicate junction point

PathDataTrait

  • is_closed(&self) -> bool — checks if start ≈ end within SAME_POINT_EPSILON

PathTrait

  • join(&mut self, other: &Self, epsilon: f64) — append path, merge at coincident endpoints
  • split(self) -> Vec<Self> — split compound paths at MoveTo boundaries

PathMetadata

  • merge(&mut self, other: &PathMetadata) — merge metadata (first wins)

LayerTrait

  • join_paths(&mut self, tolerance: f64, flip: bool) — join adjacent paths within tolerance
  • explode(&mut self) — split all compound paths into subpaths

Free Functions (vsvg::optimization)

  • sort_paths<P, D>(paths: &mut Vec<P>, flip: bool)
  • sort_paths_with_builder<P, D>(paths: &mut Vec<P>, builder: IndexBuilder)
  • join_paths<P, D>(paths: &mut Vec<P>, tolerance: f64, flip: bool)

Changed

  • LayerTrait::sort/sort_with_builder now delegate to free functions in optimization

This is part 1 of 6 in a stack made with GitButler:

@abey79 abey79 added vsvg Relates to vsvg feature New feature labels Jan 4, 2026
@abey79 abey79 changed the title Add path joining and merge optimisation Add low-level implementation for path joining and merging optimization Jan 4, 2026
@abey79 abey79 force-pushed the pr1-join-path branch 2 times, most recently from dd91bb3 to 946f75b Compare February 22, 2026 21:03
@abey79 abey79 merged commit e4ba82f into master Mar 1, 2026
9 checks passed
@abey79 abey79 deleted the pr1-join-path branch March 1, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature vsvg Relates to vsvg

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant