mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Copy to Points node: add scale/rotation randomization parameters (#1592)
* WIP, transforms broken with rot/scale * Transform around bounding box centre * Add units and tooltips --------- Co-authored-by: 0hypercube <0hypercube@gmail.com>
This commit is contained in:
@@ -2644,11 +2644,14 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
||||
name: "Copy to Points",
|
||||
category: "Vector",
|
||||
// TODO: Wrap this implementation with a document node that has a cache node so the output is cached?
|
||||
implementation: NodeImplementation::proto("graphene_core::vector::CopyToPoints<_, _>"),
|
||||
implementation: NodeImplementation::proto("graphene_core::vector::CopyToPoints<_, _, _, _, _>"),
|
||||
manual_composition: Some(concrete!(Footprint)),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Points", TaggedValue::VectorData(graphene_core::vector::VectorData::empty()), true),
|
||||
DocumentInputType::value("Instance", TaggedValue::VectorData(graphene_core::vector::VectorData::empty()), true),
|
||||
DocumentInputType::value("Random Scale Min", TaggedValue::F32(1.), false),
|
||||
DocumentInputType::value("Random Scale Max", TaggedValue::F32(1.), false),
|
||||
DocumentInputType::value("Random Rotation", TaggedValue::F32(0.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::copy_to_points_properties,
|
||||
|
||||
@@ -2036,15 +2036,39 @@ pub fn circular_repeat_properties(document_node: &DocumentNode, node_id: NodeId,
|
||||
}
|
||||
|
||||
pub fn copy_to_points_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let instance = vector_widget(document_node, node_id, 1, "Spacing", true);
|
||||
let instance = vector_widget(document_node, node_id, 1, "Instance", true);
|
||||
|
||||
vec![LayoutGroup::Row { widgets: instance }]
|
||||
let random_scale_min = number_widget(
|
||||
document_node,
|
||||
node_id,
|
||||
2,
|
||||
"Random Scale Min",
|
||||
NumberInput::default().min(0.).mode_range().range_min(Some(0.)).range_max(Some(2.)).unit("x"),
|
||||
true,
|
||||
);
|
||||
let random_scale_max = number_widget(
|
||||
document_node,
|
||||
node_id,
|
||||
3,
|
||||
"Random Scale Max",
|
||||
NumberInput::default().min(0.).mode_range().range_min(Some(0.)).range_max(Some(2.)).unit("x"),
|
||||
true,
|
||||
);
|
||||
|
||||
let random_rotation = number_widget(document_node, node_id, 4, "Random Rotation", NumberInput::default().min(0.).max(360.).mode_range().unit("°"), true);
|
||||
|
||||
vec![
|
||||
LayoutGroup::Row { widgets: instance }.with_tooltip("Artwork to be copied and placed at each point"),
|
||||
LayoutGroup::Row { widgets: random_scale_min }.with_tooltip("Minimum range of randomized sizes given to each instance"),
|
||||
LayoutGroup::Row { widgets: random_scale_max }.with_tooltip("Maximum range of randomized sizes given to each instance"),
|
||||
LayoutGroup::Row { widgets: random_rotation }.with_tooltip("Range of randomized angles given to each instance, in degrees ranging from furthest clockwise to counterclockwise"),
|
||||
]
|
||||
}
|
||||
|
||||
pub fn sample_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);
|
||||
let start_offset = number_widget(document_node, node_id, 2, "Start Offset", NumberInput::default().min(0.), true);
|
||||
let stop_offset = number_widget(document_node, node_id, 3, "Stop Offset", NumberInput::default().min(0.), true);
|
||||
let spacing = number_widget(document_node, node_id, 1, "Spacing", NumberInput::default().min(1.).unit(" px"), true);
|
||||
let start_offset = number_widget(document_node, node_id, 2, "Start Offset", NumberInput::default().min(0.).unit(" px"), true);
|
||||
let stop_offset = number_widget(document_node, node_id, 3, "Stop Offset", NumberInput::default().min(0.).unit(" px"), true);
|
||||
let adaptive_spacing = bool_widget(document_node, node_id, 4, "Adaptive Spacing", true);
|
||||
|
||||
vec![
|
||||
|
||||
Reference in New Issue
Block a user