Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion editor/src/messages/portfolio/document_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
aliases: &["graphene_math_nodes::GradientTableValueNode", "graphene_core::ops::GradientTableValueNode"],
},
NodeReplacement {
node: graphene_std::math_nodes::gradient_value::IDENTIFIER,
node: graphene_std::math_nodes::gradient_stops_value::IDENTIFIER,
aliases: &["graphene_math_nodes::GradientValueNode", "graphene_core::ops::GradientValueNode"],
},
NodeReplacement {
Expand Down
15 changes: 11 additions & 4 deletions node-graph/nodes/math/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use math_parser::value::{Number, Value};
use num_traits::Pow;
use rand::{Rng, SeedableRng};
use std::ops::{Add, Div, Mul, Rem, Sub};
use vector_types::GradientStops;
use vector_types::gradient::Gradient;
use vector_types::{GradientStops, GradientType};

/// The struct that stores the context for the maths parser.
/// This is currently just limited to supplying `a` and `b` until we add better node graph support and UI for variadic inputs.
Expand Down Expand Up @@ -764,18 +765,24 @@ fn color_value(_: impl Ctx, _primary: (), #[default(Color::BLACK)] color: Table<
color
}

/// Constructs a gradient value which may be set to any sequence of color stops to represent the transition between colors.
/// Constructs a gradient stops value which may be set to any sequence of color stops to represent the transition between colors.
#[node_macro::node(category("Value"))]
fn gradient_value(_: impl Ctx, _primary: (), gradient: GradientStops) -> GradientStops {
fn gradient_stops_value(_: impl Ctx, _primary: (), gradient: GradientStops) -> GradientStops {
gradient
}

/// Constructs a gradient value which may be set to any sequence of color stops to represent the transition between colors.
/// Constructs a gradient stops value which may be set to any sequence of color stops to represent the transition between colors.
#[node_macro::node(category("Value"))]
fn gradient_table_value(_: impl Ctx, _primary: (), gradient: GradientStops) -> Table<GradientStops> {
Table::new_from_element(gradient)
}

/// Constructs a gradient with color stops, type (linear/radial), and start/end positions.
#[node_macro::node(category("Value"))]
fn gradient_value(_: impl Ctx, _primary: (), stops: GradientStops, gradient_type: GradientType, #[default(DVec2::new(0., 0.5))] start: DVec2, #[default(DVec2::new(1., 0.5))] end: DVec2) -> Gradient {
Gradient { stops, gradient_type, start, end }
}

/// Gets the color at the specified position along the gradient, given a position from 0 (left) to 1 (right).
#[node_macro::node(category("Color"))]
fn sample_gradient(_: impl Ctx, _primary: (), gradient: GradientStops, position: Fraction) -> Table<Color> {
Expand Down