Skip to content

Commit fdd3c8a

Browse files
committed
Merge pull request #101337 from beicause/csharp-okhsl-properties
C#: Add OKHSL properties to Color
2 parents 33fb876 + a71a8c6 commit fdd3c8a

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs

+45
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,51 @@ readonly get
193193
}
194194
}
195195

196+
/// <summary>
197+
/// The OKHSL hue of this color, on the range 0 to 1.
198+
/// </summary>
199+
public float OkHslH
200+
{
201+
readonly get
202+
{
203+
return NativeFuncs.godotsharp_color_get_ok_hsl_h(this);
204+
}
205+
set
206+
{
207+
this = FromOkHsl(value, OkHslS, OkHslL, A);
208+
}
209+
}
210+
211+
/// <summary>
212+
/// The OKHSL saturation of this color, on the range 0 to 1.
213+
/// </summary>
214+
public float OkHslS
215+
{
216+
readonly get
217+
{
218+
return NativeFuncs.godotsharp_color_get_ok_hsl_s(this);
219+
}
220+
set
221+
{
222+
this = FromOkHsl(OkHslH, value, OkHslL, A);
223+
}
224+
}
225+
226+
/// <summary>
227+
/// The OKHSL lightness of this color, on the range 0 to 1.
228+
/// </summary>
229+
public float OkHslL
230+
{
231+
readonly get
232+
{
233+
return NativeFuncs.godotsharp_color_get_ok_hsl_l(this);
234+
}
235+
set
236+
{
237+
this = FromOkHsl(OkHslH, OkHslS, value, A);
238+
}
239+
}
240+
196241
/// <summary>
197242
/// Returns the light intensity of the color, as a value between 0.0 and 1.0 (inclusive).
198243
/// This is useful when determining light or dark color. Colors with a luminance smaller

modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs

+6
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ internal static partial void godotsharp_callable_call_deferred(in godot_callable
167167

168168
internal static partial Color godotsharp_color_from_ok_hsl(float p_h, float p_s, float p_l, float p_alpha);
169169

170+
internal static partial float godotsharp_color_get_ok_hsl_h(in Color p_self);
171+
172+
internal static partial float godotsharp_color_get_ok_hsl_s(in Color p_self);
173+
174+
internal static partial float godotsharp_color_get_ok_hsl_l(in Color p_self);
175+
170176
// GDNative functions
171177

172178
// gdnative.h

modules/mono/glue/runtime_interop.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,18 @@ godot_color godotsharp_color_from_ok_hsl(float p_h, float p_s, float p_l, float
559559
return ret;
560560
}
561561

562+
float godotsharp_color_get_ok_hsl_h(const Color *p_self) {
563+
return p_self->get_ok_hsl_h();
564+
}
565+
566+
float godotsharp_color_get_ok_hsl_s(const Color *p_self) {
567+
return p_self->get_ok_hsl_s();
568+
}
569+
570+
float godotsharp_color_get_ok_hsl_l(const Color *p_self) {
571+
return p_self->get_ok_hsl_l();
572+
}
573+
562574
// GDNative functions
563575

564576
// gdnative.h
@@ -1551,6 +1563,9 @@ static const void *unmanaged_callbacks[]{
15511563
(void *)godotsharp_callable_call,
15521564
(void *)godotsharp_callable_call_deferred,
15531565
(void *)godotsharp_color_from_ok_hsl,
1566+
(void *)godotsharp_color_get_ok_hsl_h,
1567+
(void *)godotsharp_color_get_ok_hsl_s,
1568+
(void *)godotsharp_color_get_ok_hsl_l,
15541569
(void *)godotsharp_method_bind_ptrcall,
15551570
(void *)godotsharp_method_bind_call,
15561571
(void *)godotsharp_variant_new_string_name,

0 commit comments

Comments
 (0)