Improve naming of several proto nodes

This commit is contained in:
Keavon Chambers 2023-12-08 14:50:01 -08:00
parent 747dae3bb6
commit d082b15abb
24 changed files with 288 additions and 303 deletions

View file

@ -536,7 +536,7 @@ def migrate(name, new_name):
"has_primary_output": True,
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -64,7 +64,7 @@ impl Default for Document {
DocumentNode {
name: "EditorApi".to_string(),
inputs: vec![NodeInput::Network(concrete!(WasmEditorApi))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode")),
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default()
},
DocumentNode {

File diff suppressed because one or more lines are too long

View file

@ -83,7 +83,7 @@ pub enum NodeImplementation {
impl Default for NodeImplementation {
fn default() -> Self {
Self::ProtoNode(NodeIdentifier::new("graphene_core::ops::IdNode"))
Self::ProtoNode(NodeIdentifier::new("graphene_core::ops::IdentityNode"))
}
}
@ -146,7 +146,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Boolean",
category: "Inputs",
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
identifier: NodeImplementation::proto("graphene_core::ops::IdentityNode"),
inputs: vec![DocumentInputType::value("Bool", TaggedValue::Bool(true), false)],
outputs: vec![DocumentOutputType::new("Out", FrontendGraphDataType::Boolean)],
properties: node_properties::boolean_properties,
@ -155,7 +155,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Number",
category: "Inputs",
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
identifier: NodeImplementation::proto("graphene_core::ops::IdentityNode"),
inputs: vec![DocumentInputType::value("Number", TaggedValue::F32(0.), false)],
outputs: vec![DocumentOutputType::new("Out", FrontendGraphDataType::Number)],
properties: node_properties::number_properties,
@ -164,7 +164,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Color",
category: "Inputs",
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
identifier: NodeImplementation::proto("graphene_core::ops::IdentityNode"),
inputs: vec![DocumentInputType::value("Color", TaggedValue::OptionalColor(None), false)],
outputs: vec![DocumentOutputType::new("Out", FrontendGraphDataType::Color)],
properties: node_properties::color_properties,
@ -173,7 +173,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Identity",
category: "Structural",
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
identifier: NodeImplementation::proto("graphene_core::ops::IdentityNode"),
inputs: vec![DocumentInputType {
name: "In",
data_type: FrontendGraphDataType::General,
@ -186,7 +186,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Monitor",
category: "Structural",
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
identifier: NodeImplementation::proto("graphene_core::ops::IdentityNode"),
inputs: vec![DocumentInputType {
name: "In",
data_type: FrontendGraphDataType::General,
@ -504,7 +504,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNode {
name: "EditorApi".to_string(),
inputs: vec![NodeInput::Network(concrete!(WasmEditorApi))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode")),
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default()
},
DocumentNode {
@ -731,7 +731,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Color Channel",
category: "Image Adjustments",
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
identifier: NodeImplementation::proto("graphene_core::ops::IdentityNode"),
inputs: vec![DocumentInputType::value("Channel", TaggedValue::RedGreenBlue(RedGreenBlue::Red), false)],
outputs: vec![DocumentOutputType::new("Out", FrontendGraphDataType::General)],
properties: node_properties::color_channel_properties,
@ -740,7 +740,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Blend Mode Value",
category: "Inputs",
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
identifier: NodeImplementation::proto("graphene_core::ops::IdentityNode"),
inputs: vec![DocumentInputType::value("Blend Mode", TaggedValue::BlendMode(BlendMode::Normal), false)],
outputs: vec![DocumentOutputType::new("Out", FrontendGraphDataType::General)],
properties: node_properties::blend_mode_value_properties,
@ -799,7 +799,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNode {
name: "Identity".to_string(),
inputs: vec![NodeInput::Network(concrete!(ImageFrame<Color>))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode")),
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default()
},
DocumentNode {
@ -883,7 +883,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Image",
category: "Ignore",
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
identifier: NodeImplementation::proto("graphene_core::ops::IdentityNode"),
inputs: vec![DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), false)],
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
properties: |_document_node, _node_id, _context| node_properties::string_properties("A bitmap image embedded in this node"),
@ -1742,7 +1742,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Add",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::AddParameterNode<_>"),
identifier: NodeImplementation::proto("graphene_core::ops::AddNode<_>"),
inputs: vec![
DocumentInputType::value("Primary", TaggedValue::F32(0.), true),
DocumentInputType::value("Addend", TaggedValue::F32(0.), false),
@ -1754,7 +1754,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Subtract",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::AddParameterNode<_>"),
identifier: NodeImplementation::proto("graphene_core::ops::AddNode<_>"),
inputs: vec![
DocumentInputType::value("Primary", TaggedValue::F32(0.), true),
DocumentInputType::value("Subtrahend", TaggedValue::F32(0.), false),
@ -1766,7 +1766,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Divide",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::DivideParameterNode<_>"),
identifier: NodeImplementation::proto("graphene_core::ops::DivideNode<_>"),
inputs: vec![
DocumentInputType::value("Primary", TaggedValue::F32(0.), true),
DocumentInputType::value("Divisor", TaggedValue::F32(0.), false),
@ -1778,7 +1778,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Multiply",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::MultiplyParameterNode<_>"),
identifier: NodeImplementation::proto("graphene_core::ops::MultiplyNode<_>"),
inputs: vec![
DocumentInputType::value("Primary", TaggedValue::F32(0.), true),
DocumentInputType::value("Multiplicand", TaggedValue::F32(0.), false),
@ -1790,7 +1790,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Exponent",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::ExponentParameterNode<_>"),
identifier: NodeImplementation::proto("graphene_core::ops::ExponentNode<_>"),
inputs: vec![
DocumentInputType::value("Primary", TaggedValue::F32(0.), true),
DocumentInputType::value("Power", TaggedValue::F32(0.), false),
@ -1811,7 +1811,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Ceil",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::CeilNode"),
identifier: NodeImplementation::proto("graphene_core::ops::CeilingNode"),
inputs: vec![DocumentInputType::value("Primary", TaggedValue::F32(0.), true)],
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Number)],
properties: node_properties::node_no_properties,
@ -1829,7 +1829,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Absolute Value",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::AbsoluteNode"),
identifier: NodeImplementation::proto("graphene_core::ops::AbsoluteValue"),
inputs: vec![DocumentInputType::value("Primary", TaggedValue::F32(0.), true)],
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Number)],
properties: node_properties::node_no_properties,
@ -1838,7 +1838,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Logarithm",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::LogParameterNode<_>"),
identifier: NodeImplementation::proto("graphene_core::ops::LogarithmNode<_>"),
inputs: vec![
DocumentInputType::value("Primary", TaggedValue::F32(0.), true),
DocumentInputType::value("Base", TaggedValue::F32(0.), true),
@ -1850,7 +1850,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Natural Logarithm",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::NaturalLogNode"),
identifier: NodeImplementation::proto("graphene_core::ops::NaturalLogarithmNode"),
inputs: vec![DocumentInputType::value("Primary", TaggedValue::F32(0.), true)],
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Number)],
properties: node_properties::node_no_properties,
@ -1886,7 +1886,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Max",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::MaxParameterNode<_>"),
identifier: NodeImplementation::proto("graphene_core::ops::MaximumNode<_>"),
inputs: vec![
DocumentInputType::value("Operand A", TaggedValue::F32(0.), true),
DocumentInputType::value("Operand B", TaggedValue::F32(0.), true),
@ -1898,7 +1898,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Min",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::MinParameterNode<_>"),
identifier: NodeImplementation::proto("graphene_core::ops::MinimumNode<_>"),
inputs: vec![
DocumentInputType::value("Operand A", TaggedValue::F32(0.), true),
DocumentInputType::value("Operand B", TaggedValue::F32(0.), true),
@ -1910,7 +1910,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Equals",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::EqParameterNode<_>"),
identifier: NodeImplementation::proto("graphene_core::ops::EqualsNode<_>"),
inputs: vec![
DocumentInputType::value("Operand A", TaggedValue::F32(0.), true),
DocumentInputType::value("Operand B", TaggedValue::F32(0.), true),
@ -1922,7 +1922,7 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
DocumentNodeBlueprint {
name: "Modulo",
category: "Math",
identifier: NodeImplementation::proto("graphene_core::ops::ModuloParameterNode<_>"),
identifier: NodeImplementation::proto("graphene_core::ops::ModuloNode<_>"),
inputs: vec![
DocumentInputType::value("Primary", TaggedValue::F32(0.), true),
DocumentInputType::value("Modulus", TaggedValue::F32(0.), false),

View file

@ -6,27 +6,27 @@ use num_traits::Pow;
#[cfg(target_arch = "spirv")]
use spirv_std::num_traits::float::Float;
// Add
// Add Pair
// TODO: Delete this redundant (two-argument version of the) add node. It's only used in tests.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct AddNode;
impl<'i, L: Add<R, Output = O> + 'i, R: 'i, O: 'i> Node<'i, (L, R)> for AddNode {
pub struct AddPairNode;
impl<'i, L: Add<R, Output = O> + 'i, R: 'i, O: 'i> Node<'i, (L, R)> for AddPairNode {
type Output = <L as Add<R>>::Output;
fn eval(&'i self, input: (L, R)) -> Self::Output {
input.0 + input.1
}
}
impl AddNode {
impl AddPairNode {
pub const fn new() -> Self {
Self
}
}
pub struct AddParameterNode<Second> {
// Add
pub struct AddNode<Second> {
second: Second,
}
#[node_macro::node_fn(AddParameterNode)]
#[node_macro::node_fn(AddNode)]
fn add_parameter<U, T>(first: U, second: T) -> <U as Add<T>>::Output
where
U: Add<T>,
@ -35,11 +35,10 @@ where
}
// Subtract
pub struct SubtractParameterNode<Second> {
pub struct SubtractNode<Second> {
second: Second,
}
#[node_macro::node_fn(SubtractParameterNode)]
#[node_macro::node_fn(SubtractNode)]
fn sub<U, T>(first: U, second: T) -> <U as Sub<T>>::Output
where
U: Sub<T>,
@ -48,11 +47,10 @@ where
}
// Divide
pub struct DivideParameterNode<Second> {
pub struct DivideNode<Second> {
second: Second,
}
#[node_macro::node_fn(DivideParameterNode)]
#[node_macro::node_fn(DivideNode)]
fn div<U, T>(first: U, second: T) -> <U as Div<T>>::Output
where
U: Div<T>,
@ -61,11 +59,10 @@ where
}
// Multiply
pub struct MultiplyParameterNode<Second> {
pub struct MultiplyNode<Second> {
second: Second,
}
#[node_macro::node_fn(MultiplyParameterNode)]
#[node_macro::node_fn(MultiplyNode)]
fn mul<U, T>(first: U, second: T) -> <U as Mul<T>>::Output
where
U: Mul<T>,
@ -74,11 +71,10 @@ where
}
// Exponent
pub struct ExponentParameterNode<Second> {
pub struct ExponentNode<Second> {
second: Second,
}
#[node_macro::node_fn(ExponentParameterNode)]
#[node_macro::node_fn(ExponentNode)]
fn exp<U, T>(first: U, second: T) -> <U as Pow<T>>::Output
where
U: Pow<T>,
@ -88,84 +84,74 @@ where
// Floor
pub struct FloorNode;
#[node_macro::node_fn(FloorNode)]
fn floor(input: f32) -> f32 {
input.floor()
}
// Ceil
pub struct CeilNode;
#[node_macro::node_fn(CeilNode)]
pub struct CeilingNode;
#[node_macro::node_fn(CeilingNode)]
fn ceil(input: f32) -> f32 {
input.ceil()
}
// Round
pub struct RoundNode;
#[node_macro::node_fn(RoundNode)]
fn round(input: f32) -> f32 {
input.round()
}
// Absolute Value
pub struct AbsoluteNode;
#[node_macro::node_fn(AbsoluteNode)]
pub struct AbsoluteValue;
#[node_macro::node_fn(AbsoluteValue)]
fn abs(input: f32) -> f32 {
input.abs()
}
// Log
pub struct LogParameterNode<Second> {
pub struct LogarithmNode<Second> {
second: Second,
}
#[node_macro::node_fn(LogParameterNode)]
#[node_macro::node_fn(LogarithmNode)]
fn ln<U: num_traits::float::Float>(first: U, second: U) -> U {
first.log(second)
}
// Natural Log
pub struct NaturalLogNode;
#[node_macro::node_fn(NaturalLogNode)]
pub struct NaturalLogarithmNode;
#[node_macro::node_fn(NaturalLogarithmNode)]
fn ln(input: f32) -> f32 {
input.ln()
}
// Sine
pub struct SineNode;
#[node_macro::node_fn(SineNode)]
fn ln(input: f32) -> f32 {
input.sin()
}
// Cos
// Cosine
pub struct CosineNode;
#[node_macro::node_fn(CosineNode)]
fn ln(input: f32) -> f32 {
input.cos()
}
// Tan
// Tangent
pub struct TangentNode;
#[node_macro::node_fn(TangentNode)]
fn ln(input: f32) -> f32 {
input.tan()
}
// Minimum
pub struct MinParameterNode<Second> {
// Min
pub struct MinimumNode<Second> {
second: Second,
}
#[node_macro::node_fn(MinParameterNode)]
#[node_macro::node_fn(MinimumNode)]
fn min<T: core::cmp::PartialOrd>(first: T, second: T) -> T {
match first < second {
true => first,
@ -173,12 +159,11 @@ fn min<T: core::cmp::PartialOrd>(first: T, second: T) -> T {
}
}
// Maximum
pub struct MaxParameterNode<Second> {
// Maxi
pub struct MaximumNode<Second> {
second: Second,
}
#[node_macro::node_fn(MaxParameterNode)]
#[node_macro::node_fn(MaximumNode)]
fn max<T: core::cmp::PartialOrd>(first: T, second: T) -> T {
match first > second {
true => first,
@ -187,21 +172,19 @@ fn max<T: core::cmp::PartialOrd>(first: T, second: T) -> T {
}
// Equals
pub struct EqParameterNode<Second> {
pub struct EqualsNode<Second> {
second: Second,
}
#[node_macro::node_fn(EqParameterNode)]
#[node_macro::node_fn(EqualsNode)]
fn eq<T: core::cmp::PartialEq>(first: T, second: T) -> bool {
first == second
}
// Modulo
pub struct ModuloParameterNode<Second> {
pub struct ModuloNode<Second> {
second: Second,
}
#[node_macro::node_fn(ModuloParameterNode)]
#[node_macro::node_fn(ModuloNode)]
fn modulo<U, T>(first: U, second: T) -> <U as Rem<T>>::Output
where
U: Rem<T>,
@ -209,15 +192,16 @@ where
first % second
}
// Size Of
#[cfg(feature = "std")]
struct SizeOfNode {}
struct SizeOfNode;
#[cfg(feature = "std")]
#[node_macro::node_fn(SizeOfNode)]
fn flat_map(ty: crate::Type) -> Option<usize> {
ty.size()
}
// Some
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct SomeNode;
#[node_macro::node_fn(SomeNode)]
@ -225,6 +209,7 @@ fn some<T>(input: T) -> Option<T> {
Some(input)
}
// Clone
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct CloneNode<O>(PhantomData<O>);
impl<'i, 'n: 'i, O: Clone + 'i> Node<'i, &'n O> for CloneNode<O> {
@ -239,82 +224,87 @@ impl<O> CloneNode<O> {
}
}
// First of Pair
/// Return the first element of a 2-tuple
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct FstNode;
impl<'i, L: 'i, R: 'i> Node<'i, (L, R)> for FstNode {
pub struct FirstOfPairNode;
impl<'i, L: 'i, R: 'i> Node<'i, (L, R)> for FirstOfPairNode {
type Output = L;
fn eval(&'i self, input: (L, R)) -> Self::Output {
input.0
}
}
impl FstNode {
impl FirstOfPairNode {
pub fn new() -> Self {
Self
}
}
/// Destructures a Tuple of two values and returns the first one
// Second of Pair
/// Return the second element of a 2-tuple
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct SndNode;
impl<'i, L: 'i, R: 'i> Node<'i, (L, R)> for SndNode {
pub struct SecondOfPairNode;
impl<'i, L: 'i, R: 'i> Node<'i, (L, R)> for SecondOfPairNode {
type Output = R;
fn eval(&'i self, input: (L, R)) -> Self::Output {
input.1
}
}
impl SndNode {
impl SecondOfPairNode {
pub fn new() -> Self {
Self
}
}
/// Destructures a Tuple of two values and returns them in reverse order
// Swap Pair
/// Return a new 2-tuple with the elements reversed
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct SwapNode;
impl<'i, L: 'i, R: 'i> Node<'i, (L, R)> for SwapNode {
pub struct SwapPairNode;
impl<'i, L: 'i, R: 'i> Node<'i, (L, R)> for SwapPairNode {
type Output = (R, L);
fn eval(&'i self, input: (L, R)) -> Self::Output {
(input.1, input.0)
}
}
impl SwapNode {
impl SwapPairNode {
pub fn new() -> Self {
Self
}
}
/// Return a tuple with two instances of the input argument
// Make Pair
/// Return a 2-tuple with two duplicates of the input argument
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct DupNode;
impl<'i, O: Clone + 'i> Node<'i, O> for DupNode {
pub struct MakePairNode;
impl<'i, O: Clone + 'i> Node<'i, O> for MakePairNode {
type Output = (O, O);
fn eval(&'i self, input: O) -> Self::Output {
(input.clone(), input)
}
}
impl DupNode {
impl MakePairNode {
pub fn new() -> Self {
Self
}
}
/// Return the Input Argument
// Identity
/// Return the input argument unchanged
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct IdNode;
impl<'i, O: 'i> Node<'i, O> for IdNode {
pub struct IdentityNode;
impl<'i, O: 'i> Node<'i, O> for IdentityNode {
type Output = O;
fn eval(&'i self, input: O) -> Self::Output {
input
}
}
impl IdNode {
impl IdentityNode {
pub fn new() -> Self {
Self
}
}
/// Ascribe the node types
// Type
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct TypeNode<N: for<'a> Node<'a, I>, I, O>(pub N, pub PhantomData<(I, O)>);
impl<'i, N, I: 'i, O: 'i> Node<'i, I> for TypeNode<N, I, O>
@ -326,13 +316,11 @@ where
self.0.eval(input)
}
}
impl<'i, N: for<'a> Node<'a, I>, I: 'i> TypeNode<N, I, <N as Node<'i, I>>::Output> {
pub fn new(node: N) -> Self {
Self(node, PhantomData)
}
}
impl<'i, N: for<'a> Node<'a, I> + Clone, I: 'i> Clone for TypeNode<N, I, <N as Node<'i, I>>::Output> {
fn clone(&self) -> Self {
Self(self.0.clone(), self.1)
@ -340,13 +328,12 @@ impl<'i, N: for<'a> Node<'a, I> + Clone, I: 'i> Clone for TypeNode<N, I, <N as N
}
impl<'i, N: for<'a> Node<'a, I> + Copy, I: 'i> Copy for TypeNode<N, I, <N as Node<'i, I>>::Output> {}
/// input.map(|x| self.0.eval(x))
// Map Result
pub struct MapResultNode<I, E, Mn> {
node: Mn,
_i: PhantomData<I>,
_e: PhantomData<E>,
}
#[node_macro::node_fn(MapResultNode<_I, _E>)]
fn flat_map<_I, _E, N>(input: Result<_I, _E>, node: &'input N) -> Result<<N as Node<'input, _I>>::Output, _E>
where
@ -354,13 +341,14 @@ where
{
input.map(|x| node.eval(x))
}
// Flat Map Result
pub struct FlatMapResultNode<I, O, E, Mn> {
node: Mn,
_i: PhantomData<I>,
_o: PhantomData<O>,
_e: PhantomData<E>,
}
#[node_macro::node_fn(FlatMapResultNode<_I, _O, _E>)]
fn flat_map<_I, _O, _E, N>(input: Result<_I, _E>, node: &'input N) -> Result<_O, _E>
where
@ -373,6 +361,7 @@ where
}
}
// Into
pub struct IntoNode<I, O> {
_i: PhantomData<I>,
_o: PhantomData<O>,
@ -392,14 +381,14 @@ mod test {
use crate::{generic::*, structural::*, value::*};
#[test]
pub fn dup_node() {
pub fn duplicate_node() {
let value = ValueNode(4u32);
let dup = ComposeNode::new(value, DupNode::new());
assert_eq!(dup.eval(()), (&4, &4));
let pair = ComposeNode::new(value, MakePairNode::new());
assert_eq!(pair.eval(()), (&4, &4));
}
#[test]
pub fn id_node() {
let value = ValueNode(4u32).then(IdNode::new());
pub fn identity_node() {
let value = ValueNode(4u32).then(IdentityNode::new());
assert_eq!(value.eval(()), &4);
}
#[test]
@ -412,19 +401,19 @@ mod test {
assert_eq!(type_erased.eval(()), 4);
}
#[test]
pub fn fst_node() {
let fst = ValueNode((4u32, "a")).then(CloneNode::new()).then(FstNode::new());
assert_eq!(fst.eval(()), 4);
pub fn first_node() {
let first_of_pair = ValueNode((4u32, "a")).then(CloneNode::new()).then(FirstOfPairNode::new());
assert_eq!(first_of_pair.eval(()), 4);
}
#[test]
pub fn snd_node() {
let fst = ValueNode((4u32, "a")).then(CloneNode::new()).then(SndNode::new());
assert_eq!(fst.eval(()), "a");
pub fn second_node() {
let second_of_pair = ValueNode((4u32, "a")).then(CloneNode::new()).then(SecondOfPairNode::new());
assert_eq!(second_of_pair.eval(()), "a");
}
#[test]
pub fn object_safe() {
let fst = ValueNode((4u32, "a")).then(CloneNode::new()).then(SndNode::new());
let foo = &fst as &dyn Node<(), Output = &str>;
let second_of_pair = ValueNode((4u32, "a")).then(CloneNode::new()).then(SecondOfPairNode::new());
let foo = &second_of_pair as &dyn Node<(), Output = &str>;
assert_eq!(foo.eval(()), "a");
}
#[test]
@ -455,7 +444,7 @@ mod test {
let cons_a = ConsNode::new(a);
let tuple = b.then(cons_a);
let sum = tuple.then(AddNode::new());
let sum = tuple.then(AddPairNode::new());
assert_eq!(sum.eval(()), 48);
}

View file

@ -486,13 +486,13 @@ impl<'a, P: Copy> Iterator for ImageWindowIterator<'a, P> {
}
#[derive(Debug)]
pub struct MapSndNode<First, Second, MapFn> {
pub struct MapSecondNode<First, Second, MapFn> {
map_fn: MapFn,
_first: PhantomData<First>,
_second: PhantomData<Second>,
}
#[node_macro::node_fn(MapSndNode< _First, _Second>)]
#[node_macro::node_fn(MapSecondNode< _First, _Second>)]
fn map_snd_node<MapFn, _First, _Second>(input: (_First, _Second), map_fn: &'input MapFn) -> (_First, <MapFn as Node<'input, _Second>>::Output)
where
MapFn: for<'any_input> Node<'any_input, _Second>,
@ -658,49 +658,47 @@ mod test {
}
// TODO: I can't be bothered to fix this test rn
/*
#[test]
fn blur_node() {
use alloc::vec;
let radius = ValueNode::new(1u32).then(CloneNode::new());
let sigma = ValueNode::new(3f64).then(CloneNode::new());
let radius = ValueNode::new(1u32).then(CloneNode::new());
let image = ValueNode::<_>::new(Image {
width: 5,
height: 5,
data: vec![Color::from_rgbf32_unchecked(1., 0., 0.); 25],
});
let image = image.then(ImageRefNode::new());
let window = WindowNode::new(radius, image);
let window: TypeNode<_, u32, ImageWindowIterator<'_>> = TypeNode::new(window);
let distance = ValueNode::new(DistanceNode::new());
let pos_to_dist = MapSndNode::new(distance);
let type_erased = &window as &dyn for<'a> Node<'a, u32, Output = ImageWindowIterator<'a>>;
type_erased.eval(0);
let map_pos_to_dist = MapNode::new(ValueNode::new(pos_to_dist));
// #[test]
// fn blur_node() {
// use alloc::vec;
// let radius = ValueNode::new(1u32).then(CloneNode::new());
// let sigma = ValueNode::new(3f64).then(CloneNode::new());
// let radius = ValueNode::new(1u32).then(CloneNode::new());
// let image = ValueNode::<_>::new(Image {
// width: 5,
// height: 5,
// data: vec![Color::from_rgbf32_unchecked(1., 0., 0.); 25],
// });
// let image = image.then(ImageRefNode::new());
// let window = WindowNode::new(radius, image);
// let window: TypeNode<_, u32, ImageWindowIterator<'_>> = TypeNode::new(window);
// let distance = ValueNode::new(DistanceNode::new());
// let pos_to_dist = MapSecondNode::new(distance);
// let type_erased = &window as &dyn for<'a> Node<'a, u32, Output = ImageWindowIterator<'a>>;
// type_erased.eval(0);
// let map_pos_to_dist = MapNode::new(ValueNode::new(pos_to_dist));
let type_erased = &map_pos_to_dist as &dyn for<'a> Node<'a, u32, Output = ImageWindowIterator<'a>>;
type_erased.eval(0);
// let type_erased = &map_pos_to_dist as &dyn for<'a> Node<'a, u32, Output = ImageWindowIterator<'a>>;
// type_erased.eval(0);
let distance = window.then(map_pos_to_dist);
let map_gaussian = MapSndNode::new(ValueNode(GaussianNode::new(sigma)));
let map_gaussian: TypeNode<_, (_, f32), (_, f32)> = TypeNode::new(map_gaussian);
let map_gaussian = ValueNode(map_gaussian);
let map_gaussian: TypeNode<_, (), &_> = TypeNode::new(map_gaussian);
let map_distances = MapNode::new(map_gaussian);
let map_distances: TypeNode<_, _, MapFnIterator<'_, '_, _, _>> = TypeNode::new(map_distances);
let gaussian_iter = distance.then(map_distances);
let avg = gaussian_iter.then(WeightedAvgNode::new());
let avg: TypeNode<_, u32, Color> = TypeNode::new(avg);
let blur_iter = MapNode::new(ValueNode::new(avg));
let blur = image.then(ImageIndexIterNode).then(blur_iter);
let blur: TypeNode<_, (), MapFnIterator<_, _>> = TypeNode::new(blur);
let collect = CollectNode::new();
let vec = collect.eval(0..10);
assert_eq!(vec.len(), 10);
let _ = blur.eval(());
let vec = blur.then(collect);
let _image = vec.eval(());
}
*/
// let distance = window.then(map_pos_to_dist);
// let map_gaussian = MapSecondNode::new(ValueNode(GaussianNode::new(sigma)));
// let map_gaussian: TypeNode<_, (_, f32), (_, f32)> = TypeNode::new(map_gaussian);
// let map_gaussian = ValueNode(map_gaussian);
// let map_gaussian: TypeNode<_, (), &_> = TypeNode::new(map_gaussian);
// let map_distances = MapNode::new(map_gaussian);
// let map_distances: TypeNode<_, _, MapFnIterator<'_, '_, _, _>> = TypeNode::new(map_distances);
// let gaussian_iter = distance.then(map_distances);
// let avg = gaussian_iter.then(WeightedAvgNode::new());
// let avg: TypeNode<_, u32, Color> = TypeNode::new(avg);
// let blur_iter = MapNode::new(ValueNode::new(avg));
// let blur = image.then(ImageIndexIterNode).then(blur_iter);
// let blur: TypeNode<_, (), MapFnIterator<_, _>> = TypeNode::new(blur);
// let collect = CollectNode::new();
// let vec = collect.eval(0..10);
// assert_eq!(vec.len(), 10);
// let _ = blur.eval(());
// let vec = blur.then(collect);
// let _image = vec.eval(());
// }
}

View file

@ -175,14 +175,14 @@ impl<'input, S0: 'input, O: 'static> ApplyNode<O, S0> {
#[cfg(test)]
mod test {
use crate::{ops::IdNode, value::ValueNode};
use crate::{ops::IdentityNode, value::ValueNode};
use super::*;
#[test]
fn compose() {
let value = ValueNode::new(4u32);
let compose = value.then(IdNode::new());
let compose = value.then(IdentityNode::new());
assert_eq!(compose.eval(()), &4u32);
let type_erased = &compose as &dyn for<'i> Node<'i, (), Output = &'i u32>;
assert_eq!(type_erased.eval(()), &4u32);
@ -193,7 +193,7 @@ mod test {
let value = ValueNode::new(5);
assert_eq!(value.eval(()), &5);
let id = IdNode::new();
let id = IdentityNode::new();
let compose = ComposeNode::new(&value, &id);

View file

@ -373,7 +373,7 @@ pub enum DocumentNodeImplementation {
impl Default for DocumentNodeImplementation {
fn default() -> Self {
Self::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode"))
Self::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode"))
}
}
@ -468,7 +468,7 @@ impl NodeNetwork {
DocumentNode {
name: "Input Frame".into(),
manual_composition: Some(concrete!(u32)),
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdNode".into()),
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdentityNode".into()),
metadata: DocumentNodeMetadata { position: (8, 4).into() },
..Default::default()
},
@ -506,7 +506,7 @@ impl NodeNetwork {
let node = DocumentNode {
name: "Output".into(),
inputs: vec![],
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdNode".into()),
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdentityNode".into()),
..Default::default()
};
self.push_node(node)
@ -821,8 +821,8 @@ impl NodeNetwork {
return;
};
if node.implementation != DocumentNodeImplementation::Unresolved("graphene_core::ops::IdNode".into()) && self.disabled.contains(&id) {
node.implementation = DocumentNodeImplementation::Unresolved("graphene_core::ops::IdNode".into());
if node.implementation != DocumentNodeImplementation::Unresolved("graphene_core::ops::IdentityNode".into()) && self.disabled.contains(&id) {
node.implementation = DocumentNodeImplementation::Unresolved("graphene_core::ops::IdentityNode".into());
if node.is_layer() {
// Connect layer node to the graphic group below
node.inputs.drain(..1);
@ -941,7 +941,7 @@ impl NodeNetwork {
fn remove_id_node(&mut self, id: NodeId) -> Result<(), String> {
let node = self.nodes.get(&id).ok_or_else(|| format!("Node with id {id} does not exist"))?.clone();
if let DocumentNodeImplementation::Unresolved(ident) = &node.implementation {
if ident.name == "graphene_core::ops::IdNode" {
if ident.name == "graphene_core::ops::IdentityNode" {
assert_eq!(node.inputs.len(), 1, "Id node has more than one input");
if let NodeInput::Node { node_id, output_index, .. } = node.inputs[0] {
let input_node_id = node_id;
@ -977,13 +977,13 @@ impl NodeNetwork {
Ok(())
}
/// Strips out any [`graphene_core::ops::IdNode`]s that are unnecessary.
/// Strips out any [`graphene_core::ops::IdentityNode`]s that are unnecessary.
pub fn remove_redundant_id_nodes(&mut self) {
let id_nodes = self
.nodes
.iter()
.filter(|(_, node)| {
matches!(&node.implementation, DocumentNodeImplementation::Unresolved(ident) if ident == &NodeIdentifier::new("graphene_core::ops::IdNode"))
matches!(&node.implementation, DocumentNodeImplementation::Unresolved(ident) if ident == &NodeIdentifier::new("graphene_core::ops::IdentityNode"))
&& node.inputs.len() == 1
&& matches!(node.inputs[0], NodeInput::Node { .. })
})
@ -1141,7 +1141,7 @@ mod test {
DocumentNode {
name: "Add".into(),
inputs: vec![NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::AddNode".into()),
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::AddPairNode".into()),
..Default::default()
},
),
@ -1174,7 +1174,7 @@ mod test {
DocumentNode {
name: "Add".into(),
inputs: vec![NodeInput::node(1, 0)],
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::AddNode".into()),
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::AddPairNode".into()),
..Default::default()
},
),
@ -1191,7 +1191,7 @@ mod test {
let id_node = DocumentNode {
name: "Id".into(),
inputs: vec![],
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdNode".into()),
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdentityNode".into()),
..Default::default()
};
// TODO: Extend test cases to test nested network
@ -1291,7 +1291,7 @@ mod test {
(
11,
ProtoNode {
identifier: "graphene_core::ops::AddNode".into(),
identifier: "graphene_core::ops::AddPairNode".into(),
input: ProtoNodeInput::Node(10, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![1, 1],
@ -1344,7 +1344,7 @@ mod test {
DocumentNode {
name: "Add".into(),
inputs: vec![NodeInput::node(10, 0)],
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::AddNode".into()),
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::AddPairNode".into()),
path: Some(vec![1, 1]),
..Default::default()
},
@ -1366,7 +1366,7 @@ mod test {
DocumentNode {
name: "Identity 1".into(),
inputs: vec![NodeInput::Network(concrete!(u32))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode")),
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default()
},
),
@ -1375,7 +1375,7 @@ mod test {
DocumentNode {
name: "Identity 2".into(),
inputs: vec![NodeInput::Network(concrete!(u32))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode")),
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default()
},
),
@ -1405,7 +1405,7 @@ mod test {
DocumentNode {
name: "Result".into(),
inputs: vec![result_node_input],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode")),
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default()
},
),

View file

@ -214,7 +214,7 @@ pub struct ProtoNode {
impl Default for ProtoNode {
fn default() -> Self {
Self {
identifier: NodeIdentifier::new("graphene_core::ops::IdNode"),
identifier: NodeIdentifier::new("graphene_core::ops::IdentityNode"),
construction_args: ConstructionArgs::Value(value::TaggedValue::U32(0)),
input: ProtoNodeInput::None,
document_node_path: vec![],

View file

@ -77,7 +77,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -482,7 +482,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1067,7 +1067,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1298,7 +1298,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {

View file

@ -77,7 +77,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -482,7 +482,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1067,7 +1067,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1298,7 +1298,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {

View file

@ -77,7 +77,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -482,7 +482,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1067,7 +1067,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1298,7 +1298,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {

View file

@ -77,7 +77,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -482,7 +482,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1067,7 +1067,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1298,7 +1298,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {

View file

@ -77,7 +77,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -482,7 +482,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1067,7 +1067,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1298,7 +1298,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {

View file

@ -77,7 +77,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -482,7 +482,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1067,7 +1067,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {
@ -1298,7 +1298,7 @@
],
"implementation": {
"Unresolved": {
"name": "graphene_core::ops::IdNode"
"name": "graphene_core::ops::IdentityNode"
}
},
"metadata": {

View file

@ -265,14 +265,14 @@ impl<I, O> PanicNode<I, O> {
#[cfg(test)]
mod test {
use super::*;
use graphene_core::{ops::AddNode, ops::IdNode};
use graphene_core::{ops::AddPairNode, ops::IdentityNode};
#[test]
#[should_panic]
pub fn dyn_input_invalid_eval_panic() {
//let add = DynAnyNode::new(AddNode::new()).into_type_erased();
//let add = DynAnyNode::new(AddPairNode::new()).into_type_erased();
//add.eval(Box::new(&("32", 32u32)));
let dyn_any = DynAnyNode::<(u32, u32), u32, _>::new(FutureWrapperNode { node: AddNode::new() });
let dyn_any = DynAnyNode::<(u32, u32), u32, _>::new(FutureWrapperNode { node: AddPairNode::new() });
let type_erased = Box::new(dyn_any) as TypeErasedBox;
let _ref_type_erased = type_erased.as_ref();
//let type_erased = Box::pin(dyn_any) as TypeErasedBox<'_>;
@ -281,12 +281,12 @@ mod test {
#[test]
pub fn dyn_input_compose() {
//let add = DynAnyNode::new(AddNode::new()).into_type_erased();
//let add = DynAnyNode::new(AddPairNode::new()).into_type_erased();
//add.eval(Box::new(&("32", 32u32)));
let dyn_any = DynAnyNode::<(u32, u32), u32, _>::new(FutureWrapperNode { node: AddNode::new() });
let dyn_any = DynAnyNode::<(u32, u32), u32, _>::new(FutureWrapperNode { node: AddPairNode::new() });
let type_erased = Box::new(dyn_any) as TypeErasedBox<'_>;
type_erased.eval(Box::new((4u32, 2u32)));
let id_node = FutureWrapperNode::new(IdNode::new());
let id_node = FutureWrapperNode::new(IdentityNode::new());
let any_id = DynAnyNode::<u32, u32, _>::new(id_node);
let type_erased_id = Box::new(any_id) as TypeErasedBox;
let type_erased = ComposeTypeErased::new(NodeContainer::new(type_erased), NodeContainer::new(type_erased_id));
@ -296,13 +296,11 @@ mod test {
}
// TODO: Fix this test
/*
#[test]
pub fn dyn_input_storage_composition() {
// todo readd test
let node = <graphene_core::ops::IdNode>::new();
let any: DynAnyNode<Any<'_>, Any<'_>, _> = DynAnyNode::new(ValueNode::new(node));
any.into_type_erased();
}
*/
// #[test]
// pub fn dyn_input_storage_composition() {
// // todo readd test
// let node = <graphene_core::ops::IdentityNode>::new();
// let any: DynAnyNode<Any<'_>, Any<'_>, _> = DynAnyNode::new(ValueNode::new(node));
// any.into_type_erased();
// }
}

View file

@ -399,7 +399,7 @@ mod test {
use crate::raster::*;
#[allow(unused_imports)]
use graphene_core::ops::{AddNode, CloneNode};
use graphene_core::ops::{AddPairNode, CloneNode};
use graphene_core::raster::*;
use graphene_core::structural::Then;
use graphene_core::transform::{Transform, TransformMut};
@ -423,7 +423,7 @@ mod test {
#[test]
fn test_reduce() {
let reduce_node = ReduceNode::new(ClonedNode::new(0u32), ValueNode::new(AddNode));
let reduce_node = ReduceNode::new(ClonedNode::new(0u32), ValueNode::new(AddPairNode));
let sum = reduce_node.eval(vec![1, 2, 3, 4, 5].into_iter());
assert_eq!(sum, 15);
}

View file

@ -182,13 +182,13 @@ async fn create_compute_pass_descriptor<T: Clone + Pixel + StaticTypeSized>(
DocumentNode {
name: "Quantization".into(),
inputs: vec![NodeInput::Network(concrete!(quantization::Quantization))],
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdNode".into()),
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdentityNode".into()),
..Default::default()
},
DocumentNode {
name: "Width".into(),
inputs: vec![NodeInput::Network(concrete!(u32))],
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdNode".into()),
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdentityNode".into()),
..Default::default()
},
/*DocumentNode {

View file

@ -33,7 +33,7 @@ mod tests {
DocumentNode {
name: "Add".into(),
inputs: vec![NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::AddNode")),
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::AddPairNode")),
..Default::default()
},
),
@ -95,7 +95,7 @@ mod tests {
DocumentNode {
name: "id".into(),
inputs: vec![NodeInput::Network(concrete!(u32))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode")),
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default()
},
),
@ -105,7 +105,7 @@ mod tests {
DocumentNode {
name: "Add".into(),
inputs: vec![NodeInput::node(0, 0), NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::AddParameterNode<_>")),
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::AddNode<_>")),
..Default::default()
},
),

View file

@ -1,6 +1,6 @@
use graph_craft::imaginate_input::{ImaginateController, ImaginateMaskStartingFill, ImaginateSamplingMethod};
use graph_craft::proto::{NodeConstructor, TypeErasedBox};
use graphene_core::ops::IdNode;
use graphene_core::ops::IdentityNode;
use graphene_core::quantization::{PackedPixel, QuantizationChannels};
use graphene_core::raster::brush_cache::BrushCache;
@ -180,10 +180,10 @@ macro_rules! raster_node {
//TODO: turn into hashmap
fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>> {
let node_types: Vec<Vec<(NodeIdentifier, NodeConstructor, NodeIOTypes)>> = vec![
//register_node!(graphene_core::ops::IdNode, input: Any<'_>, params: []),
//register_node!(graphene_core::ops::IdentityNode, input: Any<'_>, params: []),
vec![(
NodeIdentifier::new("graphene_core::ops::IdNode"),
|_| Box::pin(async move { FutureWrapperNode::new(IdNode::new()).into_type_erased() }),
NodeIdentifier::new("graphene_core::ops::IdentityNode"),
|_| Box::pin(async move { FutureWrapperNode::new(IdentityNode::new()).into_type_erased() }),
NodeIOTypes::new(generic!(I), generic!(I), vec![]),
)],
// TODO: create macro to impl for all types
@ -191,72 +191,72 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
register_node!(graphene_core::structural::ConsNode<_, _>, input: u32, params: [&u32]),
register_node!(graphene_core::structural::ConsNode<_, _>, input: &u32, params: [u32]),
register_node!(graphene_core::structural::ConsNode<_, _>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::AddNode, input: (u32, u32), params: []),
register_node!(graphene_core::ops::AddNode, input: (u32, &u32), params: []),
register_node!(graphene_core::ops::AddPairNode, input: (u32, u32), params: []),
register_node!(graphene_core::ops::AddPairNode, input: (u32, &u32), params: []),
register_node!(graphene_core::ops::CloneNode<_>, input: &ImageFrame<Color>, params: []),
register_node!(graphene_core::ops::CloneNode<_>, input: &WasmEditorApi, params: []),
register_node!(graphene_core::ops::AddParameterNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::AddParameterNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::AddParameterNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::AddParameterNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::AddParameterNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::AddParameterNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::AddParameterNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::AddParameterNode<_>, input: &f32, params: [&f32]),
register_node!(graphene_core::ops::SubtractParameterNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::SubtractParameterNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::SubtractParameterNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::SubtractParameterNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::SubtractParameterNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::SubtractParameterNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::SubtractParameterNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::SubtractParameterNode<_>, input: &f32, params: [&f32]),
register_node!(graphene_core::ops::DivideParameterNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::DivideParameterNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::DivideParameterNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::DivideParameterNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::DivideParameterNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::DivideParameterNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::DivideParameterNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::DivideParameterNode<_>, input: &f32, params: [&f32]),
register_node!(graphene_core::ops::MultiplyParameterNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::MultiplyParameterNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::MultiplyParameterNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::MultiplyParameterNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::MultiplyParameterNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::MultiplyParameterNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::MultiplyParameterNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::MultiplyParameterNode<_>, input: &f32, params: [&f32]),
register_node!(graphene_core::ops::ExponentParameterNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::ExponentParameterNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::ExponentParameterNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::ExponentParameterNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::ExponentParameterNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::ExponentParameterNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::ExponentParameterNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::AddNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::AddNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::AddNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::AddNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::AddNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::AddNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::AddNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::AddNode<_>, input: &f32, params: [&f32]),
register_node!(graphene_core::ops::SubtractNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::SubtractNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::SubtractNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::SubtractNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::SubtractNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::SubtractNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::SubtractNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::SubtractNode<_>, input: &f32, params: [&f32]),
register_node!(graphene_core::ops::DivideNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::DivideNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::DivideNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::DivideNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::DivideNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::DivideNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::DivideNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::DivideNode<_>, input: &f32, params: [&f32]),
register_node!(graphene_core::ops::MultiplyNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::MultiplyNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::MultiplyNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::MultiplyNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::MultiplyNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::MultiplyNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::MultiplyNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::MultiplyNode<_>, input: &f32, params: [&f32]),
register_node!(graphene_core::ops::ExponentNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::ExponentNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::ExponentNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::ExponentNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::ExponentNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::ExponentNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::ExponentNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::FloorNode, input: f32, params: []),
register_node!(graphene_core::ops::CeilNode, input: f32, params: []),
register_node!(graphene_core::ops::CeilingNode, input: f32, params: []),
register_node!(graphene_core::ops::RoundNode, input: f32, params: []),
register_node!(graphene_core::ops::AbsoluteNode, input: f32, params: []),
register_node!(graphene_core::ops::LogParameterNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::NaturalLogNode, input: f32, params: []),
register_node!(graphene_core::ops::AbsoluteValue, input: f32, params: []),
register_node!(graphene_core::ops::LogarithmNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::NaturalLogarithmNode, input: f32, params: []),
register_node!(graphene_core::ops::SineNode, input: f32, params: []),
register_node!(graphene_core::ops::CosineNode, input: f32, params: []),
register_node!(graphene_core::ops::TangentNode, input: f32, params: []),
register_node!(graphene_core::ops::MaxParameterNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::MaxParameterNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::MinParameterNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::MinParameterNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::EqParameterNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::EqParameterNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::ModuloParameterNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::ModuloParameterNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::ModuloParameterNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::ModuloParameterNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::ModuloParameterNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::ModuloParameterNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::ModuloParameterNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::ModuloParameterNode<_>, input: &f32, params: [&f32]),
register_node!(graphene_core::ops::MaximumNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::MaximumNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::MinimumNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::MinimumNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::EqualsNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::EqualsNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::ModuloNode<_>, input: u32, params: [u32]),
register_node!(graphene_core::ops::ModuloNode<_>, input: &u32, params: [u32]),
register_node!(graphene_core::ops::ModuloNode<_>, input: u32, params: [&u32]),
register_node!(graphene_core::ops::ModuloNode<_>, input: &u32, params: [&u32]),
register_node!(graphene_core::ops::ModuloNode<_>, input: f32, params: [f32]),
register_node!(graphene_core::ops::ModuloNode<_>, input: &f32, params: [f32]),
register_node!(graphene_core::ops::ModuloNode<_>, input: f32, params: [&f32]),
register_node!(graphene_core::ops::ModuloNode<_>, input: &f32, params: [&f32]),
register_node!(graphene_core::ops::SomeNode, input: WasmEditorApi, params: []),
register_node!(graphene_core::logic::LogToConsoleNode, input: bool, params: []),
register_node!(graphene_core::logic::LogToConsoleNode, input: f32, params: []),

View file

@ -127,7 +127,7 @@ fn create_buffer<T: Pod + Send + Sync>(data: Vec<T>, alloc: &StandardMemoryAlloc
// (
// 1,
// ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::ops::IdNode", &[generic!("u32")]),
// identifier: NodeIdentifier::new("graphene_core::ops::IdentityNode", &[generic!("u32")]),
// input: ProtoNodeInput::Node(11),
// construction_args: ConstructionArgs::Nodes(vec![]),
// },
@ -143,7 +143,7 @@ fn create_buffer<T: Pod + Send + Sync>(data: Vec<T>, alloc: &StandardMemoryAlloc
// (
// 11,
// ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::ops::AddNode", &[generic!("u32"), generic!("u32")]),
// identifier: NodeIdentifier::new("graphene_core::ops::AddPairNode", &[generic!("u32"), generic!("u32")]),
// input: ProtoNodeInput::Node(10),
// construction_args: ConstructionArgs::Nodes(vec![]),
// },

View file

@ -209,7 +209,7 @@ async fn execute_shader<I: Pod + Send + Sync, O: Pod + Send + Sync>(device: Arc<
// (
// 1,
// ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::ops::IdNode", &[generic!("u32")]),
// identifier: NodeIdentifier::new("graphene_core::ops::IdentityNode", &[generic!("u32")]),
// input: ProtoNodeInput::Node(11),
// construction_args: ConstructionArgs::Nodes(vec![]),
// },
@ -225,7 +225,7 @@ async fn execute_shader<I: Pod + Send + Sync, O: Pod + Send + Sync>(device: Arc<
// (
// 11,
// ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::ops::AddNode", &[generic!("u32"), generic!("u32")]),
// identifier: NodeIdentifier::new("graphene_core::ops::AddPairNode", &[generic!("u32"), generic!("u32")]),
// input: ProtoNodeInput::Node(10),
// construction_args: ConstructionArgs::Nodes(vec![]),
// },