// Copyright (c) 2022 Marceline Crmaer // SPDX-License-Identifier: AGPL-3.0-or-later use canary_script::Color; /// A reusable set of colors. Used by default widget styles. pub struct Palette { pub base: Color, pub base_hover: Color, pub base_active: Color, pub surface: Color, pub overlay: Color, pub text: Color, pub black: Color, pub red: Color, pub green: Color, pub yellow: Color, pub blue: Color, pub magenta: Color, pub cyan: Color, pub white: Color, } impl Palette { pub fn make_label_pairs(&self) -> Vec<(&'static str, Color)> { vec![ ("Base", self.base), ("Base Hover", self.base_hover), ("Base Active", self.base_active), ("Surface", self.surface), ("Overlay", self.overlay), ("Text", self.text), ("Black", self.black), ("Red", self.red), ("Green", self.green), ("Yellow", self.yellow), ("Blue", self.blue), ("Magenta", self.magenta), ("Cyan", self.cyan), ("White", self.white), ] } } /// The common base color alpha shared between all themes. pub const BASE_ALPHA: u8 = 230; /// The common base_hover color alpha shared between all themes. pub const BASE_HOVER_ALPHA: u8 = 242; /// Converts 0xrrggbb hex to an opaque [Color]. pub const fn hex(rgb: u32) -> Color { Color((rgb << 8) | 0xff) } /// Sword Art Online color palette. pub const SAO_PALETTE: Palette = Palette { base: Color::WHITE.with_alpha(BASE_ALPHA), base_hover: Color::WHITE.with_alpha(BASE_HOVER_ALPHA), base_active: Color::YELLOW, surface: Color::WHITE, overlay: Color::WHITE, text: Color::BLACK, black: Color::BLACK, red: Color::RED, green: Color::GREEN, yellow: Color::YELLOW, blue: Color::BLUE, magenta: Color::MAGENTA, cyan: Color::CYAN, white: Color::WHITE, }; /// Rose Pine color palette. pub const ROSE_PINE_PALETTE: Palette = Palette { base: hex(0x191724).with_alpha(BASE_ALPHA), base_hover: hex(0x21202ee0).with_alpha(BASE_HOVER_ALPHA), // Highlight Low base_active: hex(0x403d52), // Highlight Med surface: hex(0x1f1d2e), overlay: hex(0x26233a), text: hex(0xe0def4), black: hex(0x6e6a86), // Muted red: hex(0xeb6f92), // Love green: hex(0x7fb59f), // ??? (not in Rose Pine?) yellow: hex(0xf6c177), // Gold blue: hex(0x31748f), // Pine magenta: hex(0xc4a7e7), // Iris cyan: hex(0x9ccfd8), // Foam white: hex(0xe0def4), // Text }; /// Rose Pine Moon color palette. pub const ROSE_PINE_MOON_PALETTE: Palette = Palette { base: hex(0x232136).with_alpha(BASE_ALPHA), base_hover: hex(0x2a283e).with_alpha(BASE_HOVER_ALPHA), // Highlight Low base_active: hex(0x44415a), // Highlight Med surface: hex(0x2a273f), overlay: hex(0x393552), text: hex(0xe0def4), black: hex(0x6e6a86), // Muted red: hex(0xeb6f92), // Love green: hex(0x7fb59f), // ??? (not in Rose Pine?) yellow: hex(0xf6c177), // Gold blue: hex(0x3e8fb0), // Pine magenta: hex(0xc4a7e7), // Iris cyan: hex(0x9ccfd8), // Foam white: hex(0xe0def4), // Text }; /// [Arctica](https://github.com/sashakoshka/arctica) indexable color theme. pub const ARCTICA: [Color; 24] = [ hex(0x242933), hex(0x2e3440), hex(0x3b4252), hex(0x4c566a), hex(0xeceff4), hex(0xd8dee9), hex(0xc2c9d6), hex(0xaeb7c6), hex(0xa8555d), hex(0xb77763), hex(0xcdb179), hex(0x8ba277), hex(0x769b9b), hex(0x72a1ae), hex(0x5e81ac), hex(0x92738c), hex(0xbf616a), hex(0xd08770), hex(0xebcb8b), hex(0xa3be8c), hex(0x8fbcbb), hex(0x88c0d0), hex(0x81a1c1), hex(0xb48ead), ]; /// [Arctica](https://github.com/sashakoshka/arctica) color palette. pub const ARCTICA_PALETTE: Palette = Palette { base: ARCTICA[0].with_alpha(BASE_ALPHA), base_hover: ARCTICA[1].with_alpha(BASE_HOVER_ALPHA), base_active: ARCTICA[13], surface: ARCTICA[2], overlay: ARCTICA[3], text: ARCTICA[5], black: ARCTICA[3], red: ARCTICA[8], green: ARCTICA[11], yellow: ARCTICA[10], blue: ARCTICA[14], magenta: ARCTICA[15], cyan: ARCTICA[13], white: ARCTICA[7], }; /// Common measurements for widget shapes. pub struct Metrics { pub surface_rounding: f32, } /// Common default parameters for widget styles. pub struct Theme { pub palette: Palette, pub metrics: Metrics, } /// The global theme. pub const THEME: Theme = Theme { palette: ARCTICA_PALETTE, metrics: Metrics { surface_rounding: 5.0, }, };