Skip to content

Commit

Permalink
hsva color_slider_2d orientation change (#2727)
Browse files Browse the repository at this point in the history
* hsva color_slider_2d orientation change

* color_slider_2d doc fix

---------

Co-authored-by: IVANMK-7 <[email protected]>
  • Loading branch information
IVAN-MK7 and IVAN-MK7 authored Feb 28, 2023
1 parent 5910144 commit e9d869c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/egui/src/widgets/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e9d869c

Please sign in to comment.