Skip to content

Commit 153c3a8

Browse files
committed
define Subpath struct in gcore and refactor node-graph
1 parent 9b8935d commit 153c3a8

28 files changed

+3285
-122
lines changed

Cargo.lock

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node-graph/gcore/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ rustc-hash = { workspace = true }
2929
dyn-any = { workspace = true }
3030
ctor = { workspace = true }
3131
rand_chacha = { workspace = true }
32-
bezier-rs = { workspace = true }
3332
specta = { workspace = true }
3433
image = { workspace = true }
3534
tinyvec = { workspace = true }

node-graph/gcore/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub mod raster_types;
2222
pub mod registry;
2323
pub mod render_complexity;
2424
pub mod structural;
25+
pub mod subpath;
2526
pub mod table;
2627
pub mod text;
2728
pub mod transform;

node-graph/gcore/src/math/math_ext.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
use kurbo::{Line, PathSeg};
2+
13
use crate::math::quad::Quad;
24
use crate::math::rect::Rect;
3-
use bezier_rs::Bezier;
5+
use crate::subpath::Bezier;
6+
use crate::vector::misc::dvec2_to_point;
47

58
pub trait QuadExt {
69
/// Get all the edges in the rect as linear bezier curves
710
fn bezier_lines(&self) -> impl Iterator<Item = Bezier> + '_;
11+
fn to_lines(&self) -> impl Iterator<Item = PathSeg>;
812
}
913

1014
impl QuadExt for Quad {
1115
fn bezier_lines(&self) -> impl Iterator<Item = Bezier> + '_ {
1216
self.all_edges().into_iter().map(|[start, end]| Bezier::from_linear_dvec2(start, end))
1317
}
18+
19+
fn to_lines(&self) -> impl Iterator<Item = PathSeg> {
20+
self.all_edges().into_iter().map(|[start, end]| PathSeg::Line(Line::new(dvec2_to_point(start), dvec2_to_point(end))))
21+
}
1422
}
1523

1624
pub trait RectExt {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Implementation constants
2+
3+
/// Constant used to determine if `f64`s are equivalent.
4+
pub const MAX_ABSOLUTE_DIFFERENCE: f64 = 1e-3;

0 commit comments

Comments
 (0)