summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorbonjorno7 <jorijndegraaf@gmail.com>2023-04-25 16:25:50 +0200
committerbonjorno7 <jorijndegraaf@gmail.com>2023-05-09 17:43:10 +0200
commit0b7fd664c1ba372a77f78764b4ff9acfeb1f8052 (patch)
treeae6ee8d8e1ebcff0db8e814b876e41ec061eca0a /tests
parentee865051367a78bf20f50500520af13ef8f1097b (diff)
downloadredot-engine-0b7fd664c1ba372a77f78764b4ff9acfeb1f8052.tar.gz
Add API for HSL conversion
Math ported pretty much 1:1 from https://en.wikipedia.org/wiki/HSL_and_HSV Style doesn't match the existing HSV code exactly, but should be close enough.
Diffstat (limited to 'tests')
-rw-r--r--tests/core/math/test_color.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/core/math/test_color.h b/tests/core/math/test_color.h
index bd2d4f40e5..398c2da175 100644
--- a/tests/core/math/test_color.h
+++ b/tests/core/math/test_color.h
@@ -63,10 +63,14 @@ TEST_CASE("[Color] Constructor methods") {
const Color green_rgba = Color(0, 1, 0, 0.25);
const Color green_hsva = Color(0, 0, 0).from_hsv(120 / 360.0, 1, 1, 0.25);
+ const Color green_hsla = Color(0, 0, 0).from_hsl(120 / 360.0, 1, 0.5, 0.25);
CHECK_MESSAGE(
green_rgba.is_equal_approx(green_hsva),
"Creation with HSV notation should result in components approximately equal to the default constructor.");
+ CHECK_MESSAGE(
+ green_rgba.is_equal_approx(green_hsla),
+ "Creation with HSL notation should result in components approximately equal to the default constructor.");
}
TEST_CASE("[Color] Operators") {
@@ -109,6 +113,16 @@ TEST_CASE("[Color] Reading methods") {
CHECK_MESSAGE(
dark_blue.get_v() == doctest::Approx(0.5f),
"The returned HSV value should match the expected value.");
+
+ CHECK_MESSAGE(
+ dark_blue.get_hsl_h() == doctest::Approx(240.0f / 360.0f),
+ "The returned HSL hue should match the expected value.");
+ CHECK_MESSAGE(
+ dark_blue.get_hsl_s() == doctest::Approx(1.0f),
+ "The returned HSL saturation should match the expected value.");
+ CHECK_MESSAGE(
+ dark_blue.get_hsl_l() == doctest::Approx(0.25f),
+ "The returned HSL lightness should match the expected value.");
}
TEST_CASE("[Color] Conversion methods") {