-
Notifications
You must be signed in to change notification settings - Fork 0
/
panel2_lit_abs.rs
53 lines (42 loc) · 1.2 KB
/
panel2_lit_abs.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
extern crate kolorwheel;
use kolorwheel::{ KolorWheel, SpinMode, HslColor };
use crate::App;
use crate::Panel;
pub struct LitAbs {
cols: u32,
rows: u32,
color: HslColor,
lit: i32,
}
impl LitAbs {
pub fn new() -> Self {
Self {
cols: 4,
rows: 4,
color: HslColor::new(140, 70, 60),
lit: 40,
}
}
}
impl Panel for LitAbs {
fn get_source_script(&self) -> &str {
file!()
}
fn paint(&mut self, ui: &mut egui::Ui) -> (KolorWheel, u32, u32) {
ui.with_layout(egui::Layout::left_to_right(egui::Align::LEFT), |ui| {
ui.label("Base color:");
App::paint_hsl_sliders(ui, &mut self.color);
ui.label(" Change lightness to absolute:");
ui.add(
egui::Slider::new(&mut self.lit, 0..=100)
.orientation(egui::SliderOrientation::Vertical)
.trailing_fill(true)
.text("Lit")
.suffix("%")
);
});
let mut kw = KolorWheel::new(self.color, (self.cols * self.rows) as usize);
kw.with_lightness(SpinMode::Absolute(self.lit));
(kw, self.cols, self.rows)
}
}