mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 10:58:04 +08:00
New node: Color Overlay (#1391)
* [wip]feat: implement Color Overlay node's base logic * [wip]feat: attempt implementing node * feat: implement naive node logic - this needs to accommodate coloring the image * [wip]feat: attempt implementing ColorFillNode * fix: color fill node implementation path * Simplify document node definition * [wip]feat: implement ColorFillNode - correct the node implementation logic -[wip]use node in Color Overlay node network * Remove secondary image input * chore: perform cleanup and minor optimization - rename ColorFillNode node to Color Fill - remove unneeded clone method call * refactor: optimize node logic and hide optional params * fix: color fill implementation - fix broken color fill implementation logic - add alpha multiplication data to the image * Fix colour overlay node * Blend mode * chore: remove unused import * Debug logging for overlay * Use premultiplied alpha * Comment out logging * Code review nits * Remove color debug logging --------- Co-authored-by: Dennis Kobert <dennis@kobert.dev> Co-authored-by: 0hypercube <0hypercube@gmail.com> Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
@@ -589,6 +589,8 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
PasteImage { image, mouse } => {
|
||||
// All the image's pixels have been converted to 0..=1, linear, and premultiplied by `Color::from_rgba8_srgb`
|
||||
|
||||
let image_size = DVec2::new(image.width as f64, image.height as f64);
|
||||
|
||||
let Some(image_node_type) = crate::messages::portfolio::document::node_graph::resolve_document_node_type("Image") else {
|
||||
|
||||
@@ -2211,7 +2211,34 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
DocumentInputType::value("Index", TaggedValue::U32(0), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::index_node_properties,
|
||||
properties: node_properties::index_properties,
|
||||
..Default::default()
|
||||
},
|
||||
// Applies the given color to each pixel of an image but maintains the alpha value
|
||||
DocumentNodeType {
|
||||
name: "Color Fill",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::adjustments::ColorFillNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Color", TaggedValue::Color(Color::BLACK), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::color_fill_properties,
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Color Overlay",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::adjustments::ColorOverlayNode<_, _, _>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Color", TaggedValue::Color(Color::BLACK), false),
|
||||
DocumentInputType::value("Blend Mode", TaggedValue::BlendMode(BlendMode::Normal), false),
|
||||
DocumentInputType::value("Opacity", TaggedValue::F32(100.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::color_overlay_properties,
|
||||
..Default::default()
|
||||
},
|
||||
]
|
||||
|
||||
@@ -1810,7 +1810,7 @@ pub fn no_properties(_document_node: &DocumentNode, _node_id: NodeId, _context:
|
||||
string_properties("Node has no properties")
|
||||
}
|
||||
|
||||
pub fn index_node_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
pub fn index_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let index = number_widget(document_node, node_id, 1, "Index", NumberInput::default().min(0.), true);
|
||||
|
||||
vec![LayoutGroup::Row { widgets: index }]
|
||||
@@ -1938,3 +1938,16 @@ pub fn artboard_properties(document_node: &DocumentNode, node_id: NodeId, _conte
|
||||
};
|
||||
vec![location, dimensions, background, clip]
|
||||
}
|
||||
|
||||
pub fn color_fill_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let color = color_widget(document_node, node_id, 1, "Color", ColorInput::default(), true);
|
||||
vec![color]
|
||||
}
|
||||
|
||||
pub fn color_overlay_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let color = color_widget(document_node, node_id, 1, "Color", ColorInput::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().percentage(), true);
|
||||
|
||||
vec![color, blend_mode, LayoutGroup::Row { widgets: opacity }]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user