From e8d296e6c82a918e6002bffd2c231fbad901bd72 Mon Sep 17 00:00:00 2001 From: bonjorno7 Date: Tue, 25 Apr 2023 17:00:09 +0200 Subject: [PATCH] Add variant setget members for OK HSV and OK HSL I want to be able to convert both ways. I added these for OK HSL too for consistency; they already existed for standard HSV. It'd be more efficient to also have methods for getting HSV / OK HSV / OK HSL in one go instead of having to use these separate members, but that might be a bit out of scope for this PR. C# does have a ToHsv method, so I guess the APIs don't have to be identical. I should probably add ToOkHsv and ToOkHsl methods though, so C# at least has access to the same functionality as GDScript. I believe I did the documentation correctly this time around. --- core/variant/variant_setget.cpp | 8 ++++++++ doc/classes/Color.xml | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index 30fb5d0e9fa4..0b3a7bd616d6 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -139,6 +139,14 @@ void register_named_setters_getters() { REGISTER_MEMBER(Color, h); REGISTER_MEMBER(Color, s); REGISTER_MEMBER(Color, v); + + REGISTER_MEMBER(Color, ok_hsv_h); + REGISTER_MEMBER(Color, ok_hsv_s); + REGISTER_MEMBER(Color, ok_hsv_v); + + REGISTER_MEMBER(Color, ok_hsl_h); + REGISTER_MEMBER(Color, ok_hsl_s); + REGISTER_MEMBER(Color, ok_hsl_l); } void unregister_named_setters_getters() { diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index 2c49c2b5fb68..50eeb1ba786d 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -511,6 +511,24 @@ The HSV hue of this color, on the range 0 to 1. + + The OK HSL hue of this color, on the range 0 to 1. + + + The OK HSL lightness of this color, on the range 0 to 1. + + + The OK HSL saturation of this color, on the range 0 to 1. + + + The OK HSV hue of this color, on the range 0 to 1. + + + The OK HSV saturation of this color, on the range 0 to 1. + + + The OK HSV value (brightness) of this color, on the range 0 to 1. + The color's red component, typically on the range of 0 to 1.