From 12cf4dd7f20db4139ecf45da3b598d345f69cdf2 Mon Sep 17 00:00:00 2001 From: IVANMK-7 <68190772+IVANMK-7@users.noreply.github.com> Date: Sun, 12 Feb 2023 17:09:27 +0100 Subject: [PATCH 1/2] hsva color_slider_2d orientation change --- crates/egui/src/widgets/color_picker.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/color_picker.rs b/crates/egui/src/widgets/color_picker.rs index e4524d18b35..6761e433f5a 100644 --- a/crates/egui/src/widgets/color_picker.rs +++ b/crates/egui/src/widgets/color_picker.rs @@ -155,6 +155,12 @@ fn color_slider_1d(ui: &mut Ui, value: &mut f32, color_at: impl Fn(f32) -> Color response } +/// # Arguments +/// * `x_value` - X axis, either saturation or value (0.0-1.0). +/// * `y_value` - Y axis, either saturation or value (0.0-1.0). +/// * `color_at` - A function that dictates how the mix of saturation and value will be displayed in the 2d slider. +/// E.g.: color_at(hsvag.s as x_value, hsvag.v as y_value) displays the colors as follows: top-left: white \[s: 0.0, v: 1.0], top-right: fully saturated color \[s: 1.0, v: 1.0], bottom-right: black \[s: 0.0, v: 1.0] +/// fn color_slider_2d( ui: &mut Ui, x_value: &mut f32, @@ -308,7 +314,7 @@ fn color_picker_hsvag_2d(ui: &mut Ui, hsva: &mut HsvaGamma, alpha: Alpha) { color_slider_1d(ui, v, |v| HsvaGamma { v, ..opaque }.into()).on_hover_text("Value"); } - color_slider_2d(ui, v, s, |v, s| HsvaGamma { s, v, ..opaque }.into()); + color_slider_2d(ui, s, v, |s, v| HsvaGamma { s, v, ..opaque }.into()); } //// Shows a color picker where the user can change the given [`Hsva`] color. From fd3a873eb972cc5b301b6177740d11793c86dcca Mon Sep 17 00:00:00 2001 From: IVANMK-7 <68190772+IVANMK-7@users.noreply.github.com> Date: Sun, 12 Feb 2023 17:51:06 +0100 Subject: [PATCH 2/2] color_slider_2d doc fix --- crates/egui/src/widgets/color_picker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/color_picker.rs b/crates/egui/src/widgets/color_picker.rs index 6761e433f5a..da5f2867d8c 100644 --- a/crates/egui/src/widgets/color_picker.rs +++ b/crates/egui/src/widgets/color_picker.rs @@ -159,7 +159,7 @@ fn color_slider_1d(ui: &mut Ui, value: &mut f32, color_at: impl Fn(f32) -> Color /// * `x_value` - X axis, either saturation or value (0.0-1.0). /// * `y_value` - Y axis, either saturation or value (0.0-1.0). /// * `color_at` - A function that dictates how the mix of saturation and value will be displayed in the 2d slider. -/// E.g.: color_at(hsvag.s as x_value, hsvag.v as y_value) displays the colors as follows: top-left: white \[s: 0.0, v: 1.0], top-right: fully saturated color \[s: 1.0, v: 1.0], bottom-right: black \[s: 0.0, v: 1.0] +/// E.g.: `|x_value, y_value| HsvaGamma { h: 1.0, s: x_value, v: y_value, a: 1.0 }.into()` displays the colors as follows: top-left: white \[s: 0.0, v: 1.0], top-right: fully saturated color \[s: 1.0, v: 1.0], bottom-right: black \[s: 0.0, v: 1.0]. /// fn color_slider_2d( ui: &mut Ui,