1use nannou::color::{Rgb, Srgb};
4
5pub struct Palette;
9
10impl Palette {
11 pub fn generator() -> Srgb<u8> {
13 Srgb::new(66, 133, 244)
14 }
15
16 pub fn effector() -> Srgb<u8> {
18 Srgb::new(52, 168, 83)
19 }
20
21 pub fn modulator() -> Srgb<u8> {
23 Srgb::new(156, 39, 176)
24 }
25
26 pub fn io() -> Srgb<u8> {
28 Srgb::new(251, 140, 0)
29 }
30
31 pub fn audio_connection() -> Srgb<u8> {
33 Srgb::new(158, 158, 158)
34 }
35
36 pub fn modulation_connection() -> Srgb<u8> {
38 Srgb::new(233, 30, 99)
39 }
40
41 pub fn text() -> Srgb<u8> {
43 Srgb::new(255, 255, 255)
44 }
45
46 pub fn background() -> Srgb<u8> {
48 Srgb::new(30, 30, 30)
49 }
50
51 pub fn waveform() -> Srgb<u8> {
53 Srgb::new(0, 188, 212)
54 }
55
56 pub fn spectrum() -> Srgb<u8> {
58 Srgb::new(233, 30, 99)
59 }
60
61 pub fn spectrum_peak() -> Srgb<u8> {
63 Srgb::new(255, 235, 59)
64 }
65
66 pub fn midi_note_on() -> Srgb<u8> {
68 Srgb::new(76, 175, 80)
69 }
70
71 pub fn midi_note_off() -> Srgb<u8> {
73 Srgb::new(66, 66, 66)
74 }
75}
76
77pub fn to_rgb(color: Srgb<u8>) -> Rgb {
79 Rgb::new(
80 color.red as f32 / 255.0,
81 color.green as f32 / 255.0,
82 color.blue as f32 / 255.0,
83 )
84}
85
86pub fn lerp_color(a: Srgb<u8>, b: Srgb<u8>, t: f32) -> Rgb {
88 let t = t.clamp(0.0, 1.0);
89 Rgb::new(
90 (a.red as f32 + (b.red as f32 - a.red as f32) * t) / 255.0,
91 (a.green as f32 + (b.green as f32 - a.green as f32) * t) / 255.0,
92 (a.blue as f32 + (b.blue as f32 - a.blue as f32) * t) / 255.0,
93 )
94}