New nodes: Resample Points, Spline from Points (#1226)

* Create node (no implementation)

* Resampling - WIP

* use bezier::from_linear_dvec2

* Use from anchors instead of Bezier

* Tidy up anchor collection & subpath creation

* Add Spline from Points node (not implemented)

* Add spline from points node implementation

* Update resampling

* Update minimum density 0.01 -> 1.0

* Add a way to create a custom vector network

* Add spline from points node to spline tool

* Fix crash when no points

* Add anchor method to subpath

* Exact start and end point

* Fix compile errors from rebase

* Fix spline tool

* Rename 'Density' to 'Spacing'

* Fix transforms

* Only close subpaths with >1 anchor

* Fix compile

* Fix compile error

* Fix from points with many subpaths

* Fix new_cubic_spline crash with one point

* Rename to resample as polyline

* Fix div zero

* Fix missing file

* Fix resample

* Rename to resample points

---------

Co-authored-by: hypercube <0hypercube@gmail.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Chase
2023-08-30 20:21:39 +08:00
committed by GitHub
parent 3419e739af
commit 5acb2cff06
7 changed files with 94 additions and 3 deletions

View File

@@ -2170,6 +2170,27 @@ fn static_nodes() -> Vec<DocumentNodeType> {
properties: node_properties::circular_repeat_properties,
..Default::default()
},
DocumentNodeType {
name: "Resample Points",
category: "Vector",
identifier: NodeImplementation::proto("graphene_core::vector::ResamplePoints<_>"),
inputs: vec![
DocumentInputType::value("Vector Data", TaggedValue::VectorData(graphene_core::vector::VectorData::empty()), true),
DocumentInputType::value("Spacing", TaggedValue::F64(100.), false),
],
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
properties: node_properties::resample_points_properties,
..Default::default()
},
DocumentNodeType {
name: "Spline from Points",
category: "Vector",
identifier: NodeImplementation::proto("graphene_core::vector::SplineFromPointsNode"),
inputs: vec![DocumentInputType::value("Vector Data", TaggedValue::VectorData(graphene_core::vector::VectorData::empty()), true)],
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
properties: node_properties::no_properties,
..Default::default()
},
DocumentNodeType {
name: "Image Segmentation",
category: "Image Adjustments",

View File

@@ -1868,6 +1868,12 @@ pub fn circular_repeat_properties(document_node: &DocumentNode, node_id: NodeId,
vec![LayoutGroup::Row { widgets: angle_offset }, LayoutGroup::Row { widgets: radius }, LayoutGroup::Row { widgets: count }]
}
pub fn resample_points_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let spacing = number_widget(document_node, node_id, 1, "Spacing", NumberInput::default().min(1.), true);
vec![LayoutGroup::Row { widgets: spacing }]
}
/// Fill Node Widgets LayoutGroup
pub fn fill_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let fill_type_index = 1;