mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
New nodes: Blend Colors, Percentage Value
This commit is contained in:
parent
c39032ab54
commit
d7546fb183
6 changed files with 175 additions and 9 deletions
|
|
@ -98,6 +98,23 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
},
|
||||
properties: node_properties::number_properties,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Percentage Value",
|
||||
category: "Value",
|
||||
node_template: NodeTemplate {
|
||||
document_node: DocumentNode {
|
||||
implementation: DocumentNodeImplementation::proto("graphene_core::ops::IdentityNode"),
|
||||
inputs: vec![NodeInput::value(TaggedValue::F64(0.), false)],
|
||||
..Default::default()
|
||||
},
|
||||
persistent_node_metadata: DocumentNodePersistentMetadata {
|
||||
input_names: vec!["Percentage".to_string()],
|
||||
output_names: vec!["Out".to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
},
|
||||
properties: node_properties::percentage_properties,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Color Value",
|
||||
category: "Value",
|
||||
|
|
@ -115,6 +132,23 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
},
|
||||
properties: node_properties::color_properties,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Gradient Value",
|
||||
category: "Value",
|
||||
node_template: NodeTemplate {
|
||||
document_node: DocumentNode {
|
||||
implementation: DocumentNodeImplementation::proto("graphene_core::ops::IdentityNode"),
|
||||
inputs: vec![NodeInput::value(TaggedValue::GradientStops(vector::style::GradientStops::default()), false)],
|
||||
..Default::default()
|
||||
},
|
||||
persistent_node_metadata: DocumentNodePersistentMetadata {
|
||||
input_names: vec!["Gradient".to_string()],
|
||||
output_names: vec!["Out".to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
},
|
||||
properties: node_properties::gradient_properties,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Vector2 Value",
|
||||
category: "Value",
|
||||
|
|
@ -934,6 +968,46 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
},
|
||||
properties: node_properties::node_no_properties,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Unwrap",
|
||||
category: "Debug",
|
||||
node_template: NodeTemplate {
|
||||
document_node: DocumentNode {
|
||||
implementation: DocumentNodeImplementation::proto("graphene_core::ops::UnwrapNode"),
|
||||
inputs: vec![NodeInput::value(TaggedValue::OptionalColor(None), true)],
|
||||
..Default::default()
|
||||
},
|
||||
persistent_node_metadata: DocumentNodePersistentMetadata {
|
||||
input_names: vec!["Value".to_string()],
|
||||
output_names: vec!["Value".to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
},
|
||||
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",
|
||||
|
|
@ -950,7 +1024,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
..Default::default()
|
||||
},
|
||||
persistent_node_metadata: DocumentNodePersistentMetadata {
|
||||
input_names: vec!["Image".to_string(), "Second".to_string(), "BlendMode".to_string(), "Opacity".to_string()],
|
||||
input_names: vec!["Image".to_string(), "Second".to_string(), "Blend Mode".to_string(), "Opacity".to_string()],
|
||||
output_names: vec!["Image".to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
|
|
|
|||
|
|
@ -969,6 +969,14 @@ pub fn black_and_white_properties(document_node: &DocumentNode, node_id: NodeId,
|
|||
]
|
||||
}
|
||||
|
||||
pub 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 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);
|
||||
|
|
@ -983,6 +991,12 @@ pub fn number_properties(document_node: &DocumentNode, node_id: NodeId, _context
|
|||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
|
||||
pub fn percentage_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let widgets = number_widget(document_node, node_id, 0, "Percentage", NumberInput::default().min(0.).max(100.).mode_range(), true);
|
||||
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
|
||||
pub fn vector2_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let x = number_widget(document_node, node_id, 1, "X", NumberInput::default(), true);
|
||||
let y = number_widget(document_node, node_id, 2, "Y", NumberInput::default(), true);
|
||||
|
|
@ -1000,6 +1014,10 @@ pub fn color_properties(document_node: &DocumentNode, node_id: NodeId, _context:
|
|||
vec![color_widget(document_node, node_id, 0, "Color", ColorButton::default(), true)]
|
||||
}
|
||||
|
||||
pub fn gradient_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
vec![color_widget(document_node, node_id, 0, "Gradient", ColorButton::default().allow_none(false), true)]
|
||||
}
|
||||
|
||||
pub fn load_image_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let url = text_widget(document_node, node_id, 1, "URL", true);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue