Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ syn = { version = "2.0", default-features = false, features = [
"proc-macro",
] }
lyon_geom = "1.0"
delaunator = "1.0"
petgraph = { version = "0.7", default-features = false, features = ["graphmap"] }
half = { version = "2.4", default-features = false, features = ["bytemuck"] }
tinyvec = { version = "1", features = ["std"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,10 @@ where
deserializer.deserialize_seq(visitor)
}

/// Distance below which a path's closing point is treated as coincident with its start point.
/// Matches Kurbo's default path accuracy, so points within an offset operation's own precision are not split into separate anchors.
const CLOSE_POINT_TOLERANCE: f64 = 1e-6;

pub struct AppendBezpath<'a> {
first_point: Option<Point>,
last_point: Option<Point>,
Expand Down Expand Up @@ -657,7 +661,11 @@ impl<'a> AppendBezpath<'a> {
}

fn append_segment_and_close_path(&mut self, point: Point, handle: BezierHandles) {
let handle = if self.first_point.unwrap() != point {
// A path's final point may return to approximately (but not bit-exactly) its start before closing, e.g. a contour
// produced by Kurbo's path offsetting. Treat a near-coincident final point as already on the start so we don't
// introduce a redundant duplicate anchor and a zero-length closing segment.
let endpoints_coincide = (self.first_point.unwrap() - point).hypot2() <= CLOSE_POINT_TOLERANCE * CLOSE_POINT_TOLERANCE;
let handle = if !endpoints_coincide {
// If the first point is not the same as the last point of the path then we append the segment
// with given handle and point and then close the path with linear handle.
self.append_segment(point, handle);
Expand Down
1 change: 1 addition & 0 deletions node-graph/nodes/vector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ repeat-nodes = { workspace = true }
dyn-any = { workspace = true }
glam = { workspace = true }
kurbo = { workspace = true }
delaunator = { workspace = true }
rand = { workspace = true }
rustc-hash = { workspace = true }
log = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions node-graph/nodes/vector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod generator_nodes;
pub mod merge_qr_squares;
pub mod vector_modification_nodes;
mod vector_nodes;
mod voronoi;

#[macro_use]
extern crate log;
Expand Down
Loading
Loading