@@ -81,11 +81,11 @@ fn gamma_correction<T: Adjust<Color>>(
81
81
#[ default( 2.2 ) ]
82
82
#[ range( ( 0.01 , 10. ) ) ]
83
83
#[ hard_min( 0.0001 ) ]
84
- gamma : f64 ,
84
+ gamma : f32 ,
85
85
inverse : bool ,
86
86
) -> T {
87
87
let exponent = if inverse { 1. / gamma } else { gamma } ;
88
- input. adjust ( |color| color. gamma ( exponent as f32 ) ) ;
88
+ input. adjust ( |color| color. gamma ( exponent) ) ;
89
89
input
90
90
}
91
91
@@ -154,9 +154,9 @@ fn brightness_contrast<T: Adjust<Color>>(
154
154
use_classic : bool ,
155
155
) -> T {
156
156
if use_classic {
157
- let brightness = brightness as f32 / 255. ;
157
+ let brightness = brightness / 255. ;
158
158
159
- let contrast = contrast as f32 / 100. ;
159
+ let contrast = contrast / 100. ;
160
160
let contrast = if contrast > 0. { ( contrast * core:: f32:: consts:: FRAC_PI_2 - 0.01 ) . tan ( ) } else { contrast } ;
161
161
162
162
let offset = brightness * contrast + brightness - contrast / 2. ;
@@ -173,7 +173,7 @@ fn brightness_contrast<T: Adjust<Color>>(
173
173
// We clamp the brightness before the two curve X-axis points `130 - brightness * 26` and `233 - brightness * 48` intersect.
174
174
// Beyond the point of intersection, the cubic spline fitting becomes invalid and fails an assertion, which we need to avoid.
175
175
// See the intersection of the red lines at x = 103/22*100 = 468.18182 in the graph: https://www.desmos.com/calculator/ekvz4zyd9c
176
- let brightness = ( brightness. abs ( ) / 100. ) . min ( 103. / 22. - 0.00001 ) as f32 ;
176
+ let brightness = ( brightness. abs ( ) / 100. ) . min ( 103. / 22. - 0.00001 ) ;
177
177
let brightness_curve_points = CubicSplines {
178
178
x : [ 0. , 130. - brightness * 26. , 233. - brightness * 48. , 255. ] . map ( |x| x / 255. ) ,
179
179
y : [ 0. , 130. + brightness * 51. , 233. + brightness * 10. , 255. ] . map ( |x| x / 255. ) ,
@@ -198,7 +198,7 @@ fn brightness_contrast<T: Adjust<Color>>(
198
198
// Unlike with brightness, the X-axis points `64` and `192` don't intersect at any contrast value, because they are constants.
199
199
// So we don't have to worry about clamping the contrast value to avoid invalid cubic spline fitting.
200
200
// See the graph: https://www.desmos.com/calculator/iql9vsca56
201
- let contrast = contrast as f32 / 100. ;
201
+ let contrast = contrast / 100. ;
202
202
let contrast_curve_points = CubicSplines {
203
203
x : [ 0. , 64. , 192. , 255. ] . map ( |x| x / 255. ) ,
204
204
y : [ 0. , 64. - contrast * 30. , 192. + contrast * 30. , 255. ] . map ( |x| x / 255. ) ,
@@ -249,13 +249,13 @@ fn levels<T: Adjust<Color>>(
249
249
let color = color. to_gamma_srgb ( ) ;
250
250
251
251
// Input Range (Range: 0-1)
252
- let input_shadows = ( shadows / 100. ) as f32 ;
253
- let input_midtones = ( midtones / 100. ) as f32 ;
254
- let input_highlights = ( highlights / 100. ) as f32 ;
252
+ let input_shadows = shadows / 100. ;
253
+ let input_midtones = midtones / 100. ;
254
+ let input_highlights = highlights / 100. ;
255
255
256
256
// Output Range (Range: 0-1)
257
- let output_minimums = ( output_minimums / 100. ) as f32 ;
258
- let output_maximums = ( output_maximums / 100. ) as f32 ;
257
+ let output_minimums = output_minimums / 100. ;
258
+ let output_maximums = output_maximums / 100. ;
259
259
260
260
// Midtones interpolation factor between minimums and maximums (Range: 0-1)
261
261
let midtones = output_minimums + ( output_maximums - output_minimums) * input_midtones;
@@ -333,12 +333,12 @@ fn black_and_white<T: Adjust<Color>>(
333
333
image. adjust ( |color| {
334
334
let color = color. to_gamma_srgb ( ) ;
335
335
336
- let reds = reds as f32 / 100. ;
337
- let yellows = yellows as f32 / 100. ;
338
- let greens = greens as f32 / 100. ;
339
- let cyans = cyans as f32 / 100. ;
340
- let blues = blues as f32 / 100. ;
341
- let magentas = magentas as f32 / 100. ;
336
+ let reds = reds / 100. ;
337
+ let yellows = yellows / 100. ;
338
+ let greens = greens / 100. ;
339
+ let cyans = cyans / 100. ;
340
+ let blues = blues / 100. ;
341
+ let magentas = magentas / 100. ;
342
342
343
343
let gray_base = color. r ( ) . min ( color. g ( ) ) . min ( color. b ( ) ) ;
344
344
@@ -393,11 +393,11 @@ fn hue_saturation<T: Adjust<Color>>(
393
393
let [ hue, saturation, lightness, alpha] = color. to_hsla ( ) ;
394
394
395
395
let color = Color :: from_hsla (
396
- ( hue + hue_shift as f32 / 360. ) % 1. ,
396
+ ( hue + hue_shift / 360. ) % 1. ,
397
397
// TODO: Improve the way saturation works (it's slightly off)
398
- ( saturation + saturation_shift as f32 / 100. ) . clamp ( 0. , 1. ) ,
398
+ ( saturation + saturation_shift / 100. ) . clamp ( 0. , 1. ) ,
399
399
// TODO: Fix the way lightness works (it's very off)
400
- ( lightness + lightness_shift as f32 / 100. ) . clamp ( 0. , 1. ) ,
400
+ ( lightness + lightness_shift / 100. ) . clamp ( 0. , 1. ) ,
401
401
alpha,
402
402
) ;
403
403
@@ -446,8 +446,8 @@ fn threshold<T: Adjust<Color>>(
446
446
luminance_calc : LuminanceCalculation ,
447
447
) -> T {
448
448
image. adjust ( |color| {
449
- let min_luminance = Color :: srgb_to_linear ( min_luminance as f32 / 100. ) ;
450
- let max_luminance = Color :: srgb_to_linear ( max_luminance as f32 / 100. ) ;
449
+ let min_luminance = Color :: srgb_to_linear ( min_luminance / 100. ) ;
450
+ let max_luminance = Color :: srgb_to_linear ( max_luminance / 100. ) ;
451
451
452
452
let luminance = match luminance_calc {
453
453
LuminanceCalculation :: SRGB => color. luminance_srgb ( ) ,
@@ -490,7 +490,7 @@ fn vibrance<T: Adjust<Color>>(
490
490
vibrance : SignedPercentageF32 ,
491
491
) -> T {
492
492
image. adjust ( |color| {
493
- let vibrance = vibrance as f32 / 100. ;
493
+ let vibrance = vibrance / 100. ;
494
494
// Slow the effect down by half when it's negative, since artifacts begin appearing past -50%.
495
495
// So this scales the 0% to -50% range to 0% to -100%.
496
496
let slowed_vibrance = if vibrance >= 0. { vibrance } else { vibrance * 0.5 } ;
@@ -658,55 +658,55 @@ fn channel_mixer<T: Adjust<Color>>(
658
658
659
659
#[ default( 40. ) ]
660
660
#[ name( "Red" ) ]
661
- monochrome_r : f64 ,
661
+ monochrome_r : f32 ,
662
662
#[ default( 40. ) ]
663
663
#[ name( "Green" ) ]
664
- monochrome_g : f64 ,
664
+ monochrome_g : f32 ,
665
665
#[ default( 20. ) ]
666
666
#[ name( "Blue" ) ]
667
- monochrome_b : f64 ,
667
+ monochrome_b : f32 ,
668
668
#[ default( 0. ) ]
669
669
#[ name( "Constant" ) ]
670
- monochrome_c : f64 ,
670
+ monochrome_c : f32 ,
671
671
672
672
#[ default( 100. ) ]
673
673
#[ name( "(Red) Red" ) ]
674
- red_r : f64 ,
674
+ red_r : f32 ,
675
675
#[ default( 0. ) ]
676
676
#[ name( "(Red) Green" ) ]
677
- red_g : f64 ,
677
+ red_g : f32 ,
678
678
#[ default( 0. ) ]
679
679
#[ name( "(Red) Blue" ) ]
680
- red_b : f64 ,
680
+ red_b : f32 ,
681
681
#[ default( 0. ) ]
682
682
#[ name( "(Red) Constant" ) ]
683
- red_c : f64 ,
683
+ red_c : f32 ,
684
684
685
685
#[ default( 0. ) ]
686
686
#[ name( "(Green) Red" ) ]
687
- green_r : f64 ,
687
+ green_r : f32 ,
688
688
#[ default( 100. ) ]
689
689
#[ name( "(Green) Green" ) ]
690
- green_g : f64 ,
690
+ green_g : f32 ,
691
691
#[ default( 0. ) ]
692
692
#[ name( "(Green) Blue" ) ]
693
- green_b : f64 ,
693
+ green_b : f32 ,
694
694
#[ default( 0. ) ]
695
695
#[ name( "(Green) Constant" ) ]
696
- green_c : f64 ,
696
+ green_c : f32 ,
697
697
698
698
#[ default( 0. ) ]
699
699
#[ name( "(Blue) Red" ) ]
700
- blue_r : f64 ,
700
+ blue_r : f32 ,
701
701
#[ default( 0. ) ]
702
702
#[ name( "(Blue) Green" ) ]
703
- blue_g : f64 ,
703
+ blue_g : f32 ,
704
704
#[ default( 100. ) ]
705
705
#[ name( "(Blue) Blue" ) ]
706
- blue_b : f64 ,
706
+ blue_b : f32 ,
707
707
#[ default( 0. ) ]
708
708
#[ name( "(Blue) Constant" ) ]
709
- blue_c : f64 ,
709
+ blue_c : f32 ,
710
710
711
711
// Display-only properties (not used within the node)
712
712
_output_channel : RedGreenBlue ,
@@ -717,15 +717,15 @@ fn channel_mixer<T: Adjust<Color>>(
717
717
let ( r, g, b, a) = color. components ( ) ;
718
718
719
719
let color = if monochrome {
720
- let ( monochrome_r, monochrome_g, monochrome_b, monochrome_c) = ( monochrome_r as f32 / 100. , monochrome_g as f32 / 100. , monochrome_b as f32 / 100. , monochrome_c as f32 / 100. ) ;
720
+ let ( monochrome_r, monochrome_g, monochrome_b, monochrome_c) = ( monochrome_r / 100. , monochrome_g / 100. , monochrome_b / 100. , monochrome_c / 100. ) ;
721
721
722
722
let gray = ( r * monochrome_r + g * monochrome_g + b * monochrome_b + monochrome_c) . clamp ( 0. , 1. ) ;
723
723
724
724
Color :: from_rgbaf32_unchecked ( gray, gray, gray, a)
725
725
} else {
726
- let ( red_r, red_g, red_b, red_c) = ( red_r as f32 / 100. , red_g as f32 / 100. , red_b as f32 / 100. , red_c as f32 / 100. ) ;
727
- let ( green_r, green_g, green_b, green_c) = ( green_r as f32 / 100. , green_g as f32 / 100. , green_b as f32 / 100. , green_c as f32 / 100. ) ;
728
- let ( blue_r, blue_g, blue_b, blue_c) = ( blue_r as f32 / 100. , blue_g as f32 / 100. , blue_b as f32 / 100. , blue_c as f32 / 100. ) ;
726
+ let ( red_r, red_g, red_b, red_c) = ( red_r / 100. , red_g / 100. , red_b / 100. , red_c / 100. ) ;
727
+ let ( green_r, green_g, green_b, green_c) = ( green_r / 100. , green_g / 100. , green_b / 100. , green_c / 100. ) ;
728
+ let ( blue_r, blue_g, blue_b, blue_c) = ( blue_r / 100. , blue_g / 100. , blue_b / 100. , blue_c / 100. ) ;
729
729
730
730
let red = ( r * red_r + g * red_g + b * red_b + red_c) . clamp ( 0. , 1. ) ;
731
731
let green = ( r * green_r + g * green_g + b * green_b + green_c) . clamp ( 0. , 1. ) ;
@@ -785,50 +785,50 @@ fn selective_color<T: Adjust<Color>>(
785
785
786
786
mode : RelativeAbsolute ,
787
787
788
- #[ name( "(Reds) Cyan" ) ] r_c : f64 ,
789
- #[ name( "(Reds) Magenta" ) ] r_m : f64 ,
790
- #[ name( "(Reds) Yellow" ) ] r_y : f64 ,
791
- #[ name( "(Reds) Black" ) ] r_k : f64 ,
792
-
793
- #[ name( "(Yellows) Cyan" ) ] y_c : f64 ,
794
- #[ name( "(Yellows) Magenta" ) ] y_m : f64 ,
795
- #[ name( "(Yellows) Yellow" ) ] y_y : f64 ,
796
- #[ name( "(Yellows) Black" ) ] y_k : f64 ,
797
-
798
- #[ name( "(Greens) Cyan" ) ] g_c : f64 ,
799
- #[ name( "(Greens) Magenta" ) ] g_m : f64 ,
800
- #[ name( "(Greens) Yellow" ) ] g_y : f64 ,
801
- #[ name( "(Greens) Black" ) ] g_k : f64 ,
802
-
803
- #[ name( "(Cyans) Cyan" ) ] c_c : f64 ,
804
- #[ name( "(Cyans) Magenta" ) ] c_m : f64 ,
805
- #[ name( "(Cyans) Yellow" ) ] c_y : f64 ,
806
- #[ name( "(Cyans) Black" ) ] c_k : f64 ,
807
-
808
- #[ name( "(Blues) Cyan" ) ] b_c : f64 ,
809
- #[ name( "(Blues) Magenta" ) ] b_m : f64 ,
810
- #[ name( "(Blues) Yellow" ) ] b_y : f64 ,
811
- #[ name( "(Blues) Black" ) ] b_k : f64 ,
812
-
813
- #[ name( "(Magentas) Cyan" ) ] m_c : f64 ,
814
- #[ name( "(Magentas) Magenta" ) ] m_m : f64 ,
815
- #[ name( "(Magentas) Yellow" ) ] m_y : f64 ,
816
- #[ name( "(Magentas) Black" ) ] m_k : f64 ,
817
-
818
- #[ name( "(Whites) Cyan" ) ] w_c : f64 ,
819
- #[ name( "(Whites) Magenta" ) ] w_m : f64 ,
820
- #[ name( "(Whites) Yellow" ) ] w_y : f64 ,
821
- #[ name( "(Whites) Black" ) ] w_k : f64 ,
822
-
823
- #[ name( "(Neutrals) Cyan" ) ] n_c : f64 ,
824
- #[ name( "(Neutrals) Magenta" ) ] n_m : f64 ,
825
- #[ name( "(Neutrals) Yellow" ) ] n_y : f64 ,
826
- #[ name( "(Neutrals) Black" ) ] n_k : f64 ,
827
-
828
- #[ name( "(Blacks) Cyan" ) ] k_c : f64 ,
829
- #[ name( "(Blacks) Magenta" ) ] k_m : f64 ,
830
- #[ name( "(Blacks) Yellow" ) ] k_y : f64 ,
831
- #[ name( "(Blacks) Black" ) ] k_k : f64 ,
788
+ #[ name( "(Reds) Cyan" ) ] r_c : f32 ,
789
+ #[ name( "(Reds) Magenta" ) ] r_m : f32 ,
790
+ #[ name( "(Reds) Yellow" ) ] r_y : f32 ,
791
+ #[ name( "(Reds) Black" ) ] r_k : f32 ,
792
+
793
+ #[ name( "(Yellows) Cyan" ) ] y_c : f32 ,
794
+ #[ name( "(Yellows) Magenta" ) ] y_m : f32 ,
795
+ #[ name( "(Yellows) Yellow" ) ] y_y : f32 ,
796
+ #[ name( "(Yellows) Black" ) ] y_k : f32 ,
797
+
798
+ #[ name( "(Greens) Cyan" ) ] g_c : f32 ,
799
+ #[ name( "(Greens) Magenta" ) ] g_m : f32 ,
800
+ #[ name( "(Greens) Yellow" ) ] g_y : f32 ,
801
+ #[ name( "(Greens) Black" ) ] g_k : f32 ,
802
+
803
+ #[ name( "(Cyans) Cyan" ) ] c_c : f32 ,
804
+ #[ name( "(Cyans) Magenta" ) ] c_m : f32 ,
805
+ #[ name( "(Cyans) Yellow" ) ] c_y : f32 ,
806
+ #[ name( "(Cyans) Black" ) ] c_k : f32 ,
807
+
808
+ #[ name( "(Blues) Cyan" ) ] b_c : f32 ,
809
+ #[ name( "(Blues) Magenta" ) ] b_m : f32 ,
810
+ #[ name( "(Blues) Yellow" ) ] b_y : f32 ,
811
+ #[ name( "(Blues) Black" ) ] b_k : f32 ,
812
+
813
+ #[ name( "(Magentas) Cyan" ) ] m_c : f32 ,
814
+ #[ name( "(Magentas) Magenta" ) ] m_m : f32 ,
815
+ #[ name( "(Magentas) Yellow" ) ] m_y : f32 ,
816
+ #[ name( "(Magentas) Black" ) ] m_k : f32 ,
817
+
818
+ #[ name( "(Whites) Cyan" ) ] w_c : f32 ,
819
+ #[ name( "(Whites) Magenta" ) ] w_m : f32 ,
820
+ #[ name( "(Whites) Yellow" ) ] w_y : f32 ,
821
+ #[ name( "(Whites) Black" ) ] w_k : f32 ,
822
+
823
+ #[ name( "(Neutrals) Cyan" ) ] n_c : f32 ,
824
+ #[ name( "(Neutrals) Magenta" ) ] n_m : f32 ,
825
+ #[ name( "(Neutrals) Yellow" ) ] n_y : f32 ,
826
+ #[ name( "(Neutrals) Black" ) ] n_k : f32 ,
827
+
828
+ #[ name( "(Blacks) Cyan" ) ] k_c : f32 ,
829
+ #[ name( "(Blacks) Magenta" ) ] k_m : f32 ,
830
+ #[ name( "(Blacks) Yellow" ) ] k_y : f32 ,
831
+ #[ name( "(Blacks) Black" ) ] k_k : f32 ,
832
832
833
833
_colors : SelectiveColorChoice ,
834
834
) -> T {
@@ -866,15 +866,15 @@ fn selective_color<T: Adjust<Color>>(
866
866
} ;
867
867
868
868
let ( sum_r, sum_g, sum_b) = [
869
- ( SelectiveColorChoice :: Reds , ( r_c as f32 , r_m as f32 , r_y as f32 , r_k as f32 ) ) ,
870
- ( SelectiveColorChoice :: Yellows , ( y_c as f32 , y_m as f32 , y_y as f32 , y_k as f32 ) ) ,
871
- ( SelectiveColorChoice :: Greens , ( g_c as f32 , g_m as f32 , g_y as f32 , g_k as f32 ) ) ,
872
- ( SelectiveColorChoice :: Cyans , ( c_c as f32 , c_m as f32 , c_y as f32 , c_k as f32 ) ) ,
873
- ( SelectiveColorChoice :: Blues , ( b_c as f32 , b_m as f32 , b_y as f32 , b_k as f32 ) ) ,
874
- ( SelectiveColorChoice :: Magentas , ( m_c as f32 , m_m as f32 , m_y as f32 , m_k as f32 ) ) ,
875
- ( SelectiveColorChoice :: Whites , ( w_c as f32 , w_m as f32 , w_y as f32 , w_k as f32 ) ) ,
876
- ( SelectiveColorChoice :: Neutrals , ( n_c as f32 , n_m as f32 , n_y as f32 , n_k as f32 ) ) ,
877
- ( SelectiveColorChoice :: Blacks , ( k_c as f32 , k_m as f32 , k_y as f32 , k_k as f32 ) ) ,
869
+ ( SelectiveColorChoice :: Reds , ( r_c, r_m, r_y, r_k) ) ,
870
+ ( SelectiveColorChoice :: Yellows , ( y_c, y_m, y_y, y_k) ) ,
871
+ ( SelectiveColorChoice :: Greens , ( g_c, g_m, g_y, g_k) ) ,
872
+ ( SelectiveColorChoice :: Cyans , ( c_c, c_m, c_y, c_k) ) ,
873
+ ( SelectiveColorChoice :: Blues , ( b_c, b_m, b_y, b_k) ) ,
874
+ ( SelectiveColorChoice :: Magentas , ( m_c, m_m, m_y, m_k) ) ,
875
+ ( SelectiveColorChoice :: Whites , ( w_c, w_m, w_y, w_k) ) ,
876
+ ( SelectiveColorChoice :: Neutrals , ( n_c, n_m, n_y, n_k) ) ,
877
+ ( SelectiveColorChoice :: Blacks , ( k_c, k_m, k_y, k_k) ) ,
878
878
]
879
879
. into_iter ( )
880
880
. fold ( ( 0. , 0. , 0. ) , |acc, ( color_parameter_group, ( c, m, y, k) ) | {
@@ -968,12 +968,12 @@ fn exposure<T: Adjust<Color>>(
968
968
) -> T {
969
969
input. adjust ( |color| {
970
970
let adjusted = color
971
- // Exposure
972
- . map_rgb ( |c : f32 | c * 2_f32 . powf ( exposure) )
973
- // Offset
974
- . map_rgb ( |c : f32 | c + offset)
975
- // Gamma correction
976
- . gamma ( gamma_correction) ;
971
+ // Exposure
972
+ . map_rgb ( |c : f32 | c * 2_f32 . powf ( exposure) )
973
+ // Offset
974
+ . map_rgb ( |c : f32 | c + offset)
975
+ // Gamma correction
976
+ . gamma ( gamma_correction) ;
977
977
978
978
adjusted. map_rgb ( |c : f32 | c. clamp ( 0. , 1. ) )
979
979
} ) ;
0 commit comments