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:
Firestar99
2025-07-24 13:32:10 +00:00
committed by GitHub
parent 59f3835c5d
commit e7b8b5a3b6
9 changed files with 426 additions and 421 deletions
+35
View File
@@ -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);
}
}
}
}