Convert copy to points, sample polyline, scatter, spline, jitter, and assign colors

This commit is contained in:
Dennis Kobert
2026-08-22 20:59:37 +00:00
parent 5f6c18893e
commit 3126a5b278
5 changed files with 379 additions and 291 deletions

View File

@@ -1391,6 +1391,17 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
if reset_node_definitions_on_open && let Some(reference) = document.network_interface.reference(node_id, network_path) {
let node_definition = resolve_document_node_type(&reference)?;
document.network_interface.replace_implementation(node_id, network_path, &mut node_definition.default_node_template());
// The leveled-records flip moved the Copy to Points content wire ahead of the points wire.
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::copy_to_points::IDENTIFIER) {
let mut node_template = node_definition.default_node_template();
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[1].clone(), network_path);
document.network_interface.set_input(&InputConnector::node(*node_id, 1), old_inputs[0].clone(), network_path);
for (index, input) in old_inputs.into_iter().enumerate().skip(2) {
document.network_interface.set_input(&InputConnector::node(*node_id, index), input, network_path);
}
}
}
// Rebuild stale Merge/Artboard subgraphs that still use the removed LegacyLayerExtendNode internally

View File

@@ -206,16 +206,16 @@ impl Fsm for FillToolFsmState {
mod test_fill {
pub use crate::test_utils::test_prelude::*;
use graphene_std::color::SRGBA8;
use graphene_std::list::List;
use graphene_std::vector::fill;
use graphene_std::Graphic;
async fn get_fills(editor: &mut EditorTestUtils) -> Vec<List<Color>> {
async fn get_fills(editor: &mut EditorTestUtils) -> Vec<Graphic> {
let instrumented = match editor.eval_graph().await {
Ok(instrumented) => instrumented,
Err(e) => panic!("Failed to evaluate graph: {e}"),
};
instrumented.grab_all_input::<fill::FillInput<List<Color>>>(&editor.runtime).collect()
instrumented.grab_all_input::<fill::FillInput>(&editor.runtime).collect()
}
#[tokio::test]
@@ -245,7 +245,8 @@ mod test_fill {
editor.click_tool(ToolType::Fill, MouseKeys::LEFT, DVec2::new(2., 2.), ModifierKeys::empty()).await;
let fills = get_fills(&mut editor).await;
assert_eq!(fills.len(), 1);
let color = fills.first().unwrap().element(0).expect("Color is stored in the list");
let Some(Graphic::Color(color_list)) = fills.first() else { panic!("the fill paint holds a color") };
let color = color_list.element(0).expect("Color is stored in the list");
assert_eq!(SRGBA8::from(*color), SRGBA8::from(Color::GREEN));
}
@@ -258,7 +259,8 @@ mod test_fill {
editor.click_tool(ToolType::Fill, MouseKeys::LEFT, DVec2::new(2., 2.), ModifierKeys::SHIFT).await;
let fills = get_fills(&mut editor).await;
assert_eq!(fills.len(), 1);
let color = fills.first().unwrap().element(0).expect("Color is stored in the list");
let Some(Graphic::Color(color_list)) = fills.first() else { panic!("the fill paint holds a color") };
let color = color_list.element(0).expect("Color is stored in the list");
assert_eq!(SRGBA8::from(*color), SRGBA8::from(Color::YELLOW));
}
}

View File

@@ -2013,10 +2013,9 @@ mod test_gradient {
use glam::DAffine2;
use graph_craft::document::value::TaggedValue;
use graphene_std::color::SRGBA8;
use graphene_std::list::List;
use graphene_std::vector::style::{GradientSpreadMethod, build_transform_with_y_preservation};
use graphene_std::vector::{GradientStop, GradientStops, fill};
use graphene_std::{Graphic, NodeInputDecleration};
use graphene_std::NodeInputDecleration;
use super::gradient_space_transform;