mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Add the Extract Opaque node (#1276)
* Add 'Extract Opaqueue Node' * Fix node --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
@@ -207,6 +207,17 @@ fn extract_alpha_node(color: Color) -> Color {
|
||||
Color::from_rgbaf32(alpha, alpha, alpha, 1.0).unwrap()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct ExtractOpaqueNode;
|
||||
|
||||
#[node_macro::node_fn(ExtractOpaqueNode)]
|
||||
fn extract_opaque_node(color: Color) -> Color {
|
||||
if color.a() == 0. {
|
||||
return color.with_alpha(1.);
|
||||
}
|
||||
Color::from_rgbaf32(color.r() / color.a(), color.g() / color.a(), color.b() / color.a(), 1.0).unwrap()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct LevelsNode<InputStart, InputMid, InputEnd, OutputStart, OutputEnd> {
|
||||
input_start: InputStart,
|
||||
|
||||
@@ -304,6 +304,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
|
||||
raster_node!(graphene_core::raster::LuminanceNode<_>, params: [LuminanceCalculation]),
|
||||
raster_node!(graphene_core::raster::ExtractChannelNode<_>, params: [RedGreenBlue]),
|
||||
raster_node!(graphene_core::raster::ExtractAlphaNode<>, params: []),
|
||||
raster_node!(graphene_core::raster::ExtractOpaqueNode<>, params: []),
|
||||
raster_node!(graphene_core::raster::LevelsNode<_, _, _, _, _>, params: [f64, f64, f64, f64, f64]),
|
||||
register_node!(graphene_std::image_segmentation::ImageSegmentationNode<_>, input: ImageFrame<Color>, params: [ImageFrame<Color>]),
|
||||
register_node!(graphene_core::raster::IndexNode<_>, input: Vec<ImageFrame<Color>>, params: [u32]),
|
||||
|
||||
Reference in New Issue
Block a user