@@ -81,11 +81,11 @@ fn gamma_correction<T: Adjust<Color>>(
8181 #[ default( 2.2 ) ]
8282 #[ range( ( 0.01 , 10. ) ) ]
8383 #[ hard_min( 0.0001 ) ]
84- gamma : f64 ,
84+ gamma : f32 ,
8585 inverse : bool ,
8686) -> T {
8787 let exponent = if inverse { 1. / gamma } else { gamma } ;
88- input. adjust ( |color| color. gamma ( exponent as f32 ) ) ;
88+ input. adjust ( |color| color. gamma ( exponent) ) ;
8989 input
9090}
9191
@@ -154,9 +154,9 @@ fn brightness_contrast<T: Adjust<Color>>(
154154 use_classic : bool ,
155155) -> T {
156156 if use_classic {
157- let brightness = brightness as f32 / 255. ;
157+ let brightness = brightness / 255. ;
158158
159- let contrast = contrast as f32 / 100. ;
159+ let contrast = contrast / 100. ;
160160 let contrast = if contrast > 0. { ( contrast * core:: f32:: consts:: FRAC_PI_2 - 0.01 ) . tan ( ) } else { contrast } ;
161161
162162 let offset = brightness * contrast + brightness - contrast / 2. ;
@@ -173,7 +173,7 @@ fn brightness_contrast<T: Adjust<Color>>(
173173 // We clamp the brightness before the two curve X-axis points `130 - brightness * 26` and `233 - brightness * 48` intersect.
174174 // Beyond the point of intersection, the cubic spline fitting becomes invalid and fails an assertion, which we need to avoid.
175175 // 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 ) ;
177177 let brightness_curve_points = CubicSplines {
178178 x : [ 0. , 130. - brightness * 26. , 233. - brightness * 48. , 255. ] . map ( |x| x / 255. ) ,
179179 y : [ 0. , 130. + brightness * 51. , 233. + brightness * 10. , 255. ] . map ( |x| x / 255. ) ,
@@ -198,7 +198,7 @@ fn brightness_contrast<T: Adjust<Color>>(
198198 // Unlike with brightness, the X-axis points `64` and `192` don't intersect at any contrast value, because they are constants.
199199 // So we don't have to worry about clamping the contrast value to avoid invalid cubic spline fitting.
200200 // See the graph: https://www.desmos.com/calculator/iql9vsca56
201- let contrast = contrast as f32 / 100. ;
201+ let contrast = contrast / 100. ;
202202 let contrast_curve_points = CubicSplines {
203203 x : [ 0. , 64. , 192. , 255. ] . map ( |x| x / 255. ) ,
204204 y : [ 0. , 64. - contrast * 30. , 192. + contrast * 30. , 255. ] . map ( |x| x / 255. ) ,
@@ -249,13 +249,13 @@ fn levels<T: Adjust<Color>>(
249249 let color = color. to_gamma_srgb ( ) ;
250250
251251 // 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. ;
255255
256256 // 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. ;
259259
260260 // Midtones interpolation factor between minimums and maximums (Range: 0-1)
261261 let midtones = output_minimums + ( output_maximums - output_minimums) * input_midtones;
@@ -333,12 +333,12 @@ fn black_and_white<T: Adjust<Color>>(
333333 image. adjust ( |color| {
334334 let color = color. to_gamma_srgb ( ) ;
335335
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. ;
342342
343343 let gray_base = color. r ( ) . min ( color. g ( ) ) . min ( color. b ( ) ) ;
344344
@@ -393,11 +393,11 @@ fn hue_saturation<T: Adjust<Color>>(
393393 let [ hue, saturation, lightness, alpha] = color. to_hsla ( ) ;
394394
395395 let color = Color :: from_hsla (
396- ( hue + hue_shift as f32 / 360. ) % 1. ,
396+ ( hue + hue_shift / 360. ) % 1. ,
397397 // 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. ) ,
399399 // 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. ) ,
401401 alpha,
402402 ) ;
403403
@@ -446,8 +446,8 @@ fn threshold<T: Adjust<Color>>(
446446 luminance_calc : LuminanceCalculation ,
447447) -> T {
448448 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. ) ;
451451
452452 let luminance = match luminance_calc {
453453 LuminanceCalculation :: SRGB => color. luminance_srgb ( ) ,
@@ -490,7 +490,7 @@ fn vibrance<T: Adjust<Color>>(
490490 vibrance : SignedPercentageF32 ,
491491) -> T {
492492 image. adjust ( |color| {
493- let vibrance = vibrance as f32 / 100. ;
493+ let vibrance = vibrance / 100. ;
494494 // Slow the effect down by half when it's negative, since artifacts begin appearing past -50%.
495495 // So this scales the 0% to -50% range to 0% to -100%.
496496 let slowed_vibrance = if vibrance >= 0. { vibrance } else { vibrance * 0.5 } ;
@@ -658,55 +658,55 @@ fn channel_mixer<T: Adjust<Color>>(
658658
659659 #[ default( 40. ) ]
660660 #[ name( "Red" ) ]
661- monochrome_r : f64 ,
661+ monochrome_r : f32 ,
662662 #[ default( 40. ) ]
663663 #[ name( "Green" ) ]
664- monochrome_g : f64 ,
664+ monochrome_g : f32 ,
665665 #[ default( 20. ) ]
666666 #[ name( "Blue" ) ]
667- monochrome_b : f64 ,
667+ monochrome_b : f32 ,
668668 #[ default( 0. ) ]
669669 #[ name( "Constant" ) ]
670- monochrome_c : f64 ,
670+ monochrome_c : f32 ,
671671
672672 #[ default( 100. ) ]
673673 #[ name( "(Red) Red" ) ]
674- red_r : f64 ,
674+ red_r : f32 ,
675675 #[ default( 0. ) ]
676676 #[ name( "(Red) Green" ) ]
677- red_g : f64 ,
677+ red_g : f32 ,
678678 #[ default( 0. ) ]
679679 #[ name( "(Red) Blue" ) ]
680- red_b : f64 ,
680+ red_b : f32 ,
681681 #[ default( 0. ) ]
682682 #[ name( "(Red) Constant" ) ]
683- red_c : f64 ,
683+ red_c : f32 ,
684684
685685 #[ default( 0. ) ]
686686 #[ name( "(Green) Red" ) ]
687- green_r : f64 ,
687+ green_r : f32 ,
688688 #[ default( 100. ) ]
689689 #[ name( "(Green) Green" ) ]
690- green_g : f64 ,
690+ green_g : f32 ,
691691 #[ default( 0. ) ]
692692 #[ name( "(Green) Blue" ) ]
693- green_b : f64 ,
693+ green_b : f32 ,
694694 #[ default( 0. ) ]
695695 #[ name( "(Green) Constant" ) ]
696- green_c : f64 ,
696+ green_c : f32 ,
697697
698698 #[ default( 0. ) ]
699699 #[ name( "(Blue) Red" ) ]
700- blue_r : f64 ,
700+ blue_r : f32 ,
701701 #[ default( 0. ) ]
702702 #[ name( "(Blue) Green" ) ]
703- blue_g : f64 ,
703+ blue_g : f32 ,
704704 #[ default( 100. ) ]
705705 #[ name( "(Blue) Blue" ) ]
706- blue_b : f64 ,
706+ blue_b : f32 ,
707707 #[ default( 0. ) ]
708708 #[ name( "(Blue) Constant" ) ]
709- blue_c : f64 ,
709+ blue_c : f32 ,
710710
711711 // Display-only properties (not used within the node)
712712 _output_channel : RedGreenBlue ,
@@ -717,15 +717,15 @@ fn channel_mixer<T: Adjust<Color>>(
717717 let ( r, g, b, a) = color. components ( ) ;
718718
719719 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. ) ;
721721
722722 let gray = ( r * monochrome_r + g * monochrome_g + b * monochrome_b + monochrome_c) . clamp ( 0. , 1. ) ;
723723
724724 Color :: from_rgbaf32_unchecked ( gray, gray, gray, a)
725725 } 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. ) ;
729729
730730 let red = ( r * red_r + g * red_g + b * red_b + red_c) . clamp ( 0. , 1. ) ;
731731 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>>(
785785
786786 mode : RelativeAbsolute ,
787787
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 ,
832832
833833 _colors : SelectiveColorChoice ,
834834) -> T {
@@ -866,15 +866,15 @@ fn selective_color<T: Adjust<Color>>(
866866 } ;
867867
868868 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) ) ,
878878 ]
879879 . into_iter ( )
880880 . fold ( ( 0. , 0. , 0. ) , |acc, ( color_parameter_group, ( c, m, y, k) ) | {
@@ -968,12 +968,12 @@ fn exposure<T: Adjust<Color>>(
968968) -> T {
969969 input. adjust ( |color| {
970970 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) ;
977977
978978 adjusted. map_rgb ( |c : f32 | c. clamp ( 0. , 1. ) )
979979 } ) ;
0 commit comments