ColorPicker: Improve the accuracy of hue slider in OKHSL mode

This commit is contained in:
LuoZhihao
2025-01-04 21:36:27 +08:00
parent efa144396d
commit 9eeeadb037
6 changed files with 29 additions and 35 deletions

View File

@ -1081,33 +1081,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
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"]);