diff --git a/crates/egui/src/widgets/color_picker.rs b/crates/egui/src/widgets/color_picker.rs index e4524d18b35..da5f2867d8c 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.: `|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, 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.