diff --git a/src/config.rs b/src/config.rs index d1b28168..8049ca55 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,11 @@ use serde::{Deserialize, Serialize}; +#[derive(Serialize, Deserialize, Default)] +pub struct ColorShema { + pub base: (u8, u8, u8), + pub dark: (u8, u8, u8), +} + #[derive(Serialize, Deserialize)] pub struct Config { #[serde(default = "default_speed_multiplier")] @@ -9,7 +15,11 @@ pub struct Config { pub playback_offset: f32, #[serde(default = "default_play_along")] + #[serde(skip_serializing)] pub play_along: bool, + + #[serde(default = "default_color_shema")] + pub color_shema: Vec, } impl Config { @@ -31,6 +41,7 @@ impl Config { speed_multiplier: default_speed_multiplier(), playback_offset: default_playback_offset(), play_along: default_play_along(), + color_shema: default_color_shema(), }) } } @@ -55,3 +66,16 @@ fn default_playback_offset() -> f32 { fn default_play_along() -> bool { false } + +fn default_color_shema() -> Vec { + vec![ + ColorShema { + base: (93, 188, 255), + dark: (48, 124, 255), + }, + ColorShema { + base: (210, 89, 222), + dark: (125, 69, 134), + }, + ] +} diff --git a/src/scene/playing_scene/keyboard.rs b/src/scene/playing_scene/keyboard.rs index 87084d63..55df1a11 100644 --- a/src/scene/playing_scene/keyboard.rs +++ b/src/scene/playing_scene/keyboard.rs @@ -139,29 +139,21 @@ impl PianoKeyboard { } } - let colors: [[Color; 2]; 2] = [ - [ - Color::from_rgba8(93, 188, 255, 1.0), - Color::from_rgba8(48, 124, 255, 1.0), - ], - [ - Color::from_rgba8(210, 89, 222, 1.0), - Color::from_rgba8(125, 69, 134, 1.0), - ], - ]; + let color_shema = &target.state.config.color_shema; + let white_keys = white_keys.into_iter().map(|note| { - let color = colors[note.1 % 2]; + let color = &color_shema[note.1 % color_shema.len()]; if note.0 { - color[0] + color.base.into() } else { Color::new(1.0, 1.0, 1.0, 1.0) } }); let black_keys = black_keys.into_iter().map(|note| { - let color = colors[note.1 % 2]; + let color = &color_shema[note.1 % color_shema.len()]; if note.0 { - color[1] + color.dark.into() } else { Color::new(0.1, 0.1, 0.1, 1.0) } diff --git a/src/scene/playing_scene/notes.rs b/src/scene/playing_scene/notes.rs index 39964436..b7b0f70d 100644 --- a/src/scene/playing_scene/notes.rs +++ b/src/scene/playing_scene/notes.rs @@ -31,29 +31,11 @@ impl Notes { let key = &keys[note.note as usize - 21]; let ar = window_w / window_h; - // let colors: [[[f32; 3]; 2]; 2] = [ - // [ - // [146.0 / 255.0, 255.0 / 255.0, 48.0 / 255.0], - // [87.0 / 255.0, 183.0 / 255.0, 12.0 / 255.0], - // ], - // [ - // [118.0 / 255.0, 166.0 / 255.0, 211.0 / 255.0], - // [54.0 / 255.0, 109.0 / 255.0, 173.0 / 255.0], - // ], - // ]; - let colors: [[Color; 2]; 2] = [ - [ - Color::from_rgba8(93, 188, 255, 1.0), - Color::from_rgba8(48, 124, 255, 1.0), - ], - [ - Color::from_rgba8(210, 89, 222, 1.0), - Color::from_rgba8(125, 69, 134, 1.0), - ], - ]; + let color_shema = &target.state.config.color_shema; - let color = colors[note.track_id % 2]; - let color = if key.is_black { color[1] } else { color[0] }; + let color = &color_shema[note.track_id % color_shema.len()]; + let color = if key.is_black { color.dark } else { color.base }; + let color: Color = color.into(); let h = if note.duration >= 0.1 { note.duration diff --git a/src/wgpu_jumpstart/color.rs b/src/wgpu_jumpstart/color.rs index 57d8932c..fb468b7b 100644 --- a/src/wgpu_jumpstart/color.rs +++ b/src/wgpu_jumpstart/color.rs @@ -55,3 +55,9 @@ impl Color { ] } } + +impl From<(u8, u8, u8)> for Color { + fn from(f: (u8, u8, u8)) -> Self { + Self::from_rgba8(f.0, f.1, f.2, 1.0) + } +}