@@ -7,10 +7,13 @@ use core::fmt::Debug;
7
7
use graphene_core:: gradient:: GradientStops ;
8
8
#[ cfg( feature = "std" ) ]
9
9
use graphene_core:: raster_types:: { CPU , Raster } ;
10
+ #[ cfg( feature = "std" ) ]
10
11
use graphene_core:: table:: Table ;
11
12
use graphene_core_shaders:: color:: Color ;
12
13
use graphene_core_shaders:: context:: Ctx ;
13
14
use graphene_core_shaders:: registry:: types:: { Angle , Percentage , SignedPercentage } ;
15
+ #[ cfg( not( feature = "std" ) ) ]
16
+ use num_traits:: float:: Float ;
14
17
15
18
// TODO: Implement the following:
16
19
// Color Balance
@@ -125,7 +128,7 @@ fn make_opaque<T: Adjust<Color>>(
125
128
if color. a ( ) == 0. {
126
129
return color. with_alpha ( 1. ) ;
127
130
}
128
- Color :: from_rgbaf32 ( color. r ( ) / color. a ( ) , color. g ( ) / color. a ( ) , color. b ( ) / color. a ( ) , 1. ) . unwrap ( )
131
+ Color :: from_rgbaf32_unchecked ( color. r ( ) / color. a ( ) , color. g ( ) / color. a ( ) , color. b ( ) / color. a ( ) , 1. )
129
132
} ) ;
130
133
input
131
134
}
@@ -295,7 +298,7 @@ fn levels<T: Adjust<Color>>(
295
298
// https://stackoverflow.com/a/55233732/775283
296
299
// Works the same for gamma and linear color
297
300
#[ node_macro:: node( name( "Black & White" ) , category( "Raster: Adjustment" ) , shader_node( PerPixelAdjust ) ) ]
298
- async fn black_and_white < T : Adjust < Color > > (
301
+ fn black_and_white < T : Adjust < Color > > (
299
302
_: impl Ctx ,
300
303
#[ implementations(
301
304
Table <Raster <CPU >>,
@@ -360,7 +363,7 @@ async fn black_and_white<T: Adjust<Color>>(
360
363
// TODO: Fix "Color" blend mode implementation so it matches the expected behavior perfectly (it's currently close)
361
364
let color = tint. with_luminance ( luminance) ;
362
365
363
- let color = Color :: from_rgbaf32 ( color. r ( ) , color. g ( ) , color. b ( ) , alpha_part) . unwrap ( ) ;
366
+ let color = Color :: from_rgbaf32_unchecked ( color. r ( ) , color. g ( ) , color. b ( ) , alpha_part) ;
364
367
365
368
color. to_linear_srgb ( )
366
369
} ) ;
@@ -371,7 +374,7 @@ async fn black_and_white<T: Adjust<Color>>(
371
374
// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=%27hue%20%27%20%3D%20Old,saturation%2C%20Photoshop%205.0
372
375
// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=0%20%3D%20Use%20other.-,Hue/Saturation,-Hue/Saturation%20settings
373
376
#[ node_macro:: node( name( "Hue/Saturation" ) , category( "Raster: Adjustment" ) , shader_node( PerPixelAdjust ) ) ]
374
- async fn hue_saturation < T : Adjust < Color > > (
377
+ fn hue_saturation < T : Adjust < Color > > (
375
378
_: impl Ctx ,
376
379
#[ implementations(
377
380
Table <Raster <CPU >>,
@@ -406,7 +409,7 @@ async fn hue_saturation<T: Adjust<Color>>(
406
409
// Aims for interoperable compatibility with:
407
410
// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=%27%20%3D%20Color%20Lookup-,%27nvrt%27%20%3D%20Invert,-%27post%27%20%3D%20Posterize
408
411
#[ node_macro:: node( category( "Raster: Adjustment" ) , shader_node( PerPixelAdjust ) ) ]
409
- async fn invert < T : Adjust < Color > > (
412
+ fn invert < T : Adjust < Color > > (
410
413
_: impl Ctx ,
411
414
#[ implementations(
412
415
Table <Raster <CPU >>,
@@ -429,7 +432,7 @@ async fn invert<T: Adjust<Color>>(
429
432
// Aims for interoperable compatibility with:
430
433
// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=post%27%20%3D%20Posterize-,%27thrs%27%20%3D%20Threshold,-%27grdm%27%20%3D%20Gradient
431
434
#[ node_macro:: node( category( "Raster: Adjustment" ) , shader_node( PerPixelAdjust ) ) ]
432
- async fn threshold < T : Adjust < Color > > (
435
+ fn threshold < T : Adjust < Color > > (
433
436
_: impl Ctx ,
434
437
#[ implementations(
435
438
Table <Raster <CPU >>,
@@ -475,7 +478,7 @@ async fn threshold<T: Adjust<Color>>(
475
478
// When both parameters are set, it is equivalent to running this adjustment twice, with only vibrance set and then only saturation set.
476
479
// (Except for some noise probably due to rounding error.)
477
480
#[ node_macro:: node( category( "Raster: Adjustment" ) , shader_node( PerPixelAdjust ) ) ]
478
- async fn vibrance < T : Adjust < Color > > (
481
+ fn vibrance < T : Adjust < Color > > (
479
482
_: impl Ctx ,
480
483
#[ implementations(
481
484
Table <Raster <CPU >>,
@@ -641,7 +644,7 @@ pub enum DomainWarpType {
641
644
// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=%27mixr%27%20%3D%20Channel%20Mixer
642
645
// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=Lab%20color%20only-,Channel%20Mixer,-Key%20is%20%27mixr
643
646
#[ node_macro:: node( category( "Raster: Adjustment" ) , properties( "channel_mixer_properties" ) , shader_node( PerPixelAdjust ) ) ]
644
- async fn channel_mixer < T : Adjust < Color > > (
647
+ fn channel_mixer < T : Adjust < Color > > (
645
648
_: impl Ctx ,
646
649
#[ implementations(
647
650
Table <Raster <CPU >>,
@@ -770,7 +773,7 @@ pub enum SelectiveColorChoice {
770
773
// Algorithm based on:
771
774
// https://blog.pkh.me/p/22-understanding-selective-coloring-in-adobe-photoshop.html
772
775
#[ node_macro:: node( category( "Raster: Adjustment" ) , properties( "selective_color_properties" ) , shader_node( PerPixelAdjust ) ) ]
773
- async fn selective_color < T : Adjust < Color > > (
776
+ fn selective_color < T : Adjust < Color > > (
774
777
_: impl Ctx ,
775
778
#[ implementations(
776
779
Table <Raster <CPU >>,
@@ -913,7 +916,7 @@ async fn selective_color<T: Adjust<Color>>(
913
916
// https://www.axiomx.com/posterize.htm
914
917
// This algorithm produces fully accurate output in relation to the industry standard.
915
918
#[ node_macro:: node( category( "Raster: Adjustment" ) , shader_node( PerPixelAdjust ) ) ]
916
- async fn posterize < T : Adjust < Color > > (
919
+ fn posterize < T : Adjust < Color > > (
917
920
_: impl Ctx ,
918
921
#[ implementations(
919
922
Table <Raster <CPU >>,
@@ -947,7 +950,7 @@ async fn posterize<T: Adjust<Color>>(
947
950
// Algorithm based on:
948
951
// https://geraldbakker.nl/psnumbers/exposure.html
949
952
#[ node_macro:: node( category( "Raster: Adjustment" ) , properties( "exposure_properties" ) , shader_node( PerPixelAdjust ) ) ]
950
- async fn exposure < T : Adjust < Color > > (
953
+ fn exposure < T : Adjust < Color > > (
951
954
_: impl Ctx ,
952
955
#[ implementations(
953
956
Table <Raster <CPU >>,
0 commit comments