mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Add a gradient interpolation space attribute with sRGB Gamma (existing) and sRGB Linear (new) (#4412)
* Build dropdown menu entries from choice type metadata * Add a gradient interpolation color space attribute, blending stops in linear light by default * Add a Space interpolation dropdown to the color picker popover * Stamp legacy gradient ramps with their implicit gamma interpolation during deserialization * Resolve color-interpolation from SVG style blocks and fix cascade order among repeated declarations
This commit is contained in:
committed by
Dennis Kobert
parent
ea6f45ddc0
commit
f8975b7d94
@@ -11,7 +11,7 @@ use math_parser::value::{Number, Value};
|
||||
use rand::{Rng, SeedableRng};
|
||||
use std::ops::{Add, Mul, Rem, Sub};
|
||||
use vector_types::Gradient;
|
||||
use vector_types::markers::{GradientForm as GradientFormAttr, GradientSpread as GradientSpreadAttr};
|
||||
use vector_types::markers::{GradientForm as GradientFormAttr, GradientInterpolation as GradientInterpolationAttr, GradientSpread as GradientSpreadAttr};
|
||||
|
||||
/// 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.
|
||||
@@ -1214,12 +1214,18 @@ fn gradient_spread(_: impl Ctx, gradient: Gradient, gradient_spread: vector_type
|
||||
(gradient, Attr(gradient_spread))
|
||||
}
|
||||
|
||||
/// Sets the color space each gradient in the input list blends between its stops with: linear light or gamma-encoded sRGB.
|
||||
#[node_macro::node(category("Gradient"))]
|
||||
fn gradient_interpolation(_: impl Ctx, gradient: Gradient, gradient_interpolation: vector_types::GradientInterpolation) -> (Gradient, Attr<GradientInterpolationAttr>) {
|
||||
(gradient, Attr(gradient_interpolation))
|
||||
}
|
||||
|
||||
/// Sets the position of each of a gradient's stops, a factor from 0 to 1 along the gradient.
|
||||
///
|
||||
/// A list shorter than the stop count repeats its last value, a longer list is truncated, and an empty list sets each stop to its default evenly spaced position.
|
||||
#[node_macro::node(category("Gradient"))]
|
||||
fn gradient_positions(_: impl Ctx, mut gradient: Gradient, positions: IList<f64>) -> Gradient {
|
||||
let positions: Vec<f64> = positions.iter().collect();
|
||||
fn gradient_positions(_: impl Ctx, mut gradient: Gradient, positions: List<f64>) -> Gradient {
|
||||
let positions: Vec<f64> = positions.iter_element_values().copied().collect();
|
||||
gradient.set_positions(&positions);
|
||||
gradient
|
||||
}
|
||||
@@ -1230,8 +1236,8 @@ fn gradient_positions(_: impl Ctx, mut gradient: Gradient, positions: IList<f64>
|
||||
///
|
||||
/// A list shorter than the stop count repeats its last value, a longer list is truncated, and an empty list sets each midpoint to its default of 0.5.
|
||||
#[node_macro::node(category("Gradient"))]
|
||||
fn gradient_midpoints(_: impl Ctx, mut gradient: Gradient, midpoints: IList<f64>) -> Gradient {
|
||||
let midpoints: Vec<f64> = midpoints.iter().collect();
|
||||
fn gradient_midpoints(_: impl Ctx, mut gradient: Gradient, midpoints: List<f64>) -> Gradient {
|
||||
let midpoints: Vec<f64> = midpoints.iter_element_values().copied().collect();
|
||||
gradient.set_midpoints(&midpoints);
|
||||
gradient
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user