mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 08:18:13 +08:00
Add "Blend" node (#1024)
* Add Blend node * Add more implementations Currently, known buggy implementations: * Color Burn * Saturation Opacity is currently achieved by linear interpolation, this will be changed as soon as all filters are implemented. * Add more implementations Currently, known incorrect implementations: * Color Burn * Saturation Not yet Tested: * Linear Burn * Linear Dodge * Vivid Light * Linear Light * Pin Light * Hard Mix * Subtract * Divide Opacity is currently achieved by linear interpolation, this will be changed as soon as all filters are implemented. * Cleanup * Removed Unused Code * Fixed Clamping Issue * Fixed Inverted Opacity * Moved Opacity Calculation from individual Blend Functions into 'blend_node' function * Fix 'Color Burn' blend mode Currently, known incorrect implementations: * Saturation Not yet Tested: * Linear Burn * Darker Color * Linear Dodge * Lighter Color * Vivid Light * Linear Light * Pin Light * Hard Mix * Subtract * Divide Opacity is currently achieved by linear interpolation, this will be changed as soon as all filters are implemented. * Fix 'Saturation' blend mode Currently, known incorrect implementations: * None :D Not yet Tested: * Linear Burn * Darker Color * Linear Dodge * Lighter Color * Vivid Light * Linear Light * Pin Light * Hard Mix * Subtract * Divide Opacity is currently achieved by linear interpolation, this will be changed as soon as all filters are implemented. * Final Cleanups * Add proper Inputs * cargo fmt * Add test for doubling number * Display implementation for ProtoNetwork * Switch top and bottom * Add input types for blend image node * Fix test --------- Co-authored-by: 0hypercube <0hypercube@gmail.com> Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
0hypercube
Dennis Kobert
parent
48dcc2774b
commit
8fe19063c1
@@ -23,6 +23,51 @@ pub struct ProtoNetwork {
|
||||
pub nodes: Vec<(NodeId, ProtoNode)>,
|
||||
}
|
||||
|
||||
impl core::fmt::Display for ProtoNetwork {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.write_str("Proto Network with nodes: ")?;
|
||||
fn write_node(f: &mut core::fmt::Formatter<'_>, network: &ProtoNetwork, id: NodeId, indent: usize) -> core::fmt::Result {
|
||||
f.write_str(&"\t".repeat(indent))?;
|
||||
let Some((_, node)) = network.nodes.iter().find(|(node_id, _)|*node_id == id) else{
|
||||
return f.write_str("{{Unknown Node}}");
|
||||
};
|
||||
f.write_str("Node: ")?;
|
||||
f.write_str(&node.identifier.name)?;
|
||||
|
||||
f.write_str("\n")?;
|
||||
f.write_str(&"\t".repeat(indent))?;
|
||||
f.write_str("{\n")?;
|
||||
|
||||
f.write_str(&"\t".repeat(indent + 1))?;
|
||||
f.write_str("Primary input: ")?;
|
||||
match &node.input {
|
||||
ProtoNodeInput::None => f.write_str("None")?,
|
||||
ProtoNodeInput::Network(ty) => f.write_fmt(format_args!("Network (type = {:?})", ty))?,
|
||||
ProtoNodeInput::Node(_) => f.write_str("Node")?,
|
||||
}
|
||||
f.write_str("\n")?;
|
||||
|
||||
match &node.construction_args {
|
||||
ConstructionArgs::Value(value) => {
|
||||
f.write_str(&"\t".repeat(indent + 1))?;
|
||||
f.write_fmt(format_args!("Value construction argument: {value:?}"))?
|
||||
}
|
||||
ConstructionArgs::Nodes(nodes) => {
|
||||
for id in nodes {
|
||||
write_node(f, network, *id, indent + 1)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
f.write_str(&"\t".repeat(indent))?;
|
||||
f.write_str("}\n")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
let id = self.output;
|
||||
write_node(f, self, id, 0)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ConstructionArgs {
|
||||
Value(value::TaggedValue),
|
||||
|
||||
Reference in New Issue
Block a user