Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,26 @@ static DOCUMENT_NODE_TYPES: &[DocumentNodeType] = &[
outputs: &[FrontendGraphDataType::Raster],
properties: node_properties::quantize_properties,
},
DocumentNodeType {
name: "Gaussian Blur",
category: "Image Filters",
identifier: NodeIdentifier::new("graphene_core::raster::BlurNode", &[]),
inputs: &[
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
DocumentInputType::new("Radius", TaggedValue::U32(3), false),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use F64 (and round the value) and add a TODO to change this back to U32 once we have a working dynamic type system. But also this should probably be allowed to be a decimal value anyways, I think that's mathematically possible. (For example, in the FFT -> Blur in Frequency Domain -> IFFT approach, that should allow a decimal blur radius, and surely there's an equivalent for the spatial domain blur approach.)

DocumentInputType::new("Sigma", TaggedValue::F64(1.), false),
],
outputs: &[FrontendGraphDataType::Raster],
properties: node_properties::blur_image_properties,
},
DocumentNodeType {
name: "Cache",
category: "Structural",
identifier: NodeIdentifier::new("graphene_std::memo::CacheNode", &[concrete!("Image")]),
inputs: &[DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true)],
outputs: &[FrontendGraphDataType::Raster],
properties: node_properties::no_properties,
},
DocumentNodeType {
name: "Invert RGB",
category: "Image Adjustments",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ pub fn brighten_image_properties(document_node: &DocumentNode, node_id: NodeId,
vec![LayoutGroup::Row { widgets: brightness }, LayoutGroup::Row { widgets: contrast }]
}

pub fn blur_image_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let radius = number_widget(document_node, node_id, 1, "Radius", NumberInput::new().min(0.).max(20.).int(), true);
let sigma = number_widget(document_node, node_id, 2, "Sigma", NumberInput::new().min(0.).max(10000.), true);

vec![LayoutGroup::Row { widgets: radius }, LayoutGroup::Row { widgets: sigma }]
}

pub fn adjust_gamma_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let gamma = number_widget(document_node, node_id, 1, "Gamma", NumberInput::new().min(0.01), true);

Expand Down
2 changes: 1 addition & 1 deletion node-graph/gcore/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![no_std]
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(feature = "alloc")]
extern crate alloc;
Expand Down
41 changes: 41 additions & 0 deletions node-graph/gcore/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ impl<'n, O: Clone> Node<&'n O> for CloneNode {
input.clone()
}
}
impl<'n, O: Clone> Node<&'n O> for &CloneNode {
type Output = O;
fn eval(self, input: &'n O) -> Self::Output {
input.clone()
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FstNode;
Expand Down Expand Up @@ -189,6 +195,41 @@ impl IdNode {
}
}

/// Ascribe the node types
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct TypeNode<N, I, O>(pub N, pub PhantomData<(I, O)>);
impl<N: Node<I>, I> Node<I> for TypeNode<N, I, N::Output> {
type Output = N::Output;
fn eval(self, input: I) -> Self::Output {
self.0.eval(input)
}
}
impl<N: Node<I> + Copy, I> Node<I> for &TypeNode<N, I, N::Output> {
type Output = N::Output;
fn eval(self, input: I) -> Self::Output {
self.0.eval(input)
}
} /*
impl<N: RefNode<I>, I> Node<I> for &TypeNode<N, I, N::Output> {
type Output = N::Output;
fn eval(self, input: I) -> Self::Output {
self.0.eval_ref(input)
}
}*/

impl<N: Node<I>, I> TypeNode<N, I, N::Output> {
pub fn new(node: N) -> Self {
Self(node, PhantomData)
}
}

impl<N: Node<I> + Clone, I> Clone for TypeNode<N, I, N::Output> {
fn clone(&self) -> Self {
Self(self.0.clone(), self.1)
}
}
impl<N: Node<I> + Copy, I> Copy for TypeNode<N, I, N::Output> {}

pub struct MapResultNode<MN, I, E>(pub MN, pub PhantomData<(I, E)>);

impl<MN: Node<I>, I, E> Node<Result<I, E>> for MapResultNode<MN, I, E> {
Expand Down
Loading