mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 00:18:11 +08:00
Shaders: graster-nodes no-std prep (#2924)
* raster-nodes: remove commented out index node * raster-nodes: move `CubicSplines` to separate mod * raster-nodes: create `mod blending_nodes` and move assoc nodes * raster-nodes: move node `gradient_map` to its own mod
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
use graphene_core::Color;
|
||||
use graphene_core::gradient::GradientStops;
|
||||
use graphene_core::raster_types::{CPU, RasterDataTable};
|
||||
|
||||
pub trait Adjust<P> {
|
||||
fn adjust(&mut self, map_fn: impl Fn(&P) -> P);
|
||||
}
|
||||
impl Adjust<Color> for Color {
|
||||
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
|
||||
*self = map_fn(self);
|
||||
}
|
||||
}
|
||||
impl Adjust<Color> for Option<Color> {
|
||||
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
|
||||
if let Some(v) = self {
|
||||
*v = map_fn(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Adjust<Color> for GradientStops {
|
||||
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
|
||||
for (_pos, c) in self.iter_mut() {
|
||||
*c = map_fn(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Adjust<Color> for RasterDataTable<CPU> {
|
||||
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
|
||||
for instance in self.instance_mut_iter() {
|
||||
for c in instance.instance.data_mut().data.iter_mut() {
|
||||
*c = map_fn(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user