Skip to content

Commit e806384

Browse files
Revert "Refactor the Centroid node and Subpath struct and methods to use Kurbo, eliminating all remaining usages of Bezier-rs (#3036)"
This reverts commit d22b2ca.
1 parent e673641 commit e806384

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+504
-2126
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,9 @@ resolver = "2"
4242

4343
[workspace.dependencies]
4444
# Local dependencies
45-
dyn-any = { path = "libraries/dyn-any", features = [
46-
"derive",
47-
"glam",
48-
"reqwest",
49-
"log-bad-types",
50-
"rc",
51-
] }
52-
preprocessor = { path = "node-graph/preprocessor" }
45+
bezier-rs = { path = "libraries/bezier-rs", features = ["dyn-any", "serde"] }
46+
dyn-any = { path = "libraries/dyn-any", features = ["derive", "glam", "reqwest", "log-bad-types", "rc"] }
47+
preprocessor = { path = "node-graph/preprocessor"}
5348
math-parser = { path = "libraries/math-parser" }
5449
path-bool = { path = "libraries/path-bool" }
5550
graphene-application-io = { path = "node-graph/gapplication-io" }
@@ -83,7 +78,7 @@ convert_case = "0.7"
8378
derivative = "2.2"
8479
thiserror = "2"
8580
anyhow = "1.0"
86-
proc-macro2 = { version = "1", features = ["span-locations"] }
81+
proc-macro2 = { version = "1", features = [ "span-locations" ] }
8782
quote = "1.0"
8883
axum = "0.8"
8984
chrono = "0.4"
@@ -125,17 +120,9 @@ resvg = "0.44"
125120
usvg = "0.44"
126121
rand = { version = "0.9", default-features = false, features = ["std_rng"] }
127122
rand_chacha = "0.9"
128-
glam = { version = "0.29", default-features = false, features = [
129-
"serde",
130-
"scalar-math",
131-
"debug-glam-assert",
132-
] }
123+
glam = { version = "0.29", default-features = false, features = ["serde", "scalar-math", "debug-glam-assert"] }
133124
base64 = "0.22"
134-
image = { version = "0.25", default-features = false, features = [
135-
"png",
136-
"jpeg",
137-
"bmp",
138-
] }
125+
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp"] }
139126
parley = "0.5.0"
140127
skrifa = "0.32.0"
141128
pretty_assertions = "1.4.1"

editor/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ron = ["dep:ron"]
2323
graphite-proc-macros = { workspace = true }
2424
graph-craft = { workspace = true }
2525
interpreted-executor = { workspace = true }
26-
graphene-std = { workspace = true } # NOTE: `graphene-core` should not be added here because `graphene-std` re-exports its contents
26+
graphene-std = { workspace = true }
2727
preprocessor = { workspace = true }
2828

2929
# Workspace dependencies
@@ -33,6 +33,7 @@ bitflags = { workspace = true }
3333
thiserror = { workspace = true }
3434
serde = { workspace = true }
3535
serde_json = { workspace = true }
36+
bezier-rs = { workspace = true }
3637
kurbo = { workspace = true }
3738
futures = { workspace = true }
3839
glam = { workspace = true }

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,18 @@ use crate::messages::tool::tool_messages::select_tool::SelectToolPointerKeys;
2727
use crate::messages::tool::tool_messages::tool_prelude::Key;
2828
use crate::messages::tool::utility_types::ToolType;
2929
use crate::node_graph_executor::NodeGraphExecutor;
30+
use bezier_rs::Subpath;
3031
use glam::{DAffine2, DVec2, IVec2};
3132
use graph_craft::document::value::TaggedValue;
3233
use graph_craft::document::{NodeId, NodeInput, NodeNetwork, OldNodeNetwork};
3334
use graphene_std::math::quad::Quad;
3435
use graphene_std::path_bool::{boolean_intersect, path_bool_lib};
3536
use graphene_std::raster::BlendMode;
3637
use graphene_std::raster_types::Raster;
37-
use graphene_std::subpath::Subpath;
3838
use graphene_std::table::Table;
3939
use graphene_std::vector::PointId;
4040
use graphene_std::vector::click_target::{ClickTarget, ClickTargetType};
41-
use graphene_std::vector::misc::{dvec2_to_point, point_to_dvec2};
4241
use graphene_std::vector::style::ViewMode;
43-
use kurbo::{Affine, CubicBez, Line, ParamCurve, PathSeg, QuadBez};
4442
use std::path::PathBuf;
4543
use std::time::Duration;
4644

