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:
isiko
2023-02-23 12:55:32 +01:00
committed by Keavon Chambers
parent 48dcc2774b
commit 8fe19063c1
10 changed files with 534 additions and 10 deletions

View File

@@ -107,6 +107,24 @@ where
image
}
#[derive(Debug, Clone, Copy)]
pub struct BlendImageNode<Second, MapFn> {
second: Second,
map_fn: MapFn,
}
#[node_macro::node_fn(BlendImageNode)]
fn blend_image<MapFn>(image: Image, second: Image, map_fn: &'any_input MapFn) -> Image
where
MapFn: for<'any_input> Node<'any_input, (Color, Color), Output = Color> + 'input,
{
let mut image = image;
for (pixel, sec_pixel) in &mut image.data.iter_mut().zip(second.data.iter()) {
*pixel = map_fn.eval((*pixel, *sec_pixel));
}
image
}
#[derive(Debug, Clone, Copy)]
pub struct ImaginateNode<E> {
cached: E,