mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 19:08:05 +08:00
Add type checking to the node graph (#1025)
* Implement type inference Add type hints to node trait Add type annotation infrastructure Refactor type ascription infrastructure Run cargo fix Insert infer types stub Remove types from node identifier * Implement covariance * Disable rejection of generic inputs + parameters * Fix lints * Extend type checking to cover Network inputs * Implement generic specialization * Relax covariance rules * Fix type annotations for TypErasedComposeNode * Fix type checking errors * Keep connection information during node resolution * Fix TypeDescriptor PartialEq implementation * Apply review suggestions * Add documentation to type inference * Add Imaginate node to document node types * Fix whitespace in macros * Add types to imaginate node * Fix type declaration for imaginate node + add console logging * Use fully qualified type names as fallback during comparison --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
parent
a64c856ec4
commit
5dab7de68d
@@ -10,12 +10,13 @@ use document_legacy::layers::nodegraph_layer::NodeGraphFrameLayer;
|
||||
use document_legacy::LayerId;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeId, NodeInput, NodeNetwork, NodeOutput};
|
||||
use graphene_core::*;
|
||||
mod document_node_types;
|
||||
mod node_properties;
|
||||
|
||||
use glam::IVec2;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum FrontendGraphDataType {
|
||||
#[default]
|
||||
#[serde(rename = "general")]
|
||||
@@ -310,7 +311,7 @@ impl NodeGraphMessageHandler {
|
||||
exposed_inputs: node
|
||||
.inputs
|
||||
.iter()
|
||||
.zip(node_type.inputs)
|
||||
.zip(node_type.inputs.iter())
|
||||
.skip(1)
|
||||
.filter(|(input, _)| input.is_exposed())
|
||||
.map(|(_, input_type)| NodeGraphInput {
|
||||
@@ -769,7 +770,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
if let Some(node) = network.nodes.get_mut(node_id) {
|
||||
// Extend number of inputs if not already large enough
|
||||
if input_index >= node.inputs.len() {
|
||||
node.inputs.extend(((node.inputs.len() - 1)..input_index).map(|_| NodeInput::Network));
|
||||
node.inputs.extend(((node.inputs.len() - 1)..input_index).map(|_| NodeInput::Network(generic!(T))));
|
||||
}
|
||||
node.inputs[input_index] = NodeInput::Value { tagged_value: value, exposed: false };
|
||||
if network.connected_to_output(*node_id) {
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
use super::{node_properties, FrontendGraphDataType, FrontendNodeType};
|
||||
use crate::messages::layout::utility_types::layout_widget::LayoutGroup;
|
||||
use crate::node_graph_executor::NodeGraphExecutor;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use graph_craft::document::value::*;
|
||||
use graph_craft::document::*;
|
||||
use graph_craft::imaginate_input::ImaginateSamplingMethod;
|
||||
use graph_craft::proto::{NodeIdentifier, Type};
|
||||
use graph_craft::{concrete, generic};
|
||||
|
||||
use graph_craft::NodeIdentifier;
|
||||
use graphene_core::raster::{Color, Image, LuminanceCalculation};
|
||||
use graphene_core::*;
|
||||
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Hash)]
|
||||
pub struct DocumentInputType {
|
||||
pub name: &'static str,
|
||||
pub data_type: FrontendGraphDataType,
|
||||
@@ -18,7 +21,11 @@ pub struct DocumentInputType {
|
||||
}
|
||||
|
||||
impl DocumentInputType {
|
||||
pub const fn new(name: &'static str, tagged_value: TaggedValue, exposed: bool) -> Self {
|
||||
pub fn new(name: &'static str, data_type: FrontendGraphDataType, default: NodeInput) -> Self {
|
||||
Self { name, data_type, default }
|
||||
}
|
||||
|
||||
pub fn value(name: &'static str, tagged_value: TaggedValue, exposed: bool) -> Self {
|
||||
let data_type = FrontendGraphDataType::with_tagged_value(&tagged_value);
|
||||
let default = NodeInput::value(tagged_value, exposed);
|
||||
Self { name, data_type, default }
|
||||
@@ -33,6 +40,7 @@ impl DocumentInputType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Hash)]
|
||||
pub struct DocumentOutputType {
|
||||
pub name: &'static str,
|
||||
pub data_type: FrontendGraphDataType,
|
||||
@@ -61,8 +69,8 @@ pub enum NodeImplementation {
|
||||
}
|
||||
|
||||
impl NodeImplementation {
|
||||
pub const fn proto(name: &'static str, types: &'static [Type]) -> Self {
|
||||
Self::ProtoNode(NodeIdentifier::new(name, types))
|
||||
pub fn proto(name: &'static str) -> Self {
|
||||
Self::ProtoNode(NodeIdentifier::new(name))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,486 +79,458 @@ pub struct DocumentNodeType {
|
||||
pub name: &'static str,
|
||||
pub category: &'static str,
|
||||
pub identifier: NodeImplementation,
|
||||
pub inputs: &'static [DocumentInputType],
|
||||
pub outputs: &'static [DocumentOutputType],
|
||||
pub inputs: Vec<DocumentInputType>,
|
||||
pub outputs: Vec<DocumentOutputType>,
|
||||
pub properties: fn(&DocumentNode, NodeId, &mut NodePropertiesContext) -> Vec<LayoutGroup>,
|
||||
}
|
||||
|
||||
fn document_node_types() -> Vec<DocumentNodeType> {
|
||||
let mut vec: Vec<_> = STATIC_NODES.to_vec();
|
||||
|
||||
const GAUSSIAN_BLUR_NODE_INPUTS: &[DocumentInputType] = &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Radius", TaggedValue::U32(3), false),
|
||||
DocumentInputType::new("Sigma", TaggedValue::F64(1.), false),
|
||||
];
|
||||
let blur = DocumentNodeType {
|
||||
name: "Gaussian Blur",
|
||||
category: "Image Filters",
|
||||
identifier: NodeImplementation::DocumentNode(NodeNetwork {
|
||||
inputs: vec![0, 1, 1],
|
||||
outputs: vec![NodeOutput::new(1, 0)],
|
||||
nodes: vec![
|
||||
(
|
||||
0,
|
||||
DocumentNode {
|
||||
name: "CacheNode".to_string(),
|
||||
inputs: vec![NodeInput::Network],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_std::memo::CacheNode", &[concrete!("Image")])),
|
||||
metadata: Default::default(),
|
||||
},
|
||||
),
|
||||
(
|
||||
1,
|
||||
DocumentNode {
|
||||
name: "BlurNode".to_string(),
|
||||
inputs: vec![NodeInput::node(0, 0), NodeInput::Network, NodeInput::Network, NodeInput::node(0, 0)],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::raster::BlurNode", &[concrete!("Image")])),
|
||||
metadata: Default::default(),
|
||||
},
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}),
|
||||
inputs: GAUSSIAN_BLUR_NODE_INPUTS,
|
||||
outputs: &[DocumentOutputType {
|
||||
name: "Image",
|
||||
data_type: FrontendGraphDataType::Raster,
|
||||
}],
|
||||
properties: node_properties::blur_image_properties,
|
||||
};
|
||||
vec.push(blur);
|
||||
|
||||
const INPUT_NODE_INPUTS: &[DocumentInputType] = &[
|
||||
DocumentInputType {
|
||||
name: "In",
|
||||
data_type: FrontendGraphDataType::General,
|
||||
default: NodeInput::Network,
|
||||
},
|
||||
DocumentInputType::new("Transform", TaggedValue::DAffine2(DAffine2::IDENTITY), false),
|
||||
];
|
||||
let input = DocumentNodeType {
|
||||
name: "Input",
|
||||
category: "Ignore",
|
||||
identifier: NodeImplementation::DocumentNode(NodeNetwork {
|
||||
inputs: vec![0, 1],
|
||||
outputs: vec![NodeOutput::new(0, 0), NodeOutput::new(1, 0)],
|
||||
nodes: [
|
||||
DocumentNode {
|
||||
name: "Identity".to_string(),
|
||||
inputs: vec![NodeInput::Network],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode", &[generic!("T")])),
|
||||
metadata: Default::default(),
|
||||
},
|
||||
DocumentNode {
|
||||
name: "Identity".to_string(),
|
||||
inputs: vec![NodeInput::Network],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode", &[generic!("T")])),
|
||||
metadata: Default::default(),
|
||||
},
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(id, node)| (id as NodeId, node))
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}),
|
||||
inputs: INPUT_NODE_INPUTS,
|
||||
outputs: &[
|
||||
DocumentOutputType {
|
||||
name: "Image",
|
||||
data_type: FrontendGraphDataType::Raster,
|
||||
},
|
||||
DocumentOutputType {
|
||||
name: "Transform",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
},
|
||||
],
|
||||
properties: node_properties::input_properties,
|
||||
};
|
||||
vec.push(input);
|
||||
|
||||
vec
|
||||
}
|
||||
|
||||
// We use the once cell for lazy initialization to avoid the overhead of reconstructing the node list every time.
|
||||
// TODO: make document nodes not require a `'static` lifetime to avoid having to split the construction into const and non-const parts.
|
||||
static DOCUMENT_NODE_TYPES: once_cell::sync::Lazy<Vec<DocumentNodeType>> = once_cell::sync::Lazy::new(document_node_types);
|
||||
static DOCUMENT_NODE_TYPES: once_cell::sync::Lazy<Vec<DocumentNodeType>> = once_cell::sync::Lazy::new(static_nodes);
|
||||
|
||||
// TODO: Dynamic node library
|
||||
static STATIC_NODES: &[DocumentNodeType] = &[
|
||||
DocumentNodeType {
|
||||
name: "Identity",
|
||||
category: "General",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::IdNode", &[generic!("T")]),
|
||||
inputs: &[DocumentInputType {
|
||||
name: "In",
|
||||
data_type: FrontendGraphDataType::General,
|
||||
default: NodeInput::node(0, 0),
|
||||
}],
|
||||
outputs: &[DocumentOutputType::new("Out", FrontendGraphDataType::General)],
|
||||
properties: |_document_node, _node_id, _context| node_properties::string_properties("The identity node simply returns the input"),
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Image",
|
||||
category: "Ignore",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::IdNode", &[generic!("T")]),
|
||||
inputs: &[DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), false)],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: |_document_node, _node_id, _context| node_properties::string_properties("A bitmap image embedded in this node"),
|
||||
},
|
||||
// DocumentNodeType {
|
||||
// name: "Input",
|
||||
// category: "Ignore",
|
||||
// identifier: NodeImplementation::proto("graphene_core::ops::IdNode", &[generic!("T")]),
|
||||
// inputs: &[DocumentInputType {
|
||||
// name: "In",
|
||||
// data_type: FrontendGraphDataType::Raster,
|
||||
// default: NodeInput::Network,
|
||||
// }],
|
||||
// outputs: &[DocumentOutputType::new("Out", FrontendGraphDataType::Raster)],
|
||||
// properties: node_properties::input_properties,
|
||||
// },
|
||||
DocumentNodeType {
|
||||
name: "Output",
|
||||
category: "Ignore",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::IdNode", &[generic!("T")]),
|
||||
inputs: &[DocumentInputType {
|
||||
name: "In",
|
||||
data_type: FrontendGraphDataType::Raster,
|
||||
default: NodeInput::value(TaggedValue::Image(Image::empty()), true),
|
||||
}],
|
||||
outputs: &[],
|
||||
properties: |_document_node, _node_id, _context| node_properties::string_properties("The graph's output is rendered into the frame"),
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Image Frame",
|
||||
category: "General",
|
||||
identifier: NodeImplementation::proto("graphene_std::raster::ImageFrameNode<_>", &[concrete!("Image"), concrete!("DAffine2")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Transform", TaggedValue::DAffine2(DAffine2::IDENTITY), true),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: |_document_node, _node_id, _context| node_properties::string_properties("Creates an embedded image with the given transform"),
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Grayscale",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto(
|
||||
"graphene_core::raster::GrayscaleNode<_, _, _, _, _, _, _>",
|
||||
&[
|
||||
concrete!("Image"),
|
||||
concrete!("Color"),
|
||||
concrete!("f64"),
|
||||
concrete!("f64"),
|
||||
concrete!("f64"),
|
||||
concrete!("f64"),
|
||||
concrete!("f64"),
|
||||
concrete!("f64"),
|
||||
fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
vec![
|
||||
DocumentNodeType {
|
||||
name: "Identity",
|
||||
category: "General",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
|
||||
inputs: vec![DocumentInputType {
|
||||
name: "In",
|
||||
data_type: FrontendGraphDataType::General,
|
||||
default: NodeInput::node(0, 0),
|
||||
}],
|
||||
outputs: vec![DocumentOutputType::new("Out", FrontendGraphDataType::General)],
|
||||
properties: |_document_node, _node_id, _context| node_properties::string_properties("The identity node simply returns the input"),
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Image",
|
||||
category: "Ignore",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
|
||||
inputs: vec![DocumentInputType::value("Image", TaggedValue::Image(Image::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"),
|
||||
},
|
||||
// DocumentNodeType {
|
||||
// name: "Input",
|
||||
// category: "Ignore",
|
||||
// identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
|
||||
// inputs: vec![DocumentInputType {
|
||||
// name: "In",
|
||||
// data_type: FrontendGraphDataType::Raster,
|
||||
// default: NodeInput::Network,
|
||||
// }],
|
||||
// outputs: vec![DocumentOutputType::new("Out", FrontendGraphDataType::Raster)],
|
||||
// properties: node_properties::input_properties,
|
||||
// },
|
||||
DocumentNodeType {
|
||||
name: "Input",
|
||||
category: "Ignore",
|
||||
identifier: NodeImplementation::DocumentNode(NodeNetwork {
|
||||
inputs: vec![0, 1],
|
||||
outputs: vec![NodeOutput::new(0, 0), NodeOutput::new(1, 0)],
|
||||
nodes: [
|
||||
DocumentNode {
|
||||
name: "Identity".to_string(),
|
||||
inputs: vec![NodeInput::Network(concrete!(Image))],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode")),
|
||||
metadata: Default::default(),
|
||||
},
|
||||
DocumentNode {
|
||||
name: "Identity".to_string(),
|
||||
inputs: vec![NodeInput::Network(concrete!(DAffine2))],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode")),
|
||||
metadata: Default::default(),
|
||||
},
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(id, node)| (id as NodeId, node))
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}),
|
||||
inputs: vec![
|
||||
DocumentInputType {
|
||||
name: "In",
|
||||
data_type: FrontendGraphDataType::General,
|
||||
default: NodeInput::Network(concrete!(Image)),
|
||||
},
|
||||
DocumentInputType::value("Transform", TaggedValue::DAffine2(DAffine2::IDENTITY), false),
|
||||
],
|
||||
),
|
||||
inputs: &[
|
||||
DocumentInputType {
|
||||
name: "Image",
|
||||
outputs: vec![
|
||||
DocumentOutputType {
|
||||
name: "Image",
|
||||
data_type: FrontendGraphDataType::Raster,
|
||||
},
|
||||
DocumentOutputType {
|
||||
name: "Transform",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
},
|
||||
],
|
||||
properties: node_properties::input_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Output",
|
||||
category: "Ignore",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
|
||||
inputs: vec![DocumentInputType {
|
||||
name: "In",
|
||||
data_type: FrontendGraphDataType::Raster,
|
||||
default: NodeInput::value(TaggedValue::Image(Image::empty()), true),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Tint",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::Color(Color::BLACK), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Reds",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Yellows",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Greens",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Cyans",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Blues",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Magentas",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::grayscale_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Luminance",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::LuminanceNode<_>", &[concrete!("Image"), concrete!("LuminanceCalculation")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Luma Calculation", TaggedValue::LuminanceCalculation(LuminanceCalculation::SRGB), false),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::luminance_properties,
|
||||
},
|
||||
#[cfg(feature = "gpu")]
|
||||
DocumentNodeType {
|
||||
name: "GpuImage",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_std::executor::MapGpuSingleImageNode", &[concrete!("Image")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType {
|
||||
name: "Path",
|
||||
data_type: FrontendGraphDataType::Text,
|
||||
default: NodeInput::value(TaggedValue::String(String::new()), false),
|
||||
},
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::gpu_map_properties,
|
||||
},
|
||||
#[cfg(feature = "quantization")]
|
||||
DocumentNodeType {
|
||||
name: "QuantizeImage",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_std::quantization::GenerateQuantizationNode", &[concrete!("Image")]),
|
||||
inputs: &[
|
||||
DocumentInputType {
|
||||
}],
|
||||
outputs: vec![],
|
||||
properties: |_document_node, _node_id, _context| node_properties::string_properties("The graph's output is rendered into the frame"),
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Image Frame",
|
||||
category: "General",
|
||||
identifier: NodeImplementation::proto("graphene_std::raster::ImageFrameNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Transform", TaggedValue::DAffine2(DAffine2::IDENTITY), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: |_document_node, _node_id, _context| node_properties::string_properties("Creates an embedded image with the given transform"),
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Grayscale",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::GrayscaleNode<_, _, _, _, _, _, _>"),
|
||||
inputs: vec![
|
||||
DocumentInputType {
|
||||
name: "Image",
|
||||
data_type: FrontendGraphDataType::Raster,
|
||||
default: NodeInput::value(TaggedValue::Image(Image::empty()), true),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Tint",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::Color(Color::BLACK), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Reds",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Yellows",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Greens",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Cyans",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Blues",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Magentas",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
},
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::grayscale_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Luminance",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::LuminanceNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Luma Calculation", TaggedValue::LuminanceCalculation(LuminanceCalculation::SRGB), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::luminance_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Gaussian Blur",
|
||||
category: "Image Filters",
|
||||
identifier: NodeImplementation::DocumentNode(NodeNetwork {
|
||||
inputs: vec![0, 1, 1],
|
||||
outputs: vec![NodeOutput::new(1, 0)],
|
||||
nodes: vec![
|
||||
(
|
||||
0,
|
||||
DocumentNode {
|
||||
name: "CacheNode".to_string(),
|
||||
inputs: vec![NodeInput::Network(concrete!(Image))],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_std::memo::CacheNode")),
|
||||
metadata: Default::default(),
|
||||
},
|
||||
),
|
||||
(
|
||||
1,
|
||||
DocumentNode {
|
||||
name: "BlurNode".to_string(),
|
||||
inputs: vec![NodeInput::node(0, 0), NodeInput::Network(concrete!(u32)), NodeInput::Network(concrete!(f64)), NodeInput::node(0, 0)],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::raster::BlurNode")),
|
||||
metadata: Default::default(),
|
||||
},
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Radius", TaggedValue::U32(3), false),
|
||||
DocumentInputType::value("Sigma", TaggedValue::F64(1.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType {
|
||||
name: "Image",
|
||||
data_type: FrontendGraphDataType::Raster,
|
||||
default: NodeInput::value(TaggedValue::Image(Image::empty()), true),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "samples",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::U32(100), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Fn index",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::U32(0), false),
|
||||
},
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::quantize_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Cache",
|
||||
category: "Structural",
|
||||
identifier: NodeImplementation::proto("graphene_std::memo::CacheNode", &[concrete!("Image")]),
|
||||
inputs: &[DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true)],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Invert RGB",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::InvertRGBNode", &[concrete!("Image")]),
|
||||
inputs: &[DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true)],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Hue/Saturation",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto(
|
||||
"graphene_core::raster::HueSaturationNode<_, _, _>",
|
||||
&[concrete!("Image"), concrete!("f64"), concrete!("f64"), concrete!("f64")],
|
||||
),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Hue Shift", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Saturation Shift", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Lightness Shift", TaggedValue::F64(0.), false),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::adjust_hsl_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Brightness/Contrast",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::BrightnessContrastNode<_, _>", &[concrete!("Image"), concrete!("f64"), concrete!("f64")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Brightness", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Contrast", TaggedValue::F64(0.), false),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::brighten_image_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Threshold",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::ThresholdNode<_, _>", &[concrete!("Image"), concrete!("LuminanceCalculation"), concrete!("f64")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Luma Calculation", TaggedValue::LuminanceCalculation(LuminanceCalculation::SRGB), false),
|
||||
DocumentInputType::new("Threshold", TaggedValue::F64(50.), false),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::adjust_threshold_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Vibrance",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::VibranceNode<_>", &[concrete!("Image"), concrete!("f64")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Vibrance", TaggedValue::F64(0.), false),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::adjust_vibrance_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Opacity",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::OpacityNode<_>", &[concrete!("Image"), concrete!("f64")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Factor", TaggedValue::F64(100.), false),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::multiply_opacity,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Posterize",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::PosterizeNode<_>", &[concrete!("Image"), concrete!("f64")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Value", TaggedValue::F64(4.), false),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::posterize_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Exposure",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto(
|
||||
"graphene_core::raster::ExposureNode<_, _, _>",
|
||||
&[concrete!("Image"), concrete!("f64"), concrete!("f64"), concrete!("f64")],
|
||||
),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Exposure", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Offset", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Gamma Correction", TaggedValue::F64(1.), false),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::exposure_properties,
|
||||
},
|
||||
IMAGINATE_NODE,
|
||||
DocumentNodeType {
|
||||
name: "Add",
|
||||
category: "Math",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::AddParameterNode<_>", &[concrete!("f64"), concrete!("f64")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Input", TaggedValue::F64(0.), true),
|
||||
DocumentInputType::new("Addend", TaggedValue::F64(0.), true),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Output", FrontendGraphDataType::Number)],
|
||||
properties: node_properties::add_properties,
|
||||
},
|
||||
/*DocumentNodeType {
|
||||
name: "Unit Circle Generator",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_std::vector::generator_nodes::UnitCircleGenerator", &[]),
|
||||
inputs: &[DocumentInputType::none()],
|
||||
outputs: &[DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Unit Square Generator",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_std::vector::generator_nodes::UnitSquareGenerator", &[]),
|
||||
inputs: &[DocumentInputType::none()],
|
||||
outputs: &[DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Path Generator",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::IdNode", &[generic!("T")]),
|
||||
inputs: &[DocumentInputType {
|
||||
name: "Path Data",
|
||||
data_type: FrontendGraphDataType::Subpath,
|
||||
default: NodeInput::value(TaggedValue::Subpath(Subpath::new()), false),
|
||||
}],
|
||||
outputs: &[DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Transform Subpath",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_std::vector::generator_nodes::TransformSubpathNode", &[]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Subpath", TaggedValue::Subpath(Subpath::empty()), true),
|
||||
DocumentInputType::new("Translation", TaggedValue::DVec2(DVec2::ZERO), false),
|
||||
DocumentInputType::new("Rotation", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Scale", TaggedValue::DVec2(DVec2::ONE), false),
|
||||
DocumentInputType::new("Skew", TaggedValue::DVec2(DVec2::ZERO), false),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::transform_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Blit Subpath",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_std::vector::generator_nodes::BlitSubpath", &[]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Subpath", TaggedValue::Subpath(Subpath::empty()), true),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Vector", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::no_properties,
|
||||
},*/
|
||||
];
|
||||
}],
|
||||
properties: node_properties::blur_image_properties,
|
||||
},
|
||||
#[cfg(feature = "gpu")]
|
||||
DocumentNodeType {
|
||||
name: "GpuImage",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_std::executor::MapGpuSingleImageNode"),
|
||||
inputs: vec![
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType {
|
||||
name: "Path",
|
||||
data_type: FrontendGraphDataType::Text,
|
||||
default: NodeInput::value(TaggedValue::String(String::new()), false),
|
||||
},
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::gpu_map_properties,
|
||||
},
|
||||
#[cfg(feature = "quantization")]
|
||||
DocumentNodeType {
|
||||
name: "QuantizeImage",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_std::quantization::GenerateQuantizationNode"),
|
||||
inputs: vec![
|
||||
DocumentInputType {
|
||||
name: "Image",
|
||||
data_type: FrontendGraphDataType::Raster,
|
||||
default: NodeInput::value(TaggedValue::Image(Image::empty()), true),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "samples",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::U32(100), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Fn index",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::U32(0), false),
|
||||
},
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::quantize_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Cache",
|
||||
category: "Structural",
|
||||
identifier: NodeImplementation::proto("graphene_std::memo::CacheNode"),
|
||||
inputs: vec![DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true)],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Invert RGB",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::InvertRGBNode"),
|
||||
inputs: vec![DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true)],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Hue/Saturation",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::HueSaturationNode<_, _, _>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Hue Shift", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Saturation Shift", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Lightness Shift", TaggedValue::F64(0.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::adjust_hsl_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Brightness/Contrast",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::BrightnessContrastNode<_, _>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Brightness", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Contrast", TaggedValue::F64(0.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::brighten_image_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Threshold",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::ThresholdNode<_, _>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Luma Calculation", TaggedValue::LuminanceCalculation(LuminanceCalculation::SRGB), false),
|
||||
DocumentInputType::value("Threshold", TaggedValue::F64(50.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::adjust_threshold_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Vibrance",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::VibranceNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Vibrance", TaggedValue::F64(0.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::adjust_vibrance_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Opacity",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::OpacityNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Factor", TaggedValue::F64(100.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::multiply_opacity,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Posterize",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::PosterizeNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Value", TaggedValue::F64(4.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::posterize_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Exposure",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::ExposureNode<_, _, _>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Exposure", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Offset", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Gamma Correction", TaggedValue::F64(1.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::exposure_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Add",
|
||||
category: "Math",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::AddParameterNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Input", TaggedValue::F64(0.), true),
|
||||
DocumentInputType::value("Addend", TaggedValue::F64(0.), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Number)],
|
||||
properties: node_properties::add_properties,
|
||||
},
|
||||
(*IMAGINATE_NODE).clone(),
|
||||
/*DocumentNodeType {
|
||||
name: "Unit Circle Generator",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_std::vector::generator_nodes::UnitCircleGenerator", &[]),
|
||||
inputs: vec![DocumentInputType::none()],
|
||||
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Unit Square Generator",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_std::vector::generator_nodes::UnitSquareGenerator", &[]),
|
||||
inputs: vec![DocumentInputType::none()],
|
||||
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Path Generator",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::IdNode"),
|
||||
inputs: vec![DocumentInputType {
|
||||
name: "Path Data",
|
||||
data_type: FrontendGraphDataType::Subpath,
|
||||
default: NodeInput::value(TaggedValue::Subpath(Subpath::new()), false),
|
||||
}],
|
||||
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Transform Subpath",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_std::vector::generator_nodes::TransformSubpathNode", &[]),
|
||||
inputs: vec![
|
||||
DocumentInputType::new("Subpath", TaggedValue::Subpath(Subpath::empty()), true),
|
||||
DocumentInputType::new("Translation", TaggedValue::DVec2(DVec2::ZERO), false),
|
||||
DocumentInputType::new("Rotation", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Scale", TaggedValue::DVec2(DVec2::ONE), false),
|
||||
DocumentInputType::new("Skew", TaggedValue::DVec2(DVec2::ZERO), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::transform_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Blit Subpath",
|
||||
category: "Vector",
|
||||
identifier: NodeImplementation::proto("graphene_std::vector::generator_nodes::BlitSubpath", &[]),
|
||||
inputs: vec![
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Subpath", TaggedValue::Subpath(Subpath::empty()), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::no_properties,
|
||||
},*/
|
||||
]
|
||||
}
|
||||
|
||||
pub const IMAGINATE_NODE: DocumentNodeType = DocumentNodeType {
|
||||
pub static IMAGINATE_NODE: Lazy<DocumentNodeType> = Lazy::new(|| DocumentNodeType {
|
||||
name: "Imaginate",
|
||||
category: "Image Synthesis",
|
||||
identifier: NodeImplementation::proto("graphene_std::raster::ImaginateNode<_>", &[concrete!("Image"), concrete!("Option<std::sync::Arc<Image>>")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Input Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Transform", TaggedValue::DAffine2(DAffine2::IDENTITY), true),
|
||||
DocumentInputType::new("Seed", TaggedValue::F64(0.), false), // Remember to keep index used in `NodeGraphFrameImaginateRandom` updated with this entry's index
|
||||
DocumentInputType::new("Resolution", TaggedValue::OptionalDVec2(None), false),
|
||||
DocumentInputType::new("Samples", TaggedValue::F64(30.), false),
|
||||
DocumentInputType::new("Sampling Method", TaggedValue::ImaginateSamplingMethod(ImaginateSamplingMethod::EulerA), false),
|
||||
DocumentInputType::new("Prompt Guidance", TaggedValue::F64(7.5), false),
|
||||
DocumentInputType::new("Prompt", TaggedValue::String(String::new()), false),
|
||||
DocumentInputType::new("Negative Prompt", TaggedValue::String(String::new()), false),
|
||||
DocumentInputType::new("Adapt Input Image", TaggedValue::Bool(false), false),
|
||||
DocumentInputType::new("Image Creativity", TaggedValue::F64(66.), false),
|
||||
DocumentInputType::new("Masking Layer", TaggedValue::LayerPath(None), false),
|
||||
DocumentInputType::new("Inpaint", TaggedValue::Bool(true), false),
|
||||
DocumentInputType::new("Mask Blur", TaggedValue::F64(4.), false),
|
||||
DocumentInputType::new("Mask Starting Fill", TaggedValue::ImaginateMaskStartingFill(ImaginateMaskStartingFill::Fill), false),
|
||||
DocumentInputType::new("Improve Faces", TaggedValue::Bool(false), false),
|
||||
DocumentInputType::new("Tiling", TaggedValue::Bool(false), false),
|
||||
identifier: NodeImplementation::proto("graphene_std::raster::ImaginateNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Input Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::value("Transform", TaggedValue::DAffine2(DAffine2::IDENTITY), true),
|
||||
DocumentInputType::value("Seed", TaggedValue::F64(0.), false), // Remember to keep index used in `NodeGraphFrameImaginateRandom` updated with this entry's index
|
||||
DocumentInputType::value("Resolution", TaggedValue::OptionalDVec2(None), false),
|
||||
DocumentInputType::value("Samples", TaggedValue::F64(30.), false),
|
||||
DocumentInputType::value("Sampling Method", TaggedValue::ImaginateSamplingMethod(ImaginateSamplingMethod::EulerA), false),
|
||||
DocumentInputType::value("Prompt Guidance", TaggedValue::F64(7.5), false),
|
||||
DocumentInputType::value("Prompt", TaggedValue::String(String::new()), false),
|
||||
DocumentInputType::value("Negative Prompt", TaggedValue::String(String::new()), false),
|
||||
DocumentInputType::value("Adapt Input Image", TaggedValue::Bool(false), false),
|
||||
DocumentInputType::value("Image Creativity", TaggedValue::F64(66.), false),
|
||||
DocumentInputType::value("Masking Layer", TaggedValue::LayerPath(None), false),
|
||||
DocumentInputType::value("Inpaint", TaggedValue::Bool(true), false),
|
||||
DocumentInputType::value("Mask Blur", TaggedValue::F64(4.), false),
|
||||
DocumentInputType::value("Mask Starting Fill", TaggedValue::ImaginateMaskStartingFill(ImaginateMaskStartingFill::Fill), false),
|
||||
DocumentInputType::value("Improve Faces", TaggedValue::Bool(false), false),
|
||||
DocumentInputType::value("Tiling", TaggedValue::Bool(false), false),
|
||||
// Non-user status (is document input the right way to do this?)
|
||||
DocumentInputType::new("Cached Data", TaggedValue::RcImage(None), false),
|
||||
DocumentInputType::new("Percent Complete", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Status", TaggedValue::ImaginateStatus(ImaginateStatus::Idle), false),
|
||||
DocumentInputType::value("Cached Data", TaggedValue::RcImage(None), false),
|
||||
DocumentInputType::value("Percent Complete", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Status", TaggedValue::ImaginateStatus(ImaginateStatus::Idle), false),
|
||||
],
|
||||
outputs: &[DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::imaginate_properties,
|
||||
};
|
||||
});
|
||||
|
||||
pub fn resolve_document_node_type(name: &str) -> Option<&DocumentNodeType> {
|
||||
DOCUMENT_NODE_TYPES.iter().find(|node| node.name == name)
|
||||
@@ -580,7 +560,7 @@ impl DocumentNodeType {
|
||||
name: format!("{}_impl", self.name),
|
||||
// TODO: Allow inserting nodes that contain other nodes.
|
||||
implementation: DocumentNodeImplementation::Unresolved(ident.clone()),
|
||||
inputs: (0..num_inputs).map(|_| NodeInput::Network).collect(),
|
||||
inputs: self.inputs.iter().map(|i| NodeInput::Network(i.default.ty())).collect(),
|
||||
metadata: DocumentNodeMetadata::default(),
|
||||
},
|
||||
)]
|
||||
@@ -610,7 +590,7 @@ pub fn new_image_network(output_offset: i32, output_node_id: NodeId) -> NodeNetw
|
||||
outputs: vec![NodeOutput::new(1, 0)],
|
||||
nodes: [
|
||||
resolve_document_node_type("Input").expect("Input node does not exist").to_document_node(
|
||||
[NodeInput::Network, NodeInput::value(TaggedValue::DAffine2(DAffine2::IDENTITY), false)],
|
||||
[NodeInput::Network(concrete!(Image)), NodeInput::value(TaggedValue::DAffine2(DAffine2::IDENTITY), false)],
|
||||
DocumentNodeMetadata::position((8, 4)),
|
||||
),
|
||||
resolve_document_node_type("Output")
|
||||
|
||||
@@ -231,6 +231,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
||||
percent,
|
||||
status,
|
||||
} => {
|
||||
debug!("ImaginateSetGeneratingStatus: {:?} {:?} {:?} {:?}", document_id, layer_path, node_path, percent);
|
||||
let get = |name: &str| IMAGINATE_NODE.inputs.iter().position(|input| input.name == name).unwrap_or_else(|| panic!("Input {name} not found"));
|
||||
if let Some(percentage) = percent {
|
||||
responses.push_back(
|
||||
|
||||
@@ -120,7 +120,7 @@ impl Fsm for ImaginateToolFsmState {
|
||||
|
||||
use graph_craft::document::*;
|
||||
|
||||
let imaginate_node_type = IMAGINATE_NODE;
|
||||
let imaginate_node_type = &*IMAGINATE_NODE;
|
||||
|
||||
let mut imaginate_inputs: Vec<NodeInput> = imaginate_node_type.inputs.iter().map(|input| input.default.clone()).collect();
|
||||
imaginate_inputs[0] = NodeInput::node(0, 0);
|
||||
|
||||
@@ -39,7 +39,10 @@ impl NodeGraphExecutor {
|
||||
let proto_network = c.compile_single(network, true)?;
|
||||
|
||||
assert_ne!(proto_network.nodes.len(), 0, "No protonodes exist?");
|
||||
self.executor.update(proto_network);
|
||||
if let Err(e) = self.executor.update(proto_network) {
|
||||
error!("Failed to update executor:\n{}", e);
|
||||
return Err(e);
|
||||
}
|
||||
|
||||
use dyn_any::IntoDynAny;
|
||||
use graph_craft::executor::Executor;
|
||||
@@ -65,7 +68,7 @@ impl NodeGraphExecutor {
|
||||
}
|
||||
match &inner_network.nodes.get(&node_path[end]).unwrap().inputs[input_index] {
|
||||
// If the input is from a parent network then adjust the input index and continue iteration
|
||||
NodeInput::Network => {
|
||||
NodeInput::Network(_) => {
|
||||
input_index = inner_network
|
||||
.inputs
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user