@@ -1414,28 +1414,6 @@ async fn color_overlay<F: 'n + Copy + Send, T: Adjust<Color>>(
1414
1414
input
1415
1415
}
1416
1416
1417
- #[ test]
1418
- fn color_overlay_multiply ( ) {
1419
- use crate :: raster:: Image ;
1420
-
1421
- let image_color = Color :: from_rgbaf32_unchecked ( 0.7 , 0.6 , 0.5 , 0.4 ) ;
1422
- let image = ImageFrame {
1423
- image : Image :: new ( 1 , 1 , image_color) ,
1424
- ..Default :: default ( )
1425
- } ;
1426
-
1427
- // Color { red: 0., green: 1., blue: 0., alpha: 1. }
1428
- let overlay_color = Color :: GREEN ;
1429
-
1430
- // 100% of the output should come from the multiplied value
1431
- let opacity = 100_f64 ;
1432
-
1433
- let result = color_overlay ( image, overlay_color, BlendMode :: Multiply , opacity) ;
1434
-
1435
- // The output should just be the original green and alpha channels (as we multiply them by 1 and other channels by 0)
1436
- assert_eq ! ( result. image. data[ 0 ] , Color :: from_rgbaf32_unchecked( 0. , image_color. g( ) , 0. , image_color. a( ) ) ) ;
1437
- }
1438
-
1439
1417
#[ cfg( feature = "alloc" ) ]
1440
1418
pub use index_node:: IndexNode ;
1441
1419
@@ -1453,3 +1431,41 @@ mod index_node {
1453
1431
}
1454
1432
}
1455
1433
}
1434
+
1435
+ #[ cfg( test) ]
1436
+ mod test {
1437
+ use crate :: raster:: { BlendMode , Image , ImageFrame } ;
1438
+ use crate :: { Color , Node } ;
1439
+ use std:: pin:: Pin ;
1440
+
1441
+ #[ derive( Clone ) ]
1442
+ pub struct FutureWrapperNode < T : Clone > ( T ) ;
1443
+
1444
+ impl < ' i , T : ' i + Clone + Send > Node < ' i , ( ) > for FutureWrapperNode < T > {
1445
+ type Output = Pin < Box < dyn core:: future:: Future < Output = T > + ' i + Send > > ;
1446
+ fn eval ( & ' i self , _input : ( ) ) -> Self :: Output {
1447
+ let value = self . 0 . clone ( ) ;
1448
+ Box :: pin ( async move { value } )
1449
+ }
1450
+ }
1451
+
1452
+ #[ tokio:: test]
1453
+ async fn color_overlay_multiply ( ) {
1454
+ let image_color = Color :: from_rgbaf32_unchecked ( 0.7 , 0.6 , 0.5 , 0.4 ) ;
1455
+ let image = ImageFrame {
1456
+ image : Image :: new ( 1 , 1 , image_color) ,
1457
+ ..Default :: default ( )
1458
+ } ;
1459
+
1460
+ // Color { red: 0., green: 1., blue: 0., alpha: 1. }
1461
+ let overlay_color = Color :: GREEN ;
1462
+
1463
+ // 100% of the output should come from the multiplied value
1464
+ let opacity = 100_f64 ;
1465
+
1466
+ let result = super :: color_overlay ( ( ) , & FutureWrapperNode ( image) , overlay_color, BlendMode :: Multiply , opacity) . await ;
1467
+
1468
+ // The output should just be the original green and alpha channels (as we multiply them by 1 and other channels by 0)
1469
+ assert_eq ! ( result. image. data[ 0 ] , Color :: from_rgbaf32_unchecked( 0. , image_color. g( ) , 0. , image_color. a( ) ) ) ;
1470
+ }
1471
+ }
0 commit comments