From 84d6549c75abe27232d40f973f25a3cc2bad0078 Mon Sep 17 00:00:00 2001 From: kobewi Date: Wed, 2 Nov 2022 15:34:15 +0100 Subject: Change hue icons to horizontal GradientTexture2D --- scene/resources/default_theme/color_picker_hue.svg | 1 - .../default_theme/color_picker_okhsl_hue.svg | 1 - scene/resources/default_theme/default_theme.cpp | 56 +++++++++++++++++++++- 3 files changed, 54 insertions(+), 4 deletions(-) delete mode 100644 scene/resources/default_theme/color_picker_hue.svg delete mode 100644 scene/resources/default_theme/color_picker_okhsl_hue.svg (limited to 'scene/resources') diff --git a/scene/resources/default_theme/color_picker_hue.svg b/scene/resources/default_theme/color_picker_hue.svg deleted file mode 100644 index ff75d5eb9e..0000000000 --- a/scene/resources/default_theme/color_picker_hue.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/scene/resources/default_theme/color_picker_okhsl_hue.svg b/scene/resources/default_theme/color_picker_okhsl_hue.svg deleted file mode 100644 index dfd1d5e2b5..0000000000 --- a/scene/resources/default_theme/color_picker_okhsl_hue.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index b4b9542f18..894936acd7 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -887,13 +887,65 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_icon("shape_rect", "ColorPicker", icons["picker_shape_rectangle"]); theme->set_icon("shape_rect_wheel", "ColorPicker", icons["picker_shape_rectangle_wheel"]); theme->set_icon("add_preset", "ColorPicker", icons["add"]); - theme->set_icon("color_hue", "ColorPicker", icons["color_picker_hue"]); - theme->set_icon("color_okhsl_hue", "ColorPicker", icons["color_picker_okhsl_hue"]); theme->set_icon("sample_bg", "ColorPicker", icons["mini_checkerboard"]); theme->set_icon("overbright_indicator", "ColorPicker", icons["color_picker_overbright"]); theme->set_icon("bar_arrow", "ColorPicker", icons["color_picker_bar_arrow"]); theme->set_icon("picker_cursor", "ColorPicker", icons["color_picker_cursor"]); + { + const int precision = 7; + + Ref 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_hsv(h, 1, 1); + } + hue_gradient->set_offsets(offsets); + hue_gradient->set_colors(colors); + + Ref hue_texture; + hue_texture.instantiate(); + hue_texture->set_width(800); + hue_texture->set_height(6); + hue_texture->set_gradient(hue_gradient); + + theme->set_icon("color_hue", "ColorPicker", hue_texture); + } + + { + const int precision = 7; + + Ref 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, 1, 0.5); + } + hue_gradient->set_offsets(offsets); + hue_gradient->set_colors(colors); + + Ref hue_texture; + hue_texture.instantiate(); + hue_texture->set_width(800); + hue_texture->set_height(6); + hue_texture->set_gradient(hue_gradient); + + theme->set_icon("color_okhsl_hue", "ColorPicker", hue_texture); + } + // ColorPickerButton theme->set_icon("bg", "ColorPickerButton", icons["mini_checkerboard"]); -- cgit v1.2.3