mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 02:07:09 -06:00
The Simplify help page says a path can be simplified whole or "a specific path region with the Direct Selection tool" (https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/manually-simplify-paths.html). Simplify refitted every selected path whole, whatever part of it was direct-selected. object.path.simplify now looks at each path's direct selection: the segments picked as segments, or else every segment with both anchors selected. Each run of consecutive selected segments is refitted on its own (vectorcraft_pathops::simplify_part) between its two end anchors, which stay where they are with their handles on the side away from the run; every other anchor and segment stays exactly as it was. A closed path's run may cross its start point (the path then starts at the run's end anchor), separate runs on one path simplify independently in one undo step, and the runs stay direct-selected (as segments when segments were picked). A path with only lone anchors selected still simplifies whole, as before, and wholePaths: true simplifies partly selected paths whole. The slider, its preview, Auto-Simplify and the Simplify dialog all run the command, so they act on the part too. simplify_with now shares its run fitting with the part refit (same results). Verification: crates/engine/src/tests_simplify_part.rs (unselected anchors and segments equal bit for bit, run end anchors fixed, the run within the tolerance, two runs equal to each simplified alone in one undo step, a closed run across the start point, picked segments, wholePaths, slider preview and Auto-Simplify, a run that can't be simpler records no step) and simplify_slider_and_dialog_simplify_only_the_direct_selected_part_of_a_path (the slider's preview, Enter and the dialog's OK). Live: the release build's slider at level 20 on a 91-anchor wave with anchors 30–60 selected refits only that stretch.
38 lines
1.6 KiB
Rust
38 lines
1.6 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)]
|
|
|
|
mod boolean;
|
|
mod edit;
|
|
mod fit;
|
|
mod offset;
|
|
mod pathfinder;
|
|
mod planar;
|
|
|
|
pub use boolean::{BoolOp, DEFAULT_PRECISION, area, boolean, boolean_n, normalize, try_boolean, try_normalize, unite_all};
|
|
pub use edit::{
|
|
AverageAxis, SIMPLIFY_LEVEL, SimplifiedPart, SimplifyOptions, add_anchor_points, auto_simplify_level, average, join, remove_anchor,
|
|
remove_redundant_points, simplify, simplify_level_tolerance, simplify_part, simplify_with, smooth, split_into_grid,
|
|
};
|
|
pub use offset::{Cap, Join, offset_path, outline_stroke, stroke_region};
|
|
pub use pathfinder::{FaceMerger, PathfinderOp, Region, Shape, merge_regions, pathfinder, region_at, regions};
|
|
pub use planar::{
|
|
BuilderArrangement, SHAPE_BUILDER_MAX_GAP, SHAPE_BUILDER_MAX_SEGMENTS, 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,
|
|
};
|
|
|
|
/// 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,
|
|
}
|