Files
vectorcraft/crates/pathops/src/lib.rs
T
dotCooCoo 3de7547b2a Clean Up: remove hairline slivers thinner than a set width
Object > Path > Clean Up gets a Hairline Slivers option, off by default,
with a Sliver Width (0.001 to 3 pt, 0.03 mm by default). It removes
closed paths and compound paths with a visible fill, no visible stroke
and no effect when no circle that wide fits anywhere inside their fill:
shapes that
look like single lines in Outline view but have almost no area.
Select > Object > Hairline Slivers... selects the objects Clean Up would
remove, only inside the isolated group while one is isolated.

- vectorcraft-pathops: thinner_than measures the largest circle that
  fits in a fill. Bounds, the area against the outline length, and the
  width of the convex hull settle most shapes; the rest go through a
  cell search on the path's edges and then on the resolved outline.
  thinner_than_within takes the search's work from a budget, and one
  budget covers a whole document, so a run over thousands of shapes
  ends in bounded time.
- Shapes too complex to measure, and shapes still unmeasured when the
  budget runs out, are kept, and the reply's warning counts them.
- A compound path is measured as one fill. Hidden, locked and template
  objects, art on locked artboards, guides, the clipping paths of groups
  and layers, and the members of live and generated art are left alone.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-22 05:17:47 -08:00

54 lines
2.4 KiB
Rust

//! VectorCraft path operations: booleans (Pathfinder), shape builder regions, offset, outline stroke,
//! simplify and the other Object → Path commands.
//!
//! Booleans are curve-preserving: `linesweeper`'s robust sweep-line works directly on cubic
//! Béziers, and the pieces it splits curves into are refitted afterwards so results carry few
//! anchors. See the crate README for the API overview.
#![forbid(unsafe_code)]
pub mod addons;
mod boolean;
mod budget;
mod edit;
mod fit;
mod offset;
mod pathfinder;
mod planar;
mod sweep_axis;
mod thickness;
mod trap;
pub use boolean::{
BoolOp, DEFAULT_PRECISION, area, boolean, boolean_n, normalize, try_area, try_boolean, try_boolean_n, try_normalize, try_unite_all,
try_unite_all_with, unite_all, unite_all_with,
};
pub use edit::{
AverageAxis, SIMPLIFY_LEVEL, SMOOTH_AUTO_LEVEL, START_SNAP, SimplifiedPart, SimplifyOptions, add_anchor_points, auto_simplify_level, average,
join, remove_anchor, remove_anchors, remove_redundant_points, simplify, simplify_level_tolerance, simplify_part, simplify_with, smooth,
smooth_level, smooth_options, split_into_grid, start_nearest,
};
pub use fit::{fit_cubics, fit_cubics_through};
pub use offset::{Cap, Join, MAX_OFFSET_SEGMENT_PAIRS, offset_path, outline_stroke, stroke_region, try_offset_path};
pub use pathfinder::{
FaceMerger, PathfinderOp, Region, Shape, merge_regions, pathfinder, pathfinder_with, region_at, regions, regions_with, regions_within,
};
pub use planar::{
Adjacency, BuilderArrangement, MapEdge, MapFace, MapOutline, SHAPE_BUILDER_MAX_GAP, SHAPE_BUILDER_MAX_SEGMENTS, adjacency, cut_out,
encloses_area, find_gaps, has_open_path, interior_point, live_paint, live_paint_with_gaps, run_around, shape_builder, shape_builder_with_gap,
};
pub use thickness::{MAX_DOCUMENT_THICKNESS_WORK, MAX_THICKNESS_PIECES, ThicknessBudget, thinner_than, thinner_than_within};
pub use trap::{TRAP_HEIGHT_WIDTH_RANGE, TRAP_MAX_WIDTH, TRAP_MIN_WIDTH, trap_band};
/// Errors from fallible operations.
#[derive(Clone, Copy, Debug, PartialEq, Eq, thiserror::Error)]
pub enum PathOpsError {
#[error("input contains NaN or infinite coordinates")]
NonFinite,
#[error("input path could not be closed")]
OpenPath,
#[error("the shapes are too degenerate to combine")]
Degenerate,
#[error("the shapes cross themselves and each other too often to combine")]
TooComplex,
}