mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-03 21:08:18 +00:00
Add upgrade script to convert "Spline" node to "Path" -> "Spline from Points" (#2274)
* write document upgrade code to transfrom Spline node into Path -> Spline from Points * fix only connecting to single output * shift position of newly inserted Path -> Spline from Points node * refactor * remove all old Spline node code * rename Spline from Points node to Spline * Code cleanup * Update the demo art to natively use the new Spline node --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
95bbc95606
commit
2d90bb0cbf
7 changed files with 87 additions and 40 deletions
|
@ -106,17 +106,6 @@ fn line<F: 'n + Send>(#[implementations((), Footprint)] _footprint: F, _primary:
|
|||
VectorDataTable::new(VectorData::from_subpath(Subpath::new_line(start, end)))
|
||||
}
|
||||
|
||||
#[node_macro::node(category("Vector: Shape"))]
|
||||
fn spline<F: 'n + Send>(#[implementations((), Footprint)] _footprint: F, _primary: (), points: Vec<DVec2>) -> VectorDataTable {
|
||||
let mut spline = VectorData::from_subpath(Subpath::new_cubic_spline(points));
|
||||
|
||||
for pair in spline.segment_domain.ids().windows(2) {
|
||||
spline.colinear_manipulators.push([HandleId::end(pair[0]), HandleId::primary(pair[1])]);
|
||||
}
|
||||
|
||||
VectorDataTable::new(spline)
|
||||
}
|
||||
|
||||
// TODO(TrueDoctor): I removed the Arc requirement we should think about when it makes sense to use it vs making a generic value node
|
||||
#[node_macro::node(category(""))]
|
||||
fn path<F: 'n + Send>(#[implementations((), Footprint)] _footprint: F, path_data: Vec<Subpath<PointId>>, colinear_manipulators: Vec<PointId>) -> VectorDataTable {
|
||||
|
|
|
@ -864,8 +864,8 @@ async fn subpath_segment_lengths<F: 'n + Send>(
|
|||
.collect()
|
||||
}
|
||||
|
||||
#[node_macro::node(name("Splines from Points"), category("Vector"), path(graphene_core::vector))]
|
||||
async fn splines_from_points<F: 'n + Send>(
|
||||
#[node_macro::node(name("Spline"), category("Vector"), path(graphene_core::vector))]
|
||||
async fn spline<F: 'n + Send>(
|
||||
#[implementations(
|
||||
(),
|
||||
Footprint,
|
||||
|
@ -1431,7 +1431,7 @@ mod test {
|
|||
}
|
||||
#[tokio::test]
|
||||
async fn spline() {
|
||||
let spline = splines_from_points(Footprint::default(), &vector_node(Subpath::new_rect(DVec2::ZERO, DVec2::ONE * 100.))).await;
|
||||
let spline = super::spline(Footprint::default(), &vector_node(Subpath::new_rect(DVec2::ZERO, DVec2::ONE * 100.))).await;
|
||||
let spline = spline.one_item();
|
||||
assert_eq!(spline.stroke_bezier_paths().count(), 1);
|
||||
assert_eq!(spline.point_domain.positions(), &[DVec2::ZERO, DVec2::new(100., 0.), DVec2::new(100., 100.), DVec2::new(0., 100.)]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue