-
Notifications
You must be signed in to change notification settings - Fork 0
/
panel1_gradient.rs
46 lines (36 loc) · 1.05 KB
/
panel1_gradient.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
extern crate kolorwheel;
use kolorwheel::{ KolorWheel, SpinMacro, HslColor };
use crate::App;
use crate::Panel;
pub struct Gradient {
cols: u32,
rows: u32,
color1: HslColor,
color2: HslColor,
}
impl Gradient {
pub fn new() -> Self {
Self {
cols: 5,
rows: 5,
color1: HslColor::new(0, 100, 50),
color2: HslColor::new(270, 70, 30),
}
}
}
impl Panel for Gradient {
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.color1);
ui.label(" Gradient to:");
App::paint_hsl_sliders(ui, &mut self.color2);
});
let mut kw = KolorWheel::new(self.color1, (self.cols * self.rows) as usize);
kw.with_macro(SpinMacro::GradientColor(self.color2));
(kw, self.cols, self.rows)
}
}