mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
randomize arrangement bg color
This commit is contained in:
parent
cd2a94d808
commit
cc578b0b52
3 changed files with 20 additions and 5 deletions
|
|
@ -33,7 +33,9 @@ pub struct Arrangement<E: Engine> {
|
|||
/// Display mode of arranger
|
||||
pub mode: ArrangementViewMode,
|
||||
/// Whether the arranger is currently focused
|
||||
pub focused: bool
|
||||
pub focused: bool,
|
||||
/// Background color of arrangement
|
||||
pub color: Color,
|
||||
}
|
||||
/// Represents a track in the arrangement
|
||||
pub struct ArrangementTrack<E: Engine> {
|
||||
|
|
@ -149,7 +151,8 @@ impl<E: Engine> Arrangement<E> {
|
|||
phrases: phrases.clone(),
|
||||
scenes: vec![],
|
||||
tracks: vec![],
|
||||
focused: false
|
||||
focused: false,
|
||||
color: Color::Rgb(28, 35, 25),
|
||||
}
|
||||
}
|
||||
pub fn activate (&mut self) {
|
||||
|
|
@ -277,7 +280,7 @@ impl<E: Engine> Arrangement<E> {
|
|||
}
|
||||
pub fn randomize_color (&mut self) {
|
||||
match self.selected {
|
||||
ArrangementFocus::Mix => {},
|
||||
ArrangementFocus::Mix => { self.color = random_color_dark() },
|
||||
ArrangementFocus::Track(t) => { self.tracks[t].color = random_color() },
|
||||
ArrangementFocus::Scene(s) => { self.scenes[s].color = random_color() },
|
||||
ArrangementFocus::Clip(t, s) => if let Some(phrase) = &self.scenes[s].clips[t] {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
|
|||
let tracks: &[ArrangementTrack<Tui>] = state.tracks.as_ref();
|
||||
let scenes: &[Scene] = state.scenes.as_ref();
|
||||
let offset = 3 + Scene::longest_name(scenes) as u16; // x of 1st track
|
||||
let bg = Color::Rgb(28, 35, 25);
|
||||
let bg = state.color;
|
||||
let clip_bg = Color::Rgb(40, 50, 30);
|
||||
let border_bg = Color::Rgb(40, 50, 30);
|
||||
let border_hi = Color::Rgb(100, 110, 40);
|
||||
|
|
|
|||
|
|
@ -36,11 +36,19 @@ tui_style!(WHITE_NOT_DIM_BOLD =
|
|||
pub fn random_okhsl () -> Okhsl<f32> {
|
||||
let mut rng = thread_rng();
|
||||
UniformOkhsl::new(
|
||||
Okhsl::new(-180.0, 0.01, 0.1),
|
||||
Okhsl::new(-180.0, 0.01, 0.2),
|
||||
Okhsl::new( 180.0, 0.9, 0.5),
|
||||
).sample(&mut rng)
|
||||
}
|
||||
|
||||
pub fn random_okhsl_dark () -> Okhsl<f32> {
|
||||
let mut rng = thread_rng();
|
||||
UniformOkhsl::new(
|
||||
Okhsl::new(-180.0, 0.01, 0.05),
|
||||
Okhsl::new( 180.0, 0.5, 0.2),
|
||||
).sample(&mut rng)
|
||||
}
|
||||
|
||||
pub fn okhsl_to_rgb (color: Okhsl<f32>) -> Color {
|
||||
let Srgb { red, green, blue, .. }: Srgb<f32> = Srgb::from_color_unclamped(color);
|
||||
Color::Rgb((red * 255.0) as u8, (green * 255.0) as u8, (blue * 255.0) as u8,)
|
||||
|
|
@ -50,6 +58,10 @@ pub fn random_color () -> Color {
|
|||
okhsl_to_rgb(random_okhsl())
|
||||
}
|
||||
|
||||
pub fn random_color_dark () -> Color {
|
||||
okhsl_to_rgb(random_okhsl_dark())
|
||||
}
|
||||
|
||||
pub fn random_color_near (color: Color, distance: f32) -> Color {
|
||||
let (r, g, b) = if let Color::Rgb(r, g, b) = color {
|
||||
(r, g, b)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue