Add the "Perceptual" and "Classic" families of gradient spaces with OkLab as the new default (#4415)

* Add an OkLab gradient interpolation space and make it the new default

* Fix the Properties panel fill row resetting the gradient interpolation space to the default

* Add OkLch, Lab, LCh, and HSL gradient interpolation spaces

* Add a hue direction attribute and picker choice for polar gradient interpolation spaces

* Add an HSV gradient interpolation space

* Rename the sRGB Linear and sRGB Gamma gradient spaces to RGB Linear and RGB Gamma

* Divide the gradient interpolation dropdown between absolute and relative color spaces

* Rename the OkLch gradient interpolation space to OkLCh for channel-notation capitalization

* Shorten the color picker popover's hue direction row label to Arc

* Call the Gradient Interpolation node's parameter Space and extend the picker tooltip title to match

* Rename the gradient interpolation attribute and type family to gradient space

* Rename the gradient tool's gradient space transform to gradient to viewport transform

* Add serde aliases and a node replacement covering the gradient space renames

* Give the gradient space choices artist-facing labels and reorder the dropdown sections

* Add a Gradient Hue Direction node and its attribute read node

* Say interpolate instead of blend for gradient stop color traversal in docs and tooltips

* Label the polar perceptual gradient spaces as Perceptual Hue and group the dropdown sections by geometry

* Add a migration alias covering the gradient space attribute reader rename

* Carry the gradient hue direction attribute through boolean operations

* Register GradientHueDirection wire types in the node registry
This commit is contained in:
Keavon Chambers
2026-08-06 02:40:25 -07:00
committed by Dennis Kobert
parent 11436cfc80
commit be42a0aada
29 changed files with 886 additions and 410 deletions

View File

@@ -614,7 +614,9 @@ tagged_value! {
GradientForm(vector::style::GradientForm),
#[serde(alias = "GradientSpreadMethod")] // TODO: Eventually remove this document upgrade code
GradientSpread(vector::style::GradientSpread),
GradientInterpolation(vector::style::GradientInterpolation),
#[serde(alias = "GradientInterpolation")] // TODO: Eventually remove this document upgrade code
GradientSpace(vector::style::GradientSpace),
GradientHueDirection(vector::style::GradientHueDirection),
ReferencePoint(vector::ReferencePoint),
CentroidType(vector::misc::CentroidType),
BooleanOperation(vector::misc::BooleanOperation),
@@ -868,7 +870,7 @@ pub fn deserialize_tagged_value_with_legacy_migration<'de, D: serde::Deserialize
&& array.is_empty()
{
let ramp = GradientRamp {
gradient_interpolation: vector::style::GradientInterpolation::SrgbGamma,
gradient_space: vector::style::GradientSpace::RgbGamma,
..Default::default()
};
return Ok(MemoHash::new(TaggedValue::GradientRamp(ramp)));
@@ -1093,7 +1095,7 @@ mod paint_default_parsing {
#[cfg(test)]
mod gradient_shape_migration {
use graphic_types::vector_types::{GradientInterpolation, GradientSpread};
use graphic_types::vector_types::{GradientSpace, GradientSpread};
use super::*;
@@ -1121,26 +1123,22 @@ mod gradient_shape_migration {
let json = serde_json::to_value(&value).unwrap();
assert!(json.get("GradientRamp").and_then(|payload| payload.get("stops")).is_some(), "the payload should nest its stops: {json}");
assert_eq!(
json.get("GradientRamp").and_then(|payload| payload.get("gradient_interpolation")),
Some(&serde_json::json!("SrgbLinear")),
"the interpolation should serialize even at its default, marking the ramp as post-legacy: {json}"
json.get("GradientRamp").and_then(|payload| payload.get("gradient_space")),
Some(&serde_json::json!("OkLab")),
"the space should serialize even at its default, marking the ramp as post-legacy: {json}"
);
assert_eq!(load(json), value);
}
// TODO: Eventually remove this document upgrade code
#[test]
fn ramp_without_interpolation_field_reads_as_legacy_gamma() {
fn ramp_without_space_field_reads_as_legacy_gamma() {
let json = serde_json::json!({ "GradientRamp": { "stops": { "color": [white(), white()] } } });
let TaggedValue::GradientRamp(ramp) = load(json) else {
panic!("the ramp payload should become a gradient ramp value")
};
assert_eq!(
ramp.gradient_interpolation,
GradientInterpolation::SrgbGamma,
"a ramp saved before the field existed should read as gamma"
);
assert_eq!(ramp.gradient_space, GradientSpace::RgbGamma, "a ramp saved before the field existed should read as gamma");
}
// TODO: Eventually remove this document upgrade code
@@ -1150,7 +1148,7 @@ mod gradient_shape_migration {
let TaggedValue::GradientRamp(ramp) = load(json) else {
panic!("the flat stops should become a gradient ramp value")
};
assert_eq!(ramp.gradient_interpolation, GradientInterpolation::SrgbGamma, "the pre-ramp flat form should carry the era's gamma");
assert_eq!(ramp.gradient_space, GradientSpace::RgbGamma, "the pre-ramp flat form should carry the era's gamma");
let gradient = Gradient::from(ramp);
assert_eq!(gradient.positions(), vec![0., 0.25]);
@@ -1164,7 +1162,7 @@ mod gradient_shape_migration {
let TaggedValue::GradientRamp(ramp) = load(json) else {
panic!("the tuple stops should become a gradient ramp value")
};
assert_eq!(ramp.gradient_interpolation, GradientInterpolation::SrgbGamma, "the pre-ramp tuple form should carry the era's gamma");
assert_eq!(ramp.gradient_space, GradientSpace::RgbGamma, "the pre-ramp tuple form should carry the era's gamma");
let gradient = Gradient::from(ramp);
assert_eq!(gradient.positions(), vec![0., 1.]);
@@ -1176,7 +1174,7 @@ mod gradient_shape_migration {
fn empty_legacy_gradient_table_degrades_to_the_default() {
let json = serde_json::json!({ "GradientTable": { "element": [] } });
let expected = GradientRamp {
gradient_interpolation: GradientInterpolation::SrgbGamma,
gradient_space: GradientSpace::RgbGamma,
..Default::default()
};
assert_eq!(load(json), TaggedValue::GradientRamp(expected));