-
Notifications
You must be signed in to change notification settings - Fork 0
/
panel3_p4_hue_rel_univ.rs
64 lines (51 loc) · 1.51 KB
/
panel3_p4_hue_rel_univ.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
54
55
56
57
58
59
60
61
62
63
64
extern crate kolorwheel;
use kolorwheel::{ KolorWheel, SpinMode, HslColor };
use crate::App;
use crate::Panel;
pub struct HueRelUniv {
include: bool,
cols: u32,
rows: u32,
color: HslColor,
hue: i32,
}
impl HueRelUniv {
pub fn new(include: bool) -> Self {
Self {
include,
cols: 3,
rows: 2,
color: HslColor::new(0, 100, 50),
hue: 360,
}
}
}
impl Panel for HueRelUniv {
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(
if self.include { " Change hue relative, including target:" }
else { " Change hue relative, excluding target:" }
);
ui.add(
egui::Slider::new(&mut self.hue, -360..=360)
.orientation(egui::SliderOrientation::Vertical)
.trailing_fill(true)
.text("Hue+")
.suffix("°")
);
});
let mut kw = KolorWheel::new(self.color, (self.cols * self.rows) as usize);
if self.include {
kw.with_hue(SpinMode::RelativeIncl(self.hue));
} else {
kw.with_hue(SpinMode::RelativeExcl(self.hue));
}
(kw, self.cols, self.rows)
}
}