Skip to content

Commit

Permalink
Add variant setget members for OK HSV and OK HSL
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bonjorno7 committed Apr 25, 2023
1 parent feb00f4 commit e8d296e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/variant/variant_setget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
18 changes: 18 additions & 0 deletions doc/classes/Color.xml
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,24 @@
<member name="h" type="float" setter="" getter="" default="0.0">
The HSV hue of this color, on the range 0 to 1.
</member>
<member name="ok_hsl_h" type="float" setter="" getter="" default="0.0">
The OK HSL hue of this color, on the range 0 to 1.
</member>
<member name="ok_hsl_l" type="float" setter="" getter="" default="0.0">
The OK HSL lightness of this color, on the range 0 to 1.
</member>
<member name="ok_hsl_s" type="float" setter="" getter="" default="0.0">
The OK HSL saturation of this color, on the range 0 to 1.
</member>
<member name="ok_hsv_h" type="float" setter="" getter="" default="0.0">
The OK HSV hue of this color, on the range 0 to 1.
</member>
<member name="ok_hsv_s" type="float" setter="" getter="" default="0.0">
The OK HSV saturation of this color, on the range 0 to 1.
</member>
<member name="ok_hsv_v" type="float" setter="" getter="" default="0.0">
The OK HSV value (brightness) of this color, on the range 0 to 1.
</member>
<member name="r" type="float" setter="" getter="" default="0.0">
The color's red component, typically on the range of 0 to 1.
</member>
Expand Down

0 comments on commit e8d296e

Please sign in to comment.