mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 16:38:14 +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:
committed by
Dennis Kobert
parent
8504564f5d
commit
f6b4ce71e6
@@ -17,18 +17,19 @@ fn gradient_map<T: Adjust<Color> + Clone + Send + Sync + core_types::CacheHash +
|
||||
Gradient,
|
||||
)]
|
||||
mut image: T,
|
||||
gradient: IList<Gradient>,
|
||||
#[default(Color::BLACK, Color::WHITE)] gradient: IList<Gradient>,
|
||||
reverse: bool,
|
||||
) -> T {
|
||||
if gradient.is_empty() {
|
||||
return image;
|
||||
}
|
||||
let spread_method = gradient.lane(0).attr::<vector_types::markers::SpreadMethod>();
|
||||
let gradient = gradient.element_ref(0);
|
||||
|
||||
image.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