Merge pull request #67540 from KoBeWi/hue_hue_hue
Add a separate hue gradient for OKHSL mode
This commit is contained in:
commit
3cde6c0432
4 changed files with 60 additions and 7 deletions
|
@ -151,6 +151,9 @@
|
|||
<theme_item name="color_hue" data_type="icon" type="Texture2D">
|
||||
Custom texture for the hue selection slider on the right.
|
||||
</theme_item>
|
||||
<theme_item name="color_okhsl_hue" data_type="icon" type="Texture2D">
|
||||
Custom texture for the H slider in the OKHSL color mode.
|
||||
</theme_item>
|
||||
<theme_item name="expanded_arrow" data_type="icon" type="Texture2D">
|
||||
The icon for color preset drop down menu when expanded.
|
||||
</theme_item>
|
||||
|
|
|
@ -158,8 +158,7 @@ void ColorModeHSV::slider_draw(int p_which) {
|
|||
right_color.a = 1;
|
||||
} else if (p_which == 0) {
|
||||
Ref<Texture2D> hue = color_picker->get_theme_icon(SNAME("color_hue"), SNAME("ColorPicker"));
|
||||
slider->draw_set_transform(Point2(), -Math_PI / 2, Size2(1.0, 1.0));
|
||||
slider->draw_texture_rect(hue, Rect2(Vector2(margin * -1, 0), Vector2(margin, size.x)), false);
|
||||
slider->draw_texture_rect(hue, Rect2(Vector2(), Vector2(size.x, margin)), false);
|
||||
return;
|
||||
} else {
|
||||
Color s_col;
|
||||
|
@ -289,9 +288,8 @@ void ColorModeOKHSL::slider_draw(int p_which) {
|
|||
const real_t margin = 16 * color_picker->get_theme_default_base_scale();
|
||||
|
||||
if (p_which == 0) { // H
|
||||
Ref<Texture2D> hue = color_picker->get_theme_icon(SNAME("color_hue"), SNAME("ColorPicker"));
|
||||
slider->draw_set_transform(Point2(), -Math_PI / 2, Size2(1.0, 1.0));
|
||||
slider->draw_texture_rect(hue, Rect2(Vector2(margin * -1, 0), Vector2(margin, size.x)), false);
|
||||
Ref<Texture2D> hue = color_picker->get_theme_icon(SNAME("color_okhsl_hue"), SNAME("ColorPicker"));
|
||||
slider->draw_texture_rect(hue, Rect2(Vector2(), Vector2(size.x, margin)), false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" viewBox="0 0 1 256" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientTransform="matrix(0 256 -256 0 0 0)" gradientUnits="userSpaceOnUse" x1="0" x2="1" y1="0" y2="0"><stop offset="0" stop-color="#f00"/><stop offset=".04" stop-color="#ff4000"/><stop offset=".08" stop-color="#ff8000"/><stop offset=".17" stop-color="#ff0"/><stop offset=".25" stop-color="#80ff00"/><stop offset=".33" stop-color="#0f0"/><stop offset=".42" stop-color="#00ff80"/><stop offset=".5" stop-color="#0ff"/><stop offset=".58" stop-color="#0080ff"/><stop offset=".63" stop-color="#0040ff"/><stop offset=".67" stop-color="#00f"/><stop offset=".75" stop-color="#8000ff"/><stop offset=".83" stop-color="#f0f"/><stop offset=".92" stop-color="#ff0080"/><stop offset="1" stop-color="#f00"/></linearGradient><path d="m0 0h1v256h-1z" fill="url(#a)"/></svg>
|
Before Width: | Height: | Size: 970 B |
|
@ -887,12 +887,65 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &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("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<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_hsv(h, 1, 1);
|
||||
}
|
||||
hue_gradient->set_offsets(offsets);
|
||||
hue_gradient->set_colors(colors);
|
||||
|
||||
Ref<GradientTexture2D> 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<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, 1, 0.5);
|
||||
}
|
||||
hue_gradient->set_offsets(offsets);
|
||||
hue_gradient->set_colors(colors);
|
||||
|
||||
Ref<GradientTexture2D> 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"]);
|
||||
|
|
Loading…
Reference in a new issue