Make gradient evaluation follow the ramp's interpolation space attribute (#4414)

This commit is contained in:
Keavon Chambers
2026-08-05 19:32:51 -07:00
committed by GitHub
parent faed7f81bf
commit 3f082c881f
7 changed files with 49 additions and 31 deletions
+2 -1
View File
@@ -23,13 +23,14 @@ async fn gradient_map<T: Adjust<Color> + Send>(
) -> Item<T> {
let mut image = image;
let gradient_spread = gradient.attribute_cloned_or_default::<vector_types::GradientSpread>(core_types::ATTR_GRADIENT_SPREAD);
let gradient_interpolation = gradient.attribute_cloned_or_default::<vector_types::GradientInterpolation>(core_types::ATTR_GRADIENT_INTERPOLATION);
let gradient = gradient.into_element();
let reverse = reverse.into_element();
image.element_mut().adjust(|color| {
let intensity = color.luminance_rec_709();
let intensity = if reverse { 1. - intensity } else { intensity };
gradient.evaluate(intensity as f64, gradient_spread)
gradient.evaluate(intensity as f64, gradient_spread, gradient_interpolation)
});
image