@@ -3010,10 +3008,10 @@ fn quad_to_path_lib_segments(quad: Quad) -> Vec<path_bool_lib::PathSegment> {
30103008
}
30113009

30123010
fn click_targets_to_path_lib_segments<'a>(click_targets: impl Iterator<Item = &'a ClickTarget>, transform: DAffine2) -> Vec<path_bool_lib::PathSegment> {
3013-
let segment = |bezier: PathSeg| match bezier {
3014-
PathSeg::Line(line) => path_bool_lib::PathSegment::Line(point_to_dvec2(line.p0), point_to_dvec2(line.p1)),
3015-
PathSeg::Quad(quad_bez) => path_bool_lib::PathSegment::Quadratic(point_to_dvec2(quad_bez.p0), point_to_dvec2(quad_bez.p1), point_to_dvec2(quad_bez.p2)),
3016-
PathSeg::Cubic(cubic_bez) => path_bool_lib::PathSegment::Cubic(point_to_dvec2(cubic_bez.p0), point_to_dvec2(cubic_bez.p1), point_to_dvec2(cubic_bez.p2), point_to_dvec2(cubic_bez.p3)),
3011+
let segment = |bezier: bezier_rs::Bezier| match bezier.handles {
3012+
bezier_rs::BezierHandles::Linear => path_bool_lib::PathSegment::Line(bezier.start, bezier.end),
3013+
bezier_rs::BezierHandles::Quadratic { handle } => path_bool_lib::PathSegment::Quadratic(bezier.start, handle, bezier.end),
3014+
bezier_rs::BezierHandles::Cubic { handle_start, handle_end } => path_bool_lib::PathSegment::Cubic(bezier.start, handle_start, handle_end, bezier.end),
30173015
};
30183016
click_targets
30193017
.filter_map(|target| {
@@ -3024,7 +3022,7 @@ fn click_targets_to_path_lib_segments<'a>(click_targets: impl Iterator<Item = &'
30243022
}
30253023
})
30263024
.flatten()
3027-
.map(|bezier| segment(Affine::new(transform.to_cols_array()) * bezier))
3025+
.map(|bezier| segment(bezier.apply_transformation(|x| transform.transform_point2(x))))
30283026
.collect()
30293027
}
30303028

@@ -3047,11 +3045,11 @@ impl<'a> ClickXRayIter<'a> {
30473045

30483046
/// Handles the checking of the layer where the target is a rect or path
30493047
fn check_layer_area_target(&mut self, click_targets: Option<&Vec<ClickTarget>>, clip: bool, layer: LayerNodeIdentifier, path: Vec<path_bool_lib::PathSegment>, transform: DAffine2) -> XRayResult {
3050-
// Convert back to Kurbo types for intersections
3048+
// Convert back to Bezier-rs types for intersections
30513049
let segment = |bezier: &path_bool_lib::PathSegment| match *bezier {
3052-
path_bool_lib::PathSegment::Line(start, end) => PathSeg::Line(Line::new(dvec2_to_point(start), dvec2_to_point(end))),
3053-
path_bool_lib::PathSegment::Cubic(start, h1, h2, end) => PathSeg::Cubic(CubicBez::new(dvec2_to_point(start), dvec2_to_point(h1), dvec2_to_point(h2), dvec2_to_point(end))),
3054-
path_bool_lib::PathSegment::Quadratic(start, h1, end) => PathSeg::Quad(QuadBez::new(dvec2_to_point(start), dvec2_to_point(h1), dvec2_to_point(end))),
3050+
path_bool_lib::PathSegment::Line(start, end) => bezier_rs::Bezier::from_linear_dvec2(start, end),
3051+
path_bool_lib::PathSegment::Cubic(start, h1, h2, end) => bezier_rs::Bezier::from_cubic_dvec2(start, h1, h2, end),
3052+
path_bool_lib::PathSegment::Quadratic(start, h1, end) => bezier_rs::Bezier::from_quadratic_dvec2(start, h1, end),
30553053
path_bool_lib::PathSegment::Arc(_, _, _, _, _, _, _) => unimplemented!(),
30563054
};
30573055
let get_clip = || path.iter().map(segment);
@@ -3100,10 +3098,7 @@ impl<'a> ClickXRayIter<'a> {
31003098
XRayTarget::Quad(quad) => self.check_layer_area_target(click_targets, clip, layer, quad_to_path_lib_segments(*quad), transform),
31013099
XRayTarget::Path(path) => self.check_layer_area_target(click_targets, clip, layer, path.clone(), transform),
31023100
XRayTarget::Polygon(polygon) => {
3103-
let polygon = polygon
3104-
.iter_closed()
3105-
.map(|line| path_bool_lib::PathSegment::Line(point_to_dvec2(line.start()), point_to_dvec2(line.end())))
3106-
.collect();
3101+
let polygon = polygon.iter_closed().map(|line| path_bool_lib::PathSegment::Line(line.start, line.end)).collect();
31073102
self.check_layer_area_target(click_targets, clip, layer, polygon, transform)
31083103
}
31093104
}

editor/src/messages/portfolio/document/graph_operation/graph_operation_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use super::utility_types::TransformIn;
22
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
33
use crate::messages::portfolio::document::utility_types::network_interface::NodeTemplate;
44
use crate::messages::prelude::*;
5+
use bezier_rs::Subpath;
56
use glam::{DAffine2, IVec2};
67
use graph_craft::document::NodeId;
78
use graphene_std::Artboard;
89
use graphene_std::brush::brush_stroke::BrushStroke;
910
use graphene_std::raster::BlendMode;
1011
use graphene_std::raster_types::{CPU, Raster};
11-
use graphene_std::subpath::Subpath;
1212
use graphene_std::table::Table;
1313
use graphene_std::text::{Font, TypesettingConfig};
1414
use graphene_std::vector::PointId;

editor/src/messages/portfolio/document/graph_operation/transform_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::messages::portfolio::document::utility_types::network_interface::{InputConnector, NodeNetworkInterface};
2+
use bezier_rs::Subpath;
23
use glam::{DAffine2, DVec2};
34
use graph_craft::document::value::TaggedValue;
45
use graph_craft::document::{NodeId, NodeInput};
5-
use graphene_std::subpath::Subpath;
66
use graphene_std::vector::PointId;
77

88
/// Convert an affine transform into the tuple `(scale, angle, translation, shear)` assuming `shear.y = 0`.

editor/src/messages/portfolio/document/graph_operation/utility_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::messages::portfolio::document::node_graph::document_node_definitions:
33
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
44
use crate::messages::portfolio::document::utility_types::network_interface::{self, InputConnector, NodeNetworkInterface, OutputConnector};
55
use crate::messages::prelude::*;
6+
use bezier_rs::Subpath;
67
use glam::{DAffine2, IVec2};
78
use graph_craft::concrete;
89
use graph_craft::document::value::TaggedValue;
@@ -11,7 +12,6 @@ use graphene_std::Artboard;
1112
use graphene_std::brush::brush_stroke::BrushStroke;
1213
use graphene_std::raster::BlendMode;
1314
use graphene_std::raster_types::{CPU, Raster};
14-
use graphene_std::subpath::Subpath;
1515
use graphene_std::table::Table;
1616
use graphene_std::text::{Font, TypesettingConfig};
1717
use graphene_std::vector::Vector;

editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
18371837
continue;
18381838
};
18391839
let quad = Quad::from_box([box_selection_start, box_selection_end_graph]);
1840-
if click_targets.node_click_target.intersect_path(|| quad.to_lines(), DAffine2::IDENTITY) {
1840+
if click_targets.node_click_target.intersect_path(|| quad.bezier_lines(), DAffine2::IDENTITY) {
18411841
nodes.insert(node_id);
18421842
}
18431843
}

editor/src/messages/portfolio/document/overlays/utility_functions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::consts::HIDE_HANDLE_DISTANCE;
33
use crate::messages::portfolio::document::utility_types::network_interface::NodeNetworkInterface;
44
use crate::messages::tool::common_functionality::shape_editor::{SelectedLayerState, ShapeState};
55
use crate::messages::tool::tool_messages::tool_prelude::{DocumentMessageHandler, PreferencesMessageHandler};
6+
use bezier_rs::{Bezier, BezierHandles};
67
use glam::{DAffine2, DVec2};
7-
use graphene_std::subpath::{Bezier, BezierHandles};
88
use graphene_std::vector::misc::ManipulatorPointId;
99
use graphene_std::vector::{PointId, SegmentId};
1010
use wasm_bindgen::JsCast;
@@ -125,7 +125,7 @@ pub fn path_overlays(document: &DocumentMessageHandler, draw_handles: DrawHandle
125125
}
126126

127127
// Get the selected segments and then add a bold line overlay on them
128-
for (segment_id, bezier, _, _) in vector.segment_iter() {
128+
for (segment_id, bezier, _, _) in vector.segment_bezier_iter() {
129129
let Some(selected_shape_state) = shape_editor.selected_shape_state.get_mut(&layer) else {
130130
continue;
131131
};

0 commit comments

Comments
 (0)