mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 02:48:12 +08:00
Rework Gradient into a newtype of List<Color> with optional position and midpoint attributes (#4397)
* Rework Gradient into a newtype of List<Color> with optional position and midpoint attributes * Fix Vello stopless-gradient fallback coverage, empty legacy gradient tables, the node docs gradient swatch, NaN position elision, and wired setter input overwrites
This commit is contained in:
@@ -18,17 +18,18 @@ async fn gradient_map<T: Adjust<Color> + Send>(
|
||||
Gradient,
|
||||
)]
|
||||
image: Item<T>,
|
||||
gradient: Item<Gradient>,
|
||||
#[default(Color::BLACK, Color::WHITE)] gradient: Item<Gradient>,
|
||||
reverse: Item<bool>,
|
||||
) -> Item<T> {
|
||||
let mut image = image;
|
||||
let spread_method = gradient.attribute_cloned_or_default::<vector_types::GradientSpreadMethod>(core_types::ATTR_SPREAD_METHOD);
|
||||
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.evaluate(intensity as f64, spread_method)
|
||||
});
|
||||
|
||||
image
|
||||
|
||||
Reference in New Issue
Block a user