@@ -7,10 +7,13 @@ use core::fmt::Debug;
77use graphene_core:: gradient:: GradientStops ;
88#[ cfg( feature = "std" ) ]
99use graphene_core:: raster_types:: { CPU , Raster } ;
10+ #[ cfg( feature = "std" ) ]
1011use graphene_core:: table:: Table ;
1112use graphene_core_shaders:: color:: Color ;
1213use graphene_core_shaders:: context:: Ctx ;
1314use graphene_core_shaders:: registry:: types:: { Angle , Percentage , SignedPercentage } ;
15+ #[ cfg( not( feature = "std" ) ) ]
16+ use num_traits:: float:: Float ;
1417
1518// TODO: Implement the following:
1619// Color Balance
@@ -125,7 +128,7 @@ fn make_opaque<T: Adjust<Color>>(
125128 if color. a ( ) == 0. {
126129 return color. with_alpha ( 1. ) ;
127130 }
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. )
129132 } ) ;
130133 input
131134}
@@ -295,7 +298,7 @@ fn levels<T: Adjust<Color>>(
295298// https://stackoverflow.com/a/55233732/775283
296299// Works the same for gamma and linear color
297300#[ 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 > > (
299302 _: impl Ctx ,
300303 #[ implementations(
301304 Table <Raster <CPU >>,
@@ -360,7 +363,7 @@ async fn black_and_white<T: Adjust<Color>>(
360363 // TODO: Fix "Color" blend mode implementation so it matches the expected behavior perfectly (it's currently close)
361364 let color = tint. with_luminance ( luminance) ;
362365
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) ;
364367
365368 color. to_linear_srgb ( )
366369 } ) ;
@@ -371,7 +374,7 @@ async fn black_and_white<T: Adjust<Color>>(
371374// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=%27hue%20%27%20%3D%20Old,saturation%2C%20Photoshop%205.0
372375// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=0%20%3D%20Use%20other.-,Hue/Saturation,-Hue/Saturation%20settings
373376#[ 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 > > (
375378 _: impl Ctx ,
376379 #[ implementations(
377380 Table <Raster <CPU >>,
@@ -406,7 +409,7 @@ async fn hue_saturation<T: Adjust<Color>>(
406409// Aims for interoperable compatibility with:
407410// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=%27%20%3D%20Color%20Lookup-,%27nvrt%27%20%3D%20Invert,-%27post%27%20%3D%20Posterize
408411#[ node_macro:: node( category( "Raster: Adjustment" ) , shader_node( PerPixelAdjust ) ) ]
409- async fn invert < T : Adjust < Color > > (
412+ fn invert < T : Adjust < Color > > (
410413 _: impl Ctx ,
411414 #[ implementations(
412415 Table <Raster <CPU >>,
@@ -429,7 +432,7 @@ async fn invert<T: Adjust<Color>>(
429432// Aims for interoperable compatibility with:
430433// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=post%27%20%3D%20Posterize-,%27thrs%27%20%3D%20Threshold,-%27grdm%27%20%3D%20Gradient
431434#[ node_macro:: node( category( "Raster: Adjustment" ) , shader_node( PerPixelAdjust ) ) ]
432- async fn threshold < T : Adjust < Color > > (
435+ fn threshold < T : Adjust < Color > > (
433436 _: impl Ctx ,
434437 #[ implementations(
435438 Table <Raster <CPU >>,
@@ -475,7 +478,7 @@ async fn threshold<T: Adjust<Color>>(
475478// When both parameters are set, it is equivalent to running this adjustment twice, with only vibrance set and then only saturation set.
476479// (Except for some noise probably due to rounding error.)
477480#[ node_macro:: node( category( "Raster: Adjustment" ) , shader_node( PerPixelAdjust ) ) ]
478- async fn vibrance < T : Adjust < Color > > (
481+ fn vibrance < T : Adjust < Color > > (
479482 _: impl Ctx ,
480483 #[ implementations(
481484 Table <Raster <CPU >>,
@@ -641,7 +644,7 @@ pub enum DomainWarpType {
641644// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=%27mixr%27%20%3D%20Channel%20Mixer
642645// https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=Lab%20color%20only-,Channel%20Mixer,-Key%20is%20%27mixr
643646#[ 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 > > (
645648 _: impl Ctx ,
646649 #[ implementations(
647650 Table <Raster <CPU >>,
@@ -770,7 +773,7 @@ pub enum SelectiveColorChoice {
770773// Algorithm based on:
771774// https://blog.pkh.me/p/22-understanding-selective-coloring-in-adobe-photoshop.html
772775#[ 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 > > (
774777 _: impl Ctx ,
775778 #[ implementations(
776779 Table <Raster <CPU >>,
@@ -913,7 +916,7 @@ async fn selective_color<T: Adjust<Color>>(
913916// https://www.axiomx.com/posterize.htm
914917// This algorithm produces fully accurate output in relation to the industry standard.
915918#[ node_macro:: node( category( "Raster: Adjustment" ) , shader_node( PerPixelAdjust ) ) ]
916- async fn posterize < T : Adjust < Color > > (
919+ fn posterize < T : Adjust < Color > > (
917920 _: impl Ctx ,
918921 #[ implementations(
919922 Table <Raster <CPU >>,
@@ -947,7 +950,7 @@ async fn posterize<T: Adjust<Color>>(
947950// Algorithm based on:
948951// https://geraldbakker.nl/psnumbers/exposure.html
949952#[ 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 > > (
951954 _: impl Ctx ,
952955 #[ implementations(
953956 Table <Raster <CPU >>,
0 commit comments