You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Use OkHSV for rainbow labels.
This commit is contained in:
@@ -246,6 +246,19 @@ void Color::set_ok_hsl(float p_h, float p_s, float p_l, float p_alpha) {
|
||||
a = c.a;
|
||||
}
|
||||
|
||||
void Color::set_ok_hsv(float p_h, float p_s, float p_v, float p_alpha) {
|
||||
ok_color::HSV hsv;
|
||||
hsv.h = p_h;
|
||||
hsv.s = p_s;
|
||||
hsv.v = p_v;
|
||||
ok_color::RGB rgb = ok_color::okhsv_to_srgb(hsv);
|
||||
Color c = Color(rgb.r, rgb.g, rgb.b, p_alpha).clamp();
|
||||
r = c.r;
|
||||
g = c.g;
|
||||
b = c.b;
|
||||
a = c.a;
|
||||
}
|
||||
|
||||
bool Color::is_equal_approx(const Color &p_color) const {
|
||||
return Math::is_equal_approx(r, p_color.r) && Math::is_equal_approx(g, p_color.g) && Math::is_equal_approx(b, p_color.b) && Math::is_equal_approx(a, p_color.a);
|
||||
}
|
||||
@@ -476,6 +489,12 @@ Color Color::from_ok_hsl(float p_h, float p_s, float p_l, float p_alpha) {
|
||||
return c;
|
||||
}
|
||||
|
||||
Color Color::from_ok_hsv(float p_h, float p_s, float p_l, float p_alpha) {
|
||||
Color c;
|
||||
c.set_ok_hsv(p_h, p_s, p_l, p_alpha);
|
||||
return c;
|
||||
}
|
||||
|
||||
float Color::get_ok_hsl_h() const {
|
||||
ok_color::RGB rgb;
|
||||
rgb.r = r;
|
||||
|
||||
@@ -62,6 +62,7 @@ struct [[nodiscard]] Color {
|
||||
float get_ok_hsl_s() const;
|
||||
float get_ok_hsl_l() const;
|
||||
void set_ok_hsl(float p_h, float p_s, float p_l, float p_alpha = 1.0f);
|
||||
void set_ok_hsv(float p_h, float p_s, float p_v, float p_alpha = 1.0f);
|
||||
|
||||
_FORCE_INLINE_ float &operator[](int p_idx) {
|
||||
return components[p_idx];
|
||||
@@ -214,6 +215,7 @@ struct [[nodiscard]] Color {
|
||||
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_ok_hsl(float p_h, float p_s, float p_l, float p_alpha = 1.0f);
|
||||
static Color from_ok_hsv(float p_h, float p_s, float p_l, float p_alpha = 1.0f);
|
||||
static Color from_rgbe9995(uint32_t p_rgbe);
|
||||
static Color from_rgba8(int64_t p_r8, int64_t p_g8, int64_t p_b8, int64_t p_a8 = 255);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user