Introduce scopes (#1053)

* Implement let binding

* Add lambda inputs

* Fix tests

* Fix proto network formatting

* Generate a template Scoped network by default

* Add comment to explain the lambda parameter

* Move binding wrapping out of the template

* Fix errors cause by image frames
This commit is contained in:
Dennis Kobert
2023-03-02 17:13:28 +01:00
committed by Keavon Chambers
parent 0b813805d2
commit 7254c008f9
12 changed files with 366 additions and 118 deletions

View File

@@ -131,13 +131,14 @@ pub struct BlendImageNode<Second, MapFn> {
map_fn: MapFn,
}
// TODO: Implement proper blending
#[node_macro::node_fn(BlendImageNode)]
fn blend_image<MapFn>(image: Image, second: Image, map_fn: &'any_input MapFn) -> Image
fn blend_image<MapFn>(image: ImageFrame, second: ImageFrame, map_fn: &'any_input MapFn) -> ImageFrame
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()) {
for (pixel, sec_pixel) in &mut image.image.data.iter_mut().zip(second.image.data.iter()) {
*pixel = map_fn.eval((*pixel, *sec_pixel));
}
image