Skip to content

Commit

Permalink
Rename Space::LAB -> Space::CIELAB && Space::LCH -> Space::CIELCH
Browse files Browse the repository at this point in the history
Also adjusted lch function description to mention it is space agnostic

TL;DR separate lab/cylindrical representations from CIE spaces specifically
  • Loading branch information
Beinsezii committed Jan 30, 2024
1 parent 6e7f22e commit 799743b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 64 deletions.
12 changes: 6 additions & 6 deletions benches/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,27 @@ pub fn conversions(c: &mut Criterion) {
} ));

c.bench_function("full_to", |b| b.iter(|| {
black_box(pixels.clone().chunks_exact_mut(3).for_each(|pixel| convert_space(Space::SRGB, Space::LCH, pixel.try_into().unwrap())));
black_box(pixels.clone().chunks_exact_mut(3).for_each(|pixel| convert_space(Space::SRGB, Space::CIELCH, pixel.try_into().unwrap())));
} ));

c.bench_function("full_from", |b| b.iter(|| {
black_box(pixels.clone().chunks_exact_mut(3).for_each(|pixel| convert_space(Space::LCH, Space::SRGB, pixel.try_into().unwrap())));
black_box(pixels.clone().chunks_exact_mut(3).for_each(|pixel| convert_space(Space::CIELCH, Space::SRGB, pixel.try_into().unwrap())));
} ));

c.bench_function("full_to_chunk", |b| b.iter(|| {
black_box(colcon::convert_space_chunked(Space::LCH, Space::SRGB, pixels.chunks_exact(3).map(|chunk| chunk.try_into().unwrap()).collect::<Vec<[f32; 3]>>().as_mut_slice()));
black_box(colcon::convert_space_chunked(Space::CIELCH, Space::SRGB, pixels.chunks_exact(3).map(|chunk| chunk.try_into().unwrap()).collect::<Vec<[f32; 3]>>().as_mut_slice()));
} ));

c.bench_function("full_from_chunk", |b| b.iter(|| {
black_box(colcon::convert_space_chunked(Space::LCH, Space::SRGB, &mut pixels.chunks_exact(3).map(|chunk| chunk.try_into().unwrap()).collect::<Vec<[f32; 3]>>().as_mut_slice()));
black_box(colcon::convert_space_chunked(Space::CIELCH, Space::SRGB, &mut pixels.chunks_exact(3).map(|chunk| chunk.try_into().unwrap()).collect::<Vec<[f32; 3]>>().as_mut_slice()));
} ));

c.bench_function("full_to_slice", |b| b.iter(|| {
black_box(colcon::convert_space_sliced(Space::LCH, Space::SRGB, &mut pixels.clone()));
black_box(colcon::convert_space_sliced(Space::CIELCH, Space::SRGB, &mut pixels.clone()));
} ));

c.bench_function("full_from_slice", |b| b.iter(|| {
black_box(colcon::convert_space_sliced(Space::LCH, Space::SRGB, &mut pixels.clone()));
black_box(colcon::convert_space_sliced(Space::CIELCH, Space::SRGB, &mut pixels.clone()));
} ));

c.bench_function("single", |b| b.iter(|| {
Expand Down
2 changes: 1 addition & 1 deletion examples/hk_palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {
.map(|row| {
row.map(|pixel| {
let mut pixel = pixel;
convert_space(colcon::Space::LCH, colcon::Space::SRGB, &mut pixel);
convert_space(colcon::Space::CIELCH, colcon::Space::SRGB, &mut pixel);
srgb_to_irgb(pixel)
})
})
Expand Down
2 changes: 1 addition & 1 deletion examples/hk_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
.map(|row| {
row.map(|pixel| {
let mut pixel = pixel;
convert_space(colcon::Space::LCH, colcon::Space::SRGB, &mut pixel);
convert_space(colcon::Space::CIELCH, colcon::Space::SRGB, &mut pixel);
srgb_to_irgb(pixel)
})
})
Expand Down
2 changes: 1 addition & 1 deletion examples/spectrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn write_ppm(pixels: &[[f32; 3]], name: &str) {
fn main() {
for (space, filename) in [
(Space::HSV, "hsv"),
(Space::LCH, "cie_lab"),
(Space::CIELCH, "cie_lab"),
(Space::OKLCH, "oklab"),
(Space::JZCZHZ, "jzazbz"),
] {
Expand Down
Loading

0 comments on commit 799743b

Please sign in to comment.