From b22158b02237e9259f73165cacf56c517fefc27d Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Sat, 8 Aug 2026 01:20:55 -0700 Subject: [PATCH] Rename the 'Sample Gradient' node to 'Evaluate Gradient' (#4422) * Rename the 'Sample Gradient' node to 'Evaluate Gradient' * Let the Evaluate Gradient node's position reach the out-of-range values its spread modes handle --- .../portfolio/document/storage_tests/round_trip_tests.rs | 6 +++--- editor/src/messages/portfolio/document_migration.rs | 8 ++++---- node-graph/nodes/math/src/lib.rs | 9 ++++++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/editor/src/messages/portfolio/document/storage_tests/round_trip_tests.rs b/editor/src/messages/portfolio/document/storage_tests/round_trip_tests.rs index 95728d7afc..4cd4ef0b17 100644 --- a/editor/src/messages/portfolio/document/storage_tests/round_trip_tests.rs +++ b/editor/src/messages/portfolio/document/storage_tests/round_trip_tests.rs @@ -801,9 +801,9 @@ async fn legacy_four_input_fill_migrates_to_the_split_transform_shape() { "the transform input should hold a matrix, but became {transform:?}" ); - // The Sample Gradient parameter held the tuple-form stops, which parse as the ramp value with even positions elided - let sample_gradient_node = &network.nodes[&graph_craft::document::NodeId(2)]; - let stops = sample_gradient_node.input_value(graphene_std::math_nodes::sample_gradient::GradientInput); + // The Evaluate Gradient parameter held the tuple-form stops, which parse as the ramp value with even positions elided + let evaluate_gradient_node = &network.nodes[&graph_craft::document::NodeId(2)]; + let stops = evaluate_gradient_node.input_value(graphene_std::math_nodes::evaluate_gradient::GradientInput); let Some(TaggedValue::GradientRamp(ramp)) = stops else { panic!("the legacy stops parameter should become a gradient ramp value, but became {stops:?}"); }; diff --git a/editor/src/messages/portfolio/document_migration.rs b/editor/src/messages/portfolio/document_migration.rs index 7b5dfbb0b1..7aed7ebf49 100644 --- a/editor/src/messages/portfolio/document_migration.rs +++ b/editor/src/messages/portfolio/document_migration.rs @@ -258,6 +258,10 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[ node: graphene_std::math_nodes::equals::IDENTIFIER, aliases: &["graphene_math_nodes::EqualsNode", "graphene_core::ops::EqualsNode"], }, + NodeReplacement { + node: graphene_std::math_nodes::evaluate_gradient::IDENTIFIER, + aliases: &["math_nodes::SampleGradientNode", "graphene_math_nodes::SampleGradientNode", "graphene_core::ops::SampleGradientNode"], + }, NodeReplacement { node: graphene_std::math_nodes::exponent::IDENTIFIER, aliases: &["graphene_math_nodes::ExponentNode", "graphene_core::ops::ExponentNode"], @@ -399,10 +403,6 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[ node: graphene_std::math_nodes::round::IDENTIFIER, aliases: &["graphene_math_nodes::RoundNode", "graphene_core::ops::RoundNode"], }, - NodeReplacement { - node: graphene_std::math_nodes::sample_gradient::IDENTIFIER, - aliases: &["graphene_math_nodes::SampleGradientNode", "graphene_core::ops::SampleGradientNode"], - }, NodeReplacement { node: graphene_std::math_nodes::sine::IDENTIFIER, aliases: &["graphene_math_nodes::SineNode", "graphene_core::ops::SineNode"], diff --git a/node-graph/nodes/math/src/lib.rs b/node-graph/nodes/math/src/lib.rs index 184eb55a5a..3bcec895f2 100644 --- a/node-graph/nodes/math/src/lib.rs +++ b/node-graph/nodes/math/src/lib.rs @@ -1451,7 +1451,14 @@ fn gradient_midpoints(_: impl Ctx, gradient: Item, midpoints: List, position: Item) -> Item { +fn evaluate_gradient( + _: impl Ctx, + _primary: (), + #[default(Color::BLACK, Color::WHITE)] gradient: Item, + #[range] + #[soft(0..1)] + position: Item, +) -> Item { let settings = vector_types::GradientSettings::from(&gradient); let color = gradient.element().evaluate(*position.element(), settings); Item::new_from_element(color)