Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxVerevkin committed Sep 12, 2022
1 parent 983b152 commit dcca9aa
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,10 @@ pub fn colorramp_fill(r: &mut [u16], g: &mut [u16], b: &mut [u16], ramp_size: us
let step = v_max / (ramp_size - 1) as f64;
for i in 0..ramp_size {
let v = step * i as f64;
if !color.inverted {
r[i] = map_intensity(v, white_r, color, v_max_gamma);
g[i] = map_intensity(v, white_g, color, v_max_gamma);
b[i] = map_intensity(v, white_b, color, v_max_gamma);
} else {
r[ramp_size - 1 - i] = map_intensity(v, white_r, color, v_max_gamma);
g[ramp_size - 1 - i] = map_intensity(v, white_g, color, v_max_gamma);
b[ramp_size - 1 - i] = map_intensity(v, white_b, color, v_max_gamma);
}
let index = if color.inverted { ramp_size - 1 - i } else { i };
r[index] = map_intensity(v, white_r, color, v_max_gamma);
g[index] = map_intensity(v, white_g, color, v_max_gamma);
b[index] = map_intensity(v, white_b, color, v_max_gamma);
}
}

Expand Down

0 comments on commit dcca9aa

Please sign in to comment.