mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Add some raster protonodes
This commit is contained in:
committed by
Dennis Kobert
parent
2873c8fb00
commit
1a4a0db7e8
@@ -1,4 +1,5 @@
|
||||
use core::marker::PhantomData;
|
||||
use dyn_any::{DynAny, StaticType};
|
||||
use graphene_core::ops::FlatMapResultNode;
|
||||
use graphene_core::raster::color::Color;
|
||||
use graphene_core::structural::{ComposeNode, ConsNode};
|
||||
@@ -23,6 +24,17 @@ impl<I: IntoIterator<Item = S>, MN: Node<S>, S> MapNode<MN, I, S> {
|
||||
|
||||
pub struct MapImageNode<MN: Node<Color, Output = Color> + Copy>(pub MN);
|
||||
|
||||
impl<MN: Node<Color, Output = Color> + Copy> Node<Image> for MapImageNode<MN> {
|
||||
type Output = Image;
|
||||
fn eval(self, input: Image) -> Self::Output {
|
||||
Image {
|
||||
width: input.width,
|
||||
height: input.height,
|
||||
data: input.data.iter().map(|x| self.0.eval(*x)).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'n, MN: Node<Color, Output = Color> + Copy> Node<Image> for &'n MapImageNode<MN> {
|
||||
type Output = Image;
|
||||
fn eval(self, input: Image) -> Self::Output {
|
||||
@@ -40,7 +52,7 @@ impl<MN: Node<Color, Output = Color> + Copy> MapImageNode<MN> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, DynAny)]
|
||||
pub enum Error {
|
||||
IO(std::io::Error),
|
||||
Image(image::ImageError),
|
||||
@@ -86,7 +98,7 @@ impl<Reader: std::io::Read> Node<Reader> for BufferNode {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, DynAny)]
|
||||
pub struct Image {
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
|
||||
Reference in New Issue
Block a user