Add raster module to graphene_core

This commit is contained in:
Dennis
2022-08-04 12:34:05 +02:00
committed by Keavon Chambers
parent c235c7f252
commit 83ff548596
10 changed files with 220 additions and 48 deletions

View File

@@ -0,0 +1,18 @@
use core::marker::PhantomData;
use crate::Node;
use self::color::Color;
pub mod color;
pub struct GrayscaleNode<'n, N: Node<'n, Output = Color>>(pub N, PhantomData<&'n ()>);
impl<'n, N: Node<'n, Output = Color>> Node<'n> for GrayscaleNode<'n, N> {
type Output = Color;
fn eval(&'n self) -> Color {
let color = self.0.eval();
let avg = (color.r() + color.g() + color.b()) / 3.0;
Color::from_rgbaf32(avg, avg, avg, color.a()).expect("Grayscale node created an invalid color")
}
}