File tree 1 file changed +11
-9
lines changed
1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -1074,16 +1074,18 @@ where
1074
1074
} else {
1075
1075
let s = dmax / vmax;
1076
1076
1077
- let dr = ( ( ( vmax - pixel[ 0 ] ) / 6.0 . to_dt ( ) ) + ( dmax / 2.0 . to_dt ( ) ) ) / dmax;
1078
- let dg = ( ( ( vmax - pixel[ 1 ] ) / 6.0 . to_dt ( ) ) + ( dmax / 2.0 . to_dt ( ) ) ) / dmax;
1079
- let db = ( ( ( vmax - pixel[ 2 ] ) / 6.0 . to_dt ( ) ) + ( dmax / 2.0 . to_dt ( ) ) ) / dmax;
1080
-
1081
- let h = if pixel[ 0 ] == vmax {
1082
- db - dg
1083
- } else if pixel[ 1 ] == vmax {
1084
- T :: ff32 ( 1.0 / 3.0 ) + dr - db
1077
+ let [ branch_0, branch_1] = [ pixel[ 0 ] == vmax, pixel[ 1 ] == vmax] ;
1078
+
1079
+ pixel. iter_mut ( ) . take ( 3 ) . for_each ( |c| {
1080
+ * c = ( ( ( vmax - * c) / 6.0 . to_dt ( ) ) + ( dmax / 2.0 . to_dt ( ) ) ) / dmax;
1081
+ } ) ;
1082
+
1083
+ let h = if branch_0 {
1084
+ pixel[ 2 ] - pixel[ 1 ]
1085
+ } else if branch_1 {
1086
+ T :: ff32 ( 1.0 / 3.0 ) + pixel[ 0 ] - pixel[ 2 ]
1085
1087
} else {
1086
- T :: ff32 ( 2.0 / 3.0 ) + dg - dr
1088
+ T :: ff32 ( 2.0 / 3.0 ) + pixel [ 1 ] - pixel [ 0 ]
1087
1089
}
1088
1090
. rem_euclid ( 1.0 . to_dt ( ) ) ;
1089
1091
( h, s)
You can’t perform that action at this time.
0 commit comments