|
@@ -32,6 +32,7 @@
|
|
|
|
|
|
#include "core/math/color.h"
|
|
|
#include "scene/gui/slider.h"
|
|
|
+#include "scene/resources/gradient_texture.h"
|
|
|
|
|
|
ColorMode::ColorMode(ColorPicker *p_color_picker) {
|
|
|
color_picker = p_color_picker;
|
|
@@ -398,8 +399,29 @@ void ColorModeOKHSL::slider_draw(int p_which) {
|
|
|
slider->draw_polygon(pos, col);
|
|
|
|
|
|
if (p_which == 0) { // H
|
|
|
- Ref<Texture2D> hue = color_picker->theme_cache.color_okhsl_hue;
|
|
|
- slider->draw_texture_rect(hue, Rect2(Vector2(), Vector2(size.x, margin)), false, Color::from_hsv(0, 0, color.get_ok_hsl_l() * 2.0, color.get_ok_hsl_s()));
|
|
|
- return;
|
|
|
+ const int precision = 7;
|
|
|
+
|
|
|
+ Ref<Gradient> hue_gradient;
|
|
|
+ hue_gradient.instantiate();
|
|
|
+ PackedFloat32Array offsets;
|
|
|
+ offsets.resize(precision);
|
|
|
+ PackedColorArray colors;
|
|
|
+ colors.resize(precision);
|
|
|
+
|
|
|
+ for (int i = 0; i < precision; i++) {
|
|
|
+ float h = i / float(precision - 1);
|
|
|
+ offsets.write[i] = h;
|
|
|
+ colors.write[i] = Color::from_ok_hsl(h, color.get_ok_hsl_s(), color.get_ok_hsl_l());
|
|
|
+ }
|
|
|
+ hue_gradient->set_offsets(offsets);
|
|
|
+ hue_gradient->set_colors(colors);
|
|
|
+ hue_gradient->set_interpolation_color_space(Gradient::ColorSpace::GRADIENT_COLOR_SPACE_OKLAB);
|
|
|
+ if (hue_texture.is_null()) {
|
|
|
+ hue_texture.instantiate();
|
|
|
+ hue_texture->set_width(800);
|
|
|
+ hue_texture->set_height(6);
|
|
|
+ }
|
|
|
+ hue_texture->set_gradient(hue_gradient);
|
|
|
+ slider->draw_texture_rect(hue_texture, Rect2(Vector2(), Vector2(size.x, margin)), false);
|
|
|
}
|
|
|
}
|