Skip to content

Commit

Permalink
Remove node definitions for Adjustment Nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueDoctor committed Aug 27, 2024
1 parent 23f49b2 commit 65c4876
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 339 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -947,52 +947,6 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
properties: &node_properties::node_no_properties,
},
// TODO: Consolidate this into the regular Blend node once we can make its generic types all compatible, and not break the brush tool which uses that Blend node
DocumentNodeDefinition {
identifier: "Blend Colors",
category: "Raster",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::proto("graphene_core::raster::BlendColorsNode<_, _, _>"),
inputs: vec![
NodeInput::value(TaggedValue::Color(Color::TRANSPARENT), true),
NodeInput::value(TaggedValue::Color(Color::TRANSPARENT), true),
NodeInput::value(TaggedValue::BlendMode(BlendMode::Normal), false),
NodeInput::value(TaggedValue::F64(100.), false),
],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_names: vec!["Over".to_string(), "Under".to_string(), "Blend Mode".to_string(), "Opacity".to_string()],
output_names: vec!["Combined".to_string()],
..Default::default()
},
},
properties: &node_properties::blend_color_properties,
},
// TODO: This needs to work with resolution-aware (raster with footprint, post-Cull node) data.
DocumentNodeDefinition {
identifier: "Blend",
category: "Raster",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::proto("graphene_core::raster::BlendNode<_, _, _, _>"),
inputs: vec![
NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true),
NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true),
NodeInput::value(TaggedValue::BlendMode(BlendMode::Normal), false),
NodeInput::value(TaggedValue::F64(100.), false),
],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_names: vec!["Image".to_string(), "Second".to_string(), "Blend Mode".to_string(), "Opacity".to_string()],
output_names: vec!["Image".to_string()],
..Default::default()
},
},
properties: &node_properties::blend_properties,
},
DocumentNodeDefinition {
identifier: "Levels",
category: "Raster: Adjustment",
Expand Down Expand Up @@ -2194,29 +2148,6 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
properties: &node_properties::node_no_properties,
},
#[cfg(feature = "gpu")]
DocumentNodeDefinition {
identifier: "Blend (GPU)",
category: "Debug: GPU",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::proto("graphene_std::executor::BlendGpuImageNode<_, _, _>"),
inputs: vec![
NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true),
NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true),
NodeInput::value(TaggedValue::BlendMode(BlendMode::Normal), false),
NodeInput::value(TaggedValue::F64(100.), false),
],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_names: vec!["Image".to_string(), "Second".to_string(), "Blend Mode".to_string(), "Opacity".to_string()],
output_names: vec!["Image".to_string()],
..Default::default()
},
},
properties: &node_properties::blend_properties,
},
DocumentNodeDefinition {
identifier: "Extract",
category: "Debug",
Expand Down Expand Up @@ -2298,45 +2229,6 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
properties: &node_properties::quantize_properties,
},
DocumentNodeDefinition {
identifier: "Invert",
category: "Raster: Adjustment",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::proto("graphene_core::raster::InvertNode"),
inputs: vec![NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true)],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_names: vec!["Image".to_string()],
output_names: vec!["Image".to_string()],
..Default::default()
},
},
properties: &node_properties::node_no_properties,
},
DocumentNodeDefinition {
identifier: "Hue/Saturation",
category: "Raster: Adjustment",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::proto("graphene_core::raster::HueSaturationNode<_, _, _>"),
inputs: vec![
NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true),
NodeInput::value(TaggedValue::F64(0.), false),
NodeInput::value(TaggedValue::F64(0.), false),
NodeInput::value(TaggedValue::F64(0.), false),
],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_names: vec!["Image".to_string(), "Hue Shift".to_string(), "Saturation Shift".to_string(), "Lightness Shift".to_string()],
output_names: vec!["Image".to_string()],
..Default::default()
},
},
properties: &node_properties::hue_saturation_properties,
},
DocumentNodeDefinition {
identifier: "Brightness/Contrast",
category: "Raster: Adjustment",
Expand Down Expand Up @@ -2379,66 +2271,6 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
properties: &node_properties::curves_properties,
},
DocumentNodeDefinition {
identifier: "Threshold",
category: "Raster: Adjustment",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::proto("graphene_core::raster::ThresholdNode<_, _, _>"),
inputs: vec![
NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true),
NodeInput::value(TaggedValue::F64(50.), false),
NodeInput::value(TaggedValue::F64(100.), false),
NodeInput::value(TaggedValue::LuminanceCalculation(LuminanceCalculation::SRGB), false),
],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_names: vec!["Image".to_string(), "Min Luminance".to_string(), "Max Luminance".to_string(), "Luminance Calc".to_string()],
output_names: vec!["Image".to_string()],
..Default::default()
},
},
properties: &node_properties::threshold_properties,
},
DocumentNodeDefinition {
identifier: "Gradient Map",
category: "Raster: Adjustment",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::proto("graphene_core::raster::GradientMapNode<_, _>"),
inputs: vec![
NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true),
NodeInput::value(TaggedValue::GradientStops(vector::style::GradientStops::default()), false),
NodeInput::value(TaggedValue::Bool(false), false),
],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_names: vec!["Image".to_string(), "Gradient".to_string()],
output_names: vec!["Image".to_string()],
..Default::default()
},
},
properties: &node_properties::gradient_map_properties,
},
DocumentNodeDefinition {
identifier: "Vibrance",
category: "Raster: Adjustment",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::proto("graphene_core::raster::VibranceNode<_>"),
inputs: vec![NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true), NodeInput::value(TaggedValue::F64(0.), false)],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_names: vec!["Image".to_string(), "Vibrance".to_string()],
output_names: vec!["Image".to_string()],
..Default::default()
},
},
properties: &node_properties::vibrance_properties,
},
DocumentNodeDefinition {
identifier: "Channel Mixer",
category: "Raster: Adjustment",
Expand Down Expand Up @@ -2612,23 +2444,6 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
},
properties: &node_properties::selective_color_properties,
},
DocumentNodeDefinition {
identifier: "Posterize",
category: "Raster: Adjustment",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::proto("graphene_core::raster::PosterizeNode<_>"),
inputs: vec![NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true), NodeInput::value(TaggedValue::F64(4.), false)],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_names: vec!["Image".to_string(), "Levels".to_string()],
output_names: vec!["Image".to_string()],
..Default::default()
},
},
properties: &node_properties::posterize_properties,
},
DocumentNodeDefinition {
identifier: "Exposure",
category: "Raster: Adjustment",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ pub(crate) fn property_from_type(document_node: &DocumentNode, node_id: NodeId,
Type::Concrete(concrete_type) => {
match concrete_type.name.as_ref() {
// Aliased types (ambiguous values)
"Percentage" => number_widget(document_node, node_id, index, name, NumberInput::default().percentage().min(0.).max(100.), false).into(),
"Angle" => number_widget(document_node, node_id, index, name, NumberInput::default().mode_range().min(-180.).max(180.).unit("°"), false).into(),
"PixelLength" => number_widget(document_node, node_id, index, name, NumberInput::default().min(0.).unit("px"), false).into(),
"IntegerCount" => number_widget(document_node, node_id, index, name, NumberInput::default().int().min(1.), false).into(),
"SeedValue" => number_widget(document_node, node_id, index, name, NumberInput::default().int().min(0.), false).into(),
"Resolution" => vec2_widget(document_node, node_id, index, name, "W", "H", "px", Some(64.), add_blank_assist),
"graphene_core::registry::types::Percentage" => number_widget(document_node, node_id, index, name, NumberInput::default().percentage().min(0.).max(100.), false).into(),
"graphene_core::registry::types::Angle" => number_widget(document_node, node_id, index, name, NumberInput::default().mode_range().min(-180.).max(180.).unit("°"), false).into(),
"graphene_core::registry::types::PixelLength" => number_widget(document_node, node_id, index, name, NumberInput::default().min(0.).unit("px"), false).into(),
"graphene_core::registry::types::IntegerCount" => number_widget(document_node, node_id, index, name, NumberInput::default().int().min(1.), false).into(),
"graphene_core::registry::types::SeedValue" => number_widget(document_node, node_id, index, name, NumberInput::default().int().min(0.), false).into(),
"graphene_core::registry::types::Resolution" => vec2_widget(document_node, node_id, index, name, "W", "H", "px", Some(64.), add_blank_assist),

// For all other types, use TypeId-based matching
_ => {
Expand Down Expand Up @@ -1100,20 +1100,8 @@ pub(crate) fn black_and_white_properties(document_node: &DocumentNode, node_id:
]
}

pub(crate) fn blend_color_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let under = color_widget(document_node, node_id, 1, "Under", ColorButton::default(), true);
let blend_mode = blend_mode(document_node, node_id, 2, "Blend Mode", true);
let opacity = number_widget(document_node, node_id, 3, "Opacity", NumberInput::default().mode_range().min(0.).max(100.).unit("%"), true);

vec![under, blend_mode, LayoutGroup::Row { widgets: opacity }]
}

pub(crate) fn blend_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let backdrop = color_widget(document_node, node_id, 1, "Backdrop", ColorButton::default(), true);
let blend_mode = blend_mode(document_node, node_id, 2, "Blend Mode", true);
let opacity = number_widget(document_node, node_id, 3, "Opacity", NumberInput::default().mode_range().min(0.).max(100.).unit("%"), true);

vec![backdrop, blend_mode, LayoutGroup::Row { widgets: opacity }]
pub(crate) fn blend_mode_value_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
vec![blend_mode(document_node, node_id, 0, "Blend Mode", true)]
}

pub(crate) fn number_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
Expand Down Expand Up @@ -1326,18 +1314,6 @@ pub(crate) fn noise_pattern_properties(document_node: &DocumentNode, node_id: No
]
}

pub(crate) fn hue_saturation_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let hue_shift = number_widget(document_node, node_id, 1, "Hue Shift", NumberInput::default().min(-180.).max(180.).unit("°"), true);
let saturation_shift = number_widget(document_node, node_id, 2, "Saturation Shift", NumberInput::default().mode_range().min(-100.).max(100.).unit("%"), true);
let lightness_shift = number_widget(document_node, node_id, 3, "Lightness Shift", NumberInput::default().mode_range().min(-100.).max(100.).unit("%"), true);

vec![
LayoutGroup::Row { widgets: hue_shift },
LayoutGroup::Row { widgets: saturation_shift },
LayoutGroup::Row { widgets: lightness_shift },
]
}

pub(crate) fn brightness_contrast_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let brightness = number_widget(document_node, node_id, 1, "Brightness", NumberInput::default().min(-150.).max(150.), true);
let contrast = number_widget(document_node, node_id, 2, "Contrast", NumberInput::default().min(-100.).max(100.), true);
Expand All @@ -1363,24 +1339,6 @@ pub(crate) fn _blur_image_properties(document_node: &DocumentNode, node_id: Node
vec![LayoutGroup::Row { widgets: radius }, LayoutGroup::Row { widgets: sigma }]
}

pub(crate) fn threshold_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let thereshold_min = number_widget(document_node, node_id, 1, "Min Luminance", NumberInput::default().mode_range().min(0.).max(100.).unit("%"), true);
let thereshold_max = number_widget(document_node, node_id, 2, "Max Luminance", NumberInput::default().mode_range().min(0.).max(100.).unit("%"), true);
let luminance_calc = luminance_calculation(document_node, node_id, 3, "Luminance Calc", true);

vec![LayoutGroup::Row { widgets: thereshold_min }, LayoutGroup::Row { widgets: thereshold_max }, luminance_calc]
}

pub(crate) fn gradient_map_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let gradient_index = 1;
let reverse_index = 2;

let gradient_row = color_widget(document_node, node_id, gradient_index, "Gradient", ColorButton::default().allow_none(false), true);
let reverse_row = bool_widget(document_node, node_id, reverse_index, "Reverse", CheckboxInput::default(), true);

vec![gradient_row, LayoutGroup::Row { widgets: reverse_row }]
}

pub(crate) fn assign_colors_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let fill_index = 1;
let stroke_index = 2;
Expand Down Expand Up @@ -1421,21 +1379,6 @@ pub(crate) fn assign_colors_properties(document_node: &DocumentNode, node_id: No
]
}

pub(crate) fn vibrance_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let vibrance_index = 1;

let vibrance = number_widget(
document_node,
node_id,
vibrance_index,
"Vibrance",
NumberInput::default().mode_range().min(-100.).max(100.).unit("%"),
true,
);

vec![LayoutGroup::Row { widgets: vibrance }]
}

pub(crate) fn channel_mixer_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
// Monochrome
let monochrome_index = 1;
Expand Down Expand Up @@ -1632,26 +1575,6 @@ pub(crate) fn _gpu_map_properties(document_node: &DocumentNode, node_id: NodeId,
vec![LayoutGroup::Row { widgets: map }]
}

pub(crate) fn opacity_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let gamma = number_widget(document_node, node_id, 1, "Factor", NumberInput::default().mode_range().min(0.).max(100.).unit("%"), true);

vec![LayoutGroup::Row { widgets: gamma }]
}

pub(crate) fn blend_mode_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
vec![blend_mode(document_node, node_id, 1, "Blend Mode", true)]
}

pub(crate) fn blend_mode_value_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
vec![blend_mode(document_node, node_id, 0, "Blend Mode", true)]
}

pub(crate) fn posterize_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let value = number_widget(document_node, node_id, 1, "Levels", NumberInput::default().min(2.).max(255.).int(), true);

vec![LayoutGroup::Row { widgets: value }]
}

#[cfg(feature = "quantization")]
pub(crate) fn quantize_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let value = number_widget(document_node, node_id, 1, "Levels", NumberInput::default().min(1.).max(1000.).int(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::messages::portfolio::document::node_graph::utility_types::{Direction,

use bezier_rs::Subpath;
use graph_craft::document::{value::TaggedValue, DocumentNode, DocumentNodeImplementation, NodeId, NodeInput, NodeNetwork, OldDocumentNodeImplementation, OldNodeNetwork};
use graph_craft::{concrete, ProtoNodeIdentifier, Type};
use graph_craft::{concrete, Type};
use graphene_std::renderer::{ClickTarget, Quad};
use graphene_std::vector::{PointId, VectorModificationType};
use interpreted_executor::{dynamic_executor::ResolvedDocumentNodeTypes, node_registry::NODE_REGISTRY};
Expand Down
Loading

0 comments on commit 65c4876

Please sign in to comment.