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
This commit is contained in:
Keavon Chambers
2026-08-08 01:20:55 -07:00
committed by Dennis Kobert
parent ed738b8e5c
commit ca615fd6fc
3 changed files with 11 additions and 9 deletions

View File

@@ -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:?}");
};

View File

@@ -264,6 +264,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"],
@@ -405,10 +409,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"],

View File

@@ -1259,11 +1259,13 @@ fn gradient_midpoints(_: impl Ctx, mut gradient: Gradient, midpoints: IList<f64>
/// Evaluates the color at the specified position along the gradient, given a position from 0 (left) to 1 (right). Positions beyond that range follow the gradient's `gradient_spread` attribute: Pad (default), Reflect, Repeat, or Clear. Colors between stops interpolate in the gradient's `gradient_space` color space.
#[node_macro::node(category("Color"))]
fn sample_gradient(
fn evaluate_gradient(
ctx: impl Ctx + ExtractIndex + InjectIndex + Copy,
_primary: (),
#[default(Color::BLACK, Color::WHITE)] gradient: IList<Gradient>,
position: Fraction,
#[range]
#[soft(0..1)]
position: f64,
) -> Result<IList<Color>, Interrupt> {
// An unwired gradient serves an empty level: no color
if gradient.is_empty() || ctx.index() != 0 {