Skip to content

Commit

Permalink
Update spectrum example with new quantile
Browse files Browse the repository at this point in the history
  • Loading branch information
Beinsezii committed Jun 28, 2024
1 parent 7e4c78f commit f6adbe3
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions examples/spectrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,20 @@ fn main() {
(Space::OKLCH, "oklab"),
(Space::JZCZHZ, "jzazbz"),
] {
const LQ: usize = 65;
let mut data: Vec<[f32; 3]> = (0..HEIGHT)
.map(|h| {
(0..WIDTH)
.map(|w| {
[
match space {
Space::OKLCH => 0.70,
Space::JZCZHZ => 0.50,
_ => 0.65,
},
1.0 - h as f32 / 100.0,
w as f32,
]
})
.map(|w| [space.srgb_quants()[LQ][0], 1.0 - h as f32 / 100.0, w as f32])
.collect::<Vec<[f32; 3]>>()
})
.flatten()
.collect();

data.iter_mut().for_each(|p| {
if space == Space::HSV {
*p = [p[2] / 360.0, p[1], p[0]]
*p = [p[2] / 360.0, p[1], space.srgb_quants()[LQ][2]]
} else {
p[0] *= space.srgb_quants()[95][0];
p[1] *= space.srgb_quants()[100][1];
}
});
Expand Down

0 comments on commit f6adbe3

Please sign in to comment.