Skip to content

Commit

Permalink
Playtime: Add matrix color palette
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Oct 26, 2023
1 parent 18c8da1 commit 562fcb1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions playtime-api/src/persistence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub struct Matrix {
pub clip_play_settings: MatrixClipPlaySettings,
pub clip_record_settings: MatrixClipRecordSettings,
pub common_tempo_range: TempoRange,
#[serde(skip_serializing_if = "Option::is_none")]
pub color_palette: Option<ColorPalette>,
}

#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, JsonSchema)]
Expand Down Expand Up @@ -81,6 +83,7 @@ pub struct MatrixSettings {
pub clip_play_settings: MatrixClipPlaySettings,
pub clip_record_settings: MatrixClipRecordSettings,
pub common_tempo_range: TempoRange,
pub color_palette: ColorPalette,
}

impl Matrix {
Expand Down Expand Up @@ -1236,6 +1239,39 @@ pub struct BeatTimeBase {
pub downbeat: PositiveBeat,
}

#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, JsonSchema)]
pub struct ColorPalette {
pub entries: Vec<ColorPaletteEntry>,
}

impl Default for ColorPalette {
fn default() -> Self {
Self {
entries: [
RgbColor(0x90, 0x6B, 0xFA),
RgbColor(0xD8, 0x6B, 0xFA),
RgbColor(0xEE, 0x65, 0xCB),
RgbColor(0xF3, 0x68, 0x89),
RgbColor(0xF3, 0x84, 0x5D),
RgbColor(0xF3, 0xD1, 0x61),
RgbColor(0x54, 0xD3, 0x62),
RgbColor(0x1E, 0xDF, 0xAD),
RgbColor(0x00, 0xB6, 0xF1),
RgbColor(0xAB, 0xCD, 0xFF),
RgbColor(0xD1, 0xE4, 0xFF),
]
.into_iter()
.map(|color| ColorPaletteEntry { color })
.collect(),
}
}
}

#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, JsonSchema)]
pub struct ColorPaletteEntry {
pub color: RgbColor,
}

#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize, JsonSchema)]
pub struct TimeSignature {
pub numerator: u32,
Expand Down

0 comments on commit 562fcb1

Please sign in to comment.