Increase precision in linear_to_srgb and srgb_to_linear

This avoids the situation where white stops being white after conversion. While maintaining as much floating point ops as possible
This commit is contained in:
clayjohn
2024-12-20 10:49:43 -07:00
parent fafc07335b
commit 46ce499b6f
2 changed files with 12 additions and 6 deletions

View File

@@ -160,6 +160,12 @@ TEST_CASE("[Color] Linear <-> sRGB conversion") {
CHECK_MESSAGE(
color_srgb.srgb_to_linear().is_equal_approx(Color(0.35, 0.5, 0.6, 0.7)),
"The sRGB color converted back to linear color space should match the expected value.");
CHECK_MESSAGE(
Color(1.0, 1.0, 1.0, 1.0).srgb_to_linear() == (Color(1.0, 1.0, 1.0, 1.0)),
"White converted from sRGB to linear should remain white.");
CHECK_MESSAGE(
Color(1.0, 1.0, 1.0, 1.0).linear_to_srgb() == (Color(1.0, 1.0, 1.0, 1.0)),
"White converted from linear to sRGB should remain white.");
}
TEST_CASE("[Color] Named colors") {