diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-05-12 10:03:21 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-05-12 10:03:21 +0200 |
| commit | 863bcd3e2bb5bdd6857258a42818dfd9232570aa (patch) | |
| tree | b498c0725ee2879341f3f1573444cb6d64c2386f /core | |
| parent | 08d939449457d7f6216db618e6d490879e0a7163 (diff) | |
| parent | f83a90192f05454f8908e882df19958f8349cfd2 (diff) | |
| download | redot-engine-863bcd3e2bb5bdd6857258a42818dfd9232570aa.tar.gz | |
Merge pull request #76936 from clayjohn/revert-hsl
Revert "Add API for HSL conversion"
Diffstat (limited to 'core')
| -rw-r--r-- | core/math/color.cpp | 85 | ||||
| -rw-r--r-- | core/math/color.h | 8 | ||||
| -rw-r--r-- | core/variant/variant_call.cpp | 1 | ||||
| -rw-r--r-- | core/variant/variant_setget.cpp | 4 | ||||
| -rw-r--r-- | core/variant/variant_setget.h | 4 |
5 files changed, 0 insertions, 102 deletions
diff --git a/core/math/color.cpp b/core/math/color.cpp index f4b8903157..0d9325f236 100644 --- a/core/math/color.cpp +++ b/core/math/color.cpp @@ -188,32 +188,6 @@ float Color::get_v() const { return max; } -float Color::get_hsl_h() const { - return get_h(); -} - -float Color::get_hsl_s() const { - float min = MIN(MIN(r, g), b); - float max = MAX(MAX(r, g), b); - - float mid = (min + max) / 2.0f; - - if (mid == 0.0f || mid == 1.0f) { - return 0.0f; - } - - float delta = max - min; - - return delta / (1.0f - Math::abs(2.0f * mid - 1.0f)); -} - -float Color::get_hsl_l() const { - float min = MIN(MIN(r, g), b); - float max = MAX(MAX(r, g), b); - - return (min + max) / 2.0f; -} - void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) { int i; float f, p, q, t; @@ -268,59 +242,6 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) { } } -void Color::set_hsl(float p_h, float p_s, float p_l, float p_alpha) { - a = p_alpha; - - if (p_s == 0.0f) { - // Achromatic (gray) - r = g = b = p_l; - return; - } - - p_h *= 6.0f; - p_h = Math::fmod(p_h, 6.0f); - - float c = (1.0f - Math::abs(2.0f * p_l - 1.0f)) * p_s; - float x = c * (1.0f - Math::abs(Math::fmod(p_h, 2.0f) - 1.0f)); - float m = p_l - c / 2.0f; - - c += m; - x += m; - - switch ((int)p_h) { - case 0: // Red is the dominant color - r = c; - g = x; - b = m; - break; - case 1: // Green is the dominant color - r = x; - g = c; - b = m; - break; - case 2: - r = m; - g = c; - b = x; - break; - case 3: // Blue is the dominant color - r = m; - g = x; - b = c; - break; - case 4: - r = x; - g = m; - b = c; - break; - default: // (5) Red is the dominant color - r = c; - g = m; - b = x; - break; - } -} - void Color::set_ok_hsl(float p_h, float p_s, float p_l, float p_alpha) { ok_color::HSL hsl; hsl.h = p_h; @@ -547,12 +468,6 @@ Color Color::from_hsv(float p_h, float p_s, float p_v, float p_alpha) { return c; } -Color Color::from_hsl(float p_h, float p_s, float p_l, float p_alpha) { - Color c; - c.set_hsl(p_h, p_s, p_l, p_alpha); - return c; -} - Color Color::from_rgbe9995(uint32_t p_rgbe) { float r = p_rgbe & 0x1ff; float g = (p_rgbe >> 9) & 0x1ff; diff --git a/core/math/color.h b/core/math/color.h index 4a056335c1..65d7377c1c 100644 --- a/core/math/color.h +++ b/core/math/color.h @@ -57,10 +57,6 @@ struct _NO_DISCARD_ Color { float get_s() const; float get_v() const; void set_hsv(float p_h, float p_s, float p_v, float p_alpha = 1.0f); - float get_hsl_h() const; - float get_hsl_s() const; - float get_hsl_l() const; - void set_hsl(float p_h, float p_s, float p_l, float p_alpha = 1.0f); float get_ok_hsl_h() const; float get_ok_hsl_s() const; float get_ok_hsl_l() const; @@ -202,7 +198,6 @@ struct _NO_DISCARD_ Color { static Color get_named_color(int p_idx); static Color from_string(const String &p_string, const Color &p_default); static Color from_hsv(float p_h, float p_s, float p_v, float p_alpha = 1.0f); - static Color from_hsl(float p_h, float p_s, float p_l, float p_alpha = 1.0f); static Color from_ok_hsl(float p_h, float p_s, float p_l, float p_alpha = 1.0f); static Color from_rgbe9995(uint32_t p_rgbe); @@ -222,9 +217,6 @@ struct _NO_DISCARD_ Color { _FORCE_INLINE_ void set_h(float p_h) { set_hsv(p_h, get_s(), get_v(), a); } _FORCE_INLINE_ void set_s(float p_s) { set_hsv(get_h(), p_s, get_v(), a); } _FORCE_INLINE_ void set_v(float p_v) { set_hsv(get_h(), get_s(), p_v, a); } - _FORCE_INLINE_ void set_hsl_h(float p_h) { set_hsl(p_h, get_hsl_s(), get_hsl_l(), a); } - _FORCE_INLINE_ void set_hsl_s(float p_s) { set_hsl(get_hsl_h(), p_s, get_hsl_l(), a); } - _FORCE_INLINE_ void set_hsl_l(float p_l) { set_hsl(get_hsl_h(), get_hsl_s(), p_l, a); } _FORCE_INLINE_ void set_ok_hsl_h(float p_h) { set_ok_hsl(p_h, get_ok_hsl_s(), get_ok_hsl_l(), a); } _FORCE_INLINE_ void set_ok_hsl_s(float p_s) { set_ok_hsl(get_ok_hsl_h(), p_s, get_ok_hsl_l(), a); } _FORCE_INLINE_ void set_ok_hsl_l(float p_l) { set_ok_hsl(get_ok_hsl_h(), get_ok_hsl_s(), p_l, a); } diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index e22970ef5c..0a836c125a 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -2002,7 +2002,6 @@ static void _register_variant_builtin_methods() { bind_static_method(Color, html_is_valid, sarray("color"), varray()); bind_static_method(Color, from_string, sarray("str", "default"), varray()); bind_static_method(Color, from_hsv, sarray("h", "s", "v", "alpha"), varray(1.0)); - bind_static_method(Color, from_hsl, sarray("h", "s", "l", "alpha"), varray(1.0)); bind_static_method(Color, from_ok_hsl, sarray("h", "s", "l", "alpha"), varray(1.0)); bind_static_method(Color, from_rgbe9995, sarray("rgbe"), varray()); diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index ce035f5f7a..30fb5d0e9f 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -139,10 +139,6 @@ void register_named_setters_getters() { REGISTER_MEMBER(Color, h); REGISTER_MEMBER(Color, s); REGISTER_MEMBER(Color, v); - - REGISTER_MEMBER(Color, hsl_h); - REGISTER_MEMBER(Color, hsl_s); - REGISTER_MEMBER(Color, hsl_l); } void unregister_named_setters_getters() { diff --git a/core/variant/variant_setget.h b/core/variant/variant_setget.h index db6e273817..176967344f 100644 --- a/core/variant/variant_setget.h +++ b/core/variant/variant_setget.h @@ -344,10 +344,6 @@ SETGET_NUMBER_STRUCT_FUNC(Color, double, h, set_h, get_h) SETGET_NUMBER_STRUCT_FUNC(Color, double, s, set_s, get_s) SETGET_NUMBER_STRUCT_FUNC(Color, double, v, set_v, get_v) -SETGET_NUMBER_STRUCT_FUNC(Color, double, hsl_h, set_hsl_h, get_hsl_h) -SETGET_NUMBER_STRUCT_FUNC(Color, double, hsl_s, set_hsl_s, get_hsl_s) -SETGET_NUMBER_STRUCT_FUNC(Color, double, hsl_l, set_hsl_l, get_hsl_l) - SETGET_NUMBER_STRUCT_FUNC(Color, double, ok_hsl_h, set_ok_hsl_h, get_ok_hsl_h) SETGET_NUMBER_STRUCT_FUNC(Color, double, ok_hsl_s, set_ok_hsl_s, get_ok_hsl_s) SETGET_NUMBER_STRUCT_FUNC(Color, double, ok_hsl_l, set_ok_hsl_l, get_ok_hsl_l) |
