Add HSV scaling utilities
This commit is contained in:
parent
dbc6bf993b
commit
7a50cc3383
2 changed files with 22 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
//! to copy the widgets and modify them to your personal taste.
|
||||
|
||||
mod param_slider;
|
||||
pub mod util;
|
||||
|
||||
pub use param_slider::ParamSlider;
|
||||
|
||||
|
|
21
nih_plug_egui/src/widgets/util.rs
Normal file
21
nih_plug_egui/src/widgets/util.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
//! Utilities for creating these widgets
|
||||
|
||||
use egui::Color32;
|
||||
|
||||
/// Additively modify the hue, saturation, and lightness [0, 1] values of a color.
|
||||
pub fn add_hsv(color: Color32, h: f32, s: f32, v: f32) -> Color32 {
|
||||
let mut hsv = egui::color::Hsva::from(color);
|
||||
hsv.h += h;
|
||||
hsv.s += s;
|
||||
hsv.v += v;
|
||||
hsv.into()
|
||||
}
|
||||
|
||||
/// Multiplicatively modify the hue, saturation, and lightness [0, 1] values of a color.
|
||||
pub fn scale_hsv(color: Color32, h: f32, s: f32, v: f32) -> Color32 {
|
||||
let mut hsv = egui::color::Hsva::from(color);
|
||||
hsv.h *= h;
|
||||
hsv.s *= s;
|
||||
hsv.v *= v;
|
||||
hsv.into()
|
||||
}
|
Loading…
Add table
Reference in a new issue