Ogeon / palette

A Rust library for linear color calculations and conversion
Apache License 2.0
752 stars 60 forks source link

Oklab<f32> sRGB color spaces may be wrong #296

Open NeverGivinUp opened 2 years ago

NeverGivinUp commented 2 years ago

Oklab and Oklch have a formally unlimited gamut and are made to be perceptually linear in the percievable gamut. Okhsv, Okhsl and Okhwb are limited to the sRGB gamut. When converting a color from Oklab/Oklch to one of the sRGB-Ok* colors, the color must be mapped. To do that the maximum saturation of the color's hue is computed. This computation works fine in f64 but not in f32.

How To Reproduce

Run test palette::ok_utils::tests::print_min_max_srgb_chroma_of_all_hues with EPSILON = 1e-6