| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | use std::path::PathBuf; |
| 46 | use std::sync::atomic::{AtomicU8, AtomicU32, AtomicUsize, Ordering::Relaxed}; |
| 47 | use std::sync::{Mutex, RwLock}; |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | macro_rules! palette { |
| 60 | ($($name:ident: $ty:ty),+ $(,)?) => { |
| 61 | /// One family's numbers, in a struct so the set can be swapped whole. |
| 62 | /// Field names are the role names the whole editor already paints by, |
| 63 | /// which is why they shout. |
| 64 | #[allow(non_snake_case)] |
| 65 | #[derive(Clone, Copy, PartialEq, Debug)] |
| 66 | pub struct Palette { $(pub $name: $ty,)+ } |
| 67 | |
| 68 | /// The families in [`PaletteId::ALL`]'s order, so the index the atomic |
| 69 | /// holds is the id itself. |
| 70 | static PALETTES: [Palette; PaletteId::ALL.len()] = [ |
| 71 | Palette { $($name: cool::$name,)+ }, |
| 72 | Palette { $($name: warm::$name,)+ }, |
| 73 | Palette { $($name: forest::$name,)+ }, |
| 74 | Palette { $($name: violet::$name,)+ }, |
| 75 | Palette { $($name: rose::$name,)+ }, |
| 76 | Palette { $($name: amber::$name,)+ }, |
| 77 | Palette { $($name: ocean::$name,)+ }, |
| 78 | Palette { $($name: ice::$name,)+ }, |
| 79 | Palette { $($name: orchid::$name,)+ }, |
| 80 | Palette { $($name: nord::$name,)+ }, |
| 81 | Palette { $($name: gruvbox::$name,)+ }, |
| 82 | Palette { $($name: dracula::$name,)+ }, |
| 83 | Palette { $($name: darkroom::$name,)+ }, |
| 84 | ]; |
| 85 | |
| 86 | $( |
| 87 | #[allow(non_snake_case)] |
| 88 | // corner-cut: the Darkroom substrate roles (INK1.. SAFELIGHT_GLYPH) |
| 89 | |
| 90 | |
| 91 | |
| 92 | #[allow(dead_code)] |
| 93 | #[inline] |
| 94 | pub fn $name() -> $ty { palette().$name } |
| 95 | )+ |
| 96 | }; |
| 97 | } |
| 98 | |
| 99 | palette! { |
| 100 | BG_CANVAS: u32, |
| 101 | BG_PANEL: u32, |
| 102 | BG_RAISED: u32, |
| 103 | BG_TIMELINE: u32, |
| 104 | BG_HOVER: u32, |
| 105 | BG_HOVER_DIM: u32, |
| 106 | BG_SELECTED: u32, |
| 107 | SCRIM: u32, |
| 108 | SCRIM_LIGHT: u32, |
| 109 | STROKE_DIVIDER: u32, |
| 110 | STROKE_SELECTED: u32, |
| 111 | FG_PRIMARY: u32, |
| 112 | FG_SECONDARY: u32, |
| 113 | FG_DISABLED: u32, |
| 114 | ACCENT_PRIMARY: u32, |
| 115 | ACCENT_HOVER: u32, |
| 116 | ACCENT_PLAYHEAD: u32, |
| 117 | ACCENT_WASH: u32, |
| 118 | CLIP_VIDEO: u32, |
| 119 | CLIP_AUDIO: u32, |
| 120 | CLIP_IMAGE: u32, |
| 121 | CLIP_TEXT: u32, |
| 122 | SOURCE_TINTS: [u32; 12], |
| 123 | STATUS_ERROR: u32, |
| 124 | STATUS_WARNING: u32, |
| 125 | STATUS_SUCCESS: u32, |
| 126 | STATUS_PROGRESS: u32, |
| 127 | DROP_REFUSE: u32, |
| 128 | SUB_FG: u32, |
| 129 | SUB_SHADE: u32, |
| 130 | EQ_GRID: u32, |
| 131 | EQ_SPECTRUM_INK: u32, |
| 132 | EQ_FILL_INK: u32, |
| 133 | EQ_BELL_INK: u32, |
| 134 | HIST_INK: [u32; 3], |
| 135 | |
| 136 | INK1: u32, |
| 137 | INK2: u32, |
| 138 | INK3: u32, |
| 139 | INK4: u32, |
| 140 | DARK_CANVAS: u32, |
| 141 | DARK_PANEL: u32, |
| 142 | DARK_RAISED: u32, |
| 143 | DARK_HAIRLINE: u32, |
| 144 | DARK_EDGE: u32, |
| 145 | DARK_SEAM: u32, |
| 146 | LAMP_WHITE: u32, |
| 147 | NOTICE_TELL: u32, |
| 148 | NOTICE_LOOK: u32, |
| 149 | NOTICE_DECIDE: u32, |
| 150 | SAFELIGHT_GROUND: u32, |
| 151 | SAFELIGHT_GLYPH: u32, |
| 152 | } |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 158 | pub enum PaletteId { |
| 159 | Cool, |
| 160 | Warm, |
| 161 | Forest, |
| 162 | Violet, |
| 163 | Rose, |
| 164 | Amber, |
| 165 | Ocean, |
| 166 | Ice, |
| 167 | Orchid, |
| 168 | Nord, |
| 169 | Gruvbox, |
| 170 | Dracula, |
| 171 | Darkroom, |
| 172 | } |
| 173 | |
| 174 | impl PaletteId { |
| 175 | |
| 176 | |
| 177 | pub const DEFAULT: PaletteId = PaletteId::Darkroom; |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | pub const ALL: [PaletteId; 13] = [ |
| 183 | PaletteId::Cool, |
| 184 | PaletteId::Warm, |
| 185 | PaletteId::Forest, |
| 186 | PaletteId::Violet, |
| 187 | PaletteId::Rose, |
| 188 | PaletteId::Amber, |
| 189 | PaletteId::Ocean, |
| 190 | PaletteId::Ice, |
| 191 | PaletteId::Orchid, |
| 192 | PaletteId::Nord, |
| 193 | PaletteId::Gruvbox, |
| 194 | PaletteId::Dracula, |
| 195 | PaletteId::Darkroom, |
| 196 | ]; |
| 197 | |
| 198 | |
| 199 | pub fn label(self) -> &'static str { |
| 200 | match self { |
| 201 | PaletteId::Cool => "Cool", |
| 202 | PaletteId::Warm => "Warm", |
| 203 | PaletteId::Forest => "Forest", |
| 204 | PaletteId::Violet => "Violet", |
| 205 | PaletteId::Rose => "Rose", |
| 206 | PaletteId::Amber => "Amber", |
| 207 | PaletteId::Ocean => "Ocean", |
| 208 | PaletteId::Ice => "Ice", |
| 209 | PaletteId::Orchid => "Orchid", |
| 210 | PaletteId::Nord => "Nord", |
| 211 | PaletteId::Gruvbox => "Gruvbox", |
| 212 | PaletteId::Dracula => "Dracula", |
| 213 | PaletteId::Darkroom => "Darkroom", |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | pub fn detail(self) -> &'static str { |
| 223 | match self { |
| 224 | PaletteId::Cool => "Black with cyan", |
| 225 | PaletteId::Warm => "Warm grey with coral", |
| 226 | PaletteId::Forest => "Dark green with emerald", |
| 227 | PaletteId::Violet => "Indigo with lavender", |
| 228 | PaletteId::Rose => "Grey with rose", |
| 229 | PaletteId::Amber => "Graphite with gold", |
| 230 | PaletteId::Ocean => "Blue-black with azure", |
| 231 | PaletteId::Ice => "Navy black with pale blue", |
| 232 | PaletteId::Orchid => "Plum with orchid", |
| 233 | PaletteId::Nord => "Blue-grey with frost", |
| 234 | PaletteId::Gruvbox => "Brown with orange", |
| 235 | PaletteId::Dracula => "Purple-grey with pink", |
| 236 | PaletteId::Darkroom => "Dark with sage green", |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | |
| 241 | |
| 242 | pub fn name(self) -> &'static str { |
| 243 | match self { |
| 244 | PaletteId::Cool => "cool", |
| 245 | PaletteId::Warm => "warm", |
| 246 | PaletteId::Forest => "forest", |
| 247 | PaletteId::Violet => "violet", |
| 248 | PaletteId::Rose => "rose", |
| 249 | PaletteId::Amber => "amber", |
| 250 | PaletteId::Ocean => "ocean", |
| 251 | PaletteId::Ice => "ice", |
| 252 | PaletteId::Orchid => "orchid", |
| 253 | PaletteId::Nord => "nord", |
| 254 | PaletteId::Gruvbox => "gruvbox", |
| 255 | PaletteId::Dracula => "dracula", |
| 256 | PaletteId::Darkroom => "darkroom", |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | fn from_name(name: &str) -> Option<Self> { |
| 261 | Self::ALL.into_iter().find(|p| p.name() == name) |
| 262 | } |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | #[cfg(test)] |
| 268 | pub fn palette(self) -> &'static Palette { |
| 269 | &PALETTES[self as usize] |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | static ACTIVE: AtomicUsize = AtomicUsize::new(PaletteId::DEFAULT as usize); |
| 278 | |
| 279 | |
| 280 | |
| 281 | #[inline] |
| 282 | pub fn palette() -> &'static Palette { |
| 283 | PALETTES |
| 284 | .get(ACTIVE.load(Relaxed)) |
| 285 | .unwrap_or(&PALETTES[PaletteId::DEFAULT as usize]) |
| 286 | } |
| 287 | |
| 288 | |
| 289 | pub fn active() -> PaletteId { |
| 290 | PaletteId::ALL |
| 291 | .get(ACTIVE.load(Relaxed)) |
| 292 | .copied() |
| 293 | .unwrap_or(PaletteId::DEFAULT) |
| 294 | } |
| 295 | |
| 296 | |
| 297 | |
| 298 | pub fn set(id: PaletteId) { |
| 299 | ACTIVE.store(id as usize, Relaxed); |
| 300 | } |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 307 | pub enum AccentId { |
| 308 | Sage, |
| 309 | Ocean, |
| 310 | Plum, |
| 311 | Rose, |
| 312 | Ochre, |
| 313 | Gold, |
| 314 | Custom, |
| 315 | } |
| 316 | |
| 317 | |
| 318 | pub const CUSTOM_DEFAULT: u32 = 0xd49ae0; |
| 319 | |
| 320 | pub const VIVID_DESIGNED: u8 = 50; |
| 321 | |
| 322 | pub const VIVID_DEFAULT: u8 = 100; |
| 323 | |
| 324 | impl AccentId { |
| 325 | pub const DEFAULT: AccentId = AccentId::Sage; |
| 326 | pub const ALL: [AccentId; 7] = [ |
| 327 | AccentId::Sage, |
| 328 | AccentId::Ocean, |
| 329 | AccentId::Plum, |
| 330 | AccentId::Rose, |
| 331 | AccentId::Ochre, |
| 332 | AccentId::Gold, |
| 333 | AccentId::Custom, |
| 334 | ]; |
| 335 | |
| 336 | pub fn label(self) -> &'static str { |
| 337 | match self { |
| 338 | AccentId::Sage => "Sage", |
| 339 | AccentId::Ocean => "Ocean", |
| 340 | AccentId::Plum => "Plum", |
| 341 | AccentId::Rose => "Rose", |
| 342 | AccentId::Ochre => "Ochre", |
| 343 | AccentId::Gold => "Gold", |
| 344 | AccentId::Custom => "Custom", |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | |
| 349 | pub fn name(self) -> &'static str { |
| 350 | match self { |
| 351 | AccentId::Sage => "sage", |
| 352 | AccentId::Ocean => "ocean", |
| 353 | AccentId::Plum => "plum", |
| 354 | AccentId::Rose => "rose", |
| 355 | AccentId::Ochre => "ochre", |
| 356 | AccentId::Gold => "gold", |
| 357 | AccentId::Custom => "custom", |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | |
| 362 | |
| 363 | pub fn from_name(name: &str) -> Option<Self> { |
| 364 | match name { |
| 365 | "slate" => Some(AccentId::Gold), |
| 366 | _ => Self::ALL.into_iter().find(|a| a.name() == name), |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | |
| 371 | |
| 372 | pub fn base(self, custom: u32) -> (u32, u32, u32) { |
| 373 | match self { |
| 374 | AccentId::Sage => (0x9dbea2, 0xb5d2b9, 0x0f1510), |
| 375 | AccentId::Ocean => (0x86b9dd, 0x9fcbea, 0x061118), |
| 376 | AccentId::Plum => (0xbba9e0, 0xcbbceb, 0x110d18), |
| 377 | AccentId::Rose => (0xe79dad, 0xf3b2c0, 0x190a0e), |
| 378 | AccentId::Ochre => (0xd8a98a, 0xe4bca1, 0x170d07), |
| 379 | AccentId::Gold => (0xe3d372, 0xf7ea9b, 0x191606), |
| 380 | AccentId::Custom => { |
| 381 | let (l, c, h) = to_oklch(custom); |
| 382 | (custom, from_oklch((l + 0.06).min(1.), c * 0.9, h), from_oklch(0.17, c.min(0.03), h)) |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | |
| 388 | pub fn colours(self) -> (u32, u32, u32) { |
| 389 | self.base(custom_colour().unwrap_or(CUSTOM_DEFAULT)) |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | |
| 394 | pub fn swatch(a: AccentId) -> u32 { |
| 395 | vivid_adjust(a.colours().0, vivid()) |
| 396 | } |
| 397 | |
| 398 | |
| 399 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 400 | pub struct AccentSpec { |
| 401 | pub id: AccentId, |
| 402 | pub vivid: u8, |
| 403 | pub custom: u32, |
| 404 | } |
| 405 | |
| 406 | impl AccentSpec { |
| 407 | #[cfg(test)] |
| 408 | pub const DEFAULT: AccentSpec = AccentSpec { id: AccentId::DEFAULT, vivid: VIVID_DEFAULT, custom: CUSTOM_DEFAULT }; |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | fn apply(self, mut t: Tokens) -> Tokens { |
| 415 | let (base, base_hover, ink) = self.id.base(self.custom); |
| 416 | let accent = vivid_adjust(base, self.vivid); |
| 417 | let hover = match accent == base { |
| 418 | true => base_hover, |
| 419 | false => vivid_adjust(base_hover, self.vivid), |
| 420 | }; |
| 421 | let press = mix(accent, 0x000000, 0.15); |
| 422 | let score = |ink: u32| contrast(ink, accent).min(contrast(ink, press)); |
| 423 | t.accent = accent; |
| 424 | t.accent_hover = hover; |
| 425 | t.accent_press = press; |
| 426 | t.accent_fill = accent; |
| 427 | t.on_accent = match score(ink) >= score(0xffffff) { |
| 428 | true => ink, |
| 429 | false => 0xffffff, |
| 430 | }; |
| 431 | t.accent_wash = with_alpha(accent, 0x33); |
| 432 | t.range_tint = with_alpha(accent, 0x1a); |
| 433 | t |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | |
| 438 | |
| 439 | fn srgb_to_lin(c: f64) -> f64 { |
| 440 | if c <= 0.04045 { c / 12.92 } else { ((c + 0.055) / 1.055).powf(2.4) } |
| 441 | } |
| 442 | |
| 443 | fn lin_to_srgb(x: f64) -> f64 { |
| 444 | if x <= 0.0031308 { x * 12.92 } else { 1.055 * x.powf(1. / 2.4) - 0.055 } |
| 445 | } |
| 446 | |
| 447 | |
| 448 | pub fn to_oklch(rgb: u32) -> (f64, f64, f64) { |
| 449 | let ch = |s: u32| srgb_to_lin(f64::from((rgb >> s) & 0xff) / 255.); |
| 450 | let (r, g, b) = (ch(16), ch(8), ch(0)); |
| 451 | let l = (0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b).cbrt(); |
| 452 | let m = (0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b).cbrt(); |
| 453 | let s = (0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b).cbrt(); |
| 454 | let big_l = 0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s; |
| 455 | let a = 1.9779984951 * l - 2.4285922050 * m + 0.4505937099 * s; |
| 456 | let bb = 0.0259040371 * l + 0.7827717662 * m - 0.8086757660 * s; |
| 457 | (big_l, a.hypot(bb), bb.atan2(a).to_degrees().rem_euclid(360.)) |
| 458 | } |
| 459 | |
| 460 | |
| 461 | fn oklch_lin(l: f64, c: f64, h: f64) -> (f64, f64, f64) { |
| 462 | let (a, b) = (c * h.to_radians().cos(), c * h.to_radians().sin()); |
| 463 | let l_ = (l + 0.3963377774 * a + 0.2158037573 * b).powi(3); |
| 464 | let m_ = (l - 0.1055613458 * a - 0.0638541728 * b).powi(3); |
| 465 | let s_ = (l - 0.0894841775 * a - 1.2914855480 * b).powi(3); |
| 466 | ( |
| 467 | 4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_, |
| 468 | -1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_, |
| 469 | -0.0041960863 * l_ - 0.7034186147 * m_ + 1.7076147010 * s_, |
| 470 | ) |
| 471 | } |
| 472 | |
| 473 | |
| 474 | |
| 475 | pub fn from_oklch(l: f64, c: f64, h: f64) -> u32 { |
| 476 | let l = l.clamp(0., 1.); |
| 477 | let fits = |c: f64| { |
| 478 | let (r, g, b) = oklch_lin(l, c, h); |
| 479 | [r, g, b].iter().all(|v| (-0.0005..=1.0005).contains(v)) |
| 480 | }; |
| 481 | let mut c = c.max(0.); |
| 482 | if !fits(c) { |
| 483 | let (mut lo, mut hi) = (0., c); |
| 484 | for _ in 0..24 { |
| 485 | let mid = (lo + hi) / 2.; |
| 486 | match fits(mid) { |
| 487 | true => lo = mid, |
| 488 | false => hi = mid, |
| 489 | } |
| 490 | } |
| 491 | c = lo; |
| 492 | } |
| 493 | let (r, g, b) = oklch_lin(l, c, h); |
| 494 | let byte = |v: f64| (lin_to_srgb(v.clamp(0., 1.)) * 255.).round() as u32; |
| 495 | byte(r) << 16 | byte(g) << 8 | byte(b) |
| 496 | } |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | pub fn vivid_adjust(rgb: u32, vivid: u8) -> u32 { |
| 502 | if vivid == VIVID_DESIGNED { |
| 503 | return rgb; |
| 504 | } |
| 505 | let (l, c, h) = to_oklch(rgb); |
| 506 | let v = f64::from(vivid.min(100)); |
| 507 | let c = match v < 50. { |
| 508 | true => c * (0.08 + 0.92 * v / 50.), |
| 509 | false => c + (v - 50.) / 50. * ((c * 3.).max(0.17) - c), |
| 510 | }; |
| 511 | from_oklch(l, c, h) |
| 512 | } |
| 513 | |
| 514 | |
| 515 | pub fn parse_hex(text: &str) -> Option<u32> { |
| 516 | let t = text.trim().trim_start_matches('#'); |
| 517 | match t.len() == 6 && t.chars().all(|c| c.is_ascii_hexdigit()) { |
| 518 | true => u32::from_str_radix(t, 16).ok(), |
| 519 | false => None, |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | |
| 524 | static ACCENT: AtomicUsize = AtomicUsize::new(AccentId::DEFAULT as usize); |
| 525 | static VIVID: AtomicU8 = AtomicU8::new(VIVID_DEFAULT); |
| 526 | |
| 527 | static CUSTOM: AtomicU32 = AtomicU32::new(u32::MAX); |
| 528 | |
| 529 | pub fn accent() -> AccentId { |
| 530 | AccentId::ALL.get(ACCENT.load(Relaxed)).copied().unwrap_or(AccentId::DEFAULT) |
| 531 | } |
| 532 | |
| 533 | pub fn vivid() -> u8 { |
| 534 | VIVID.load(Relaxed) |
| 535 | } |
| 536 | |
| 537 | |
| 538 | pub fn custom_colour() -> Option<u32> { |
| 539 | Some(CUSTOM.load(Relaxed)).filter(|c| *c <= 0xffffff) |
| 540 | } |
| 541 | |
| 542 | fn spec_in_force() -> AccentSpec { |
| 543 | AccentSpec { id: accent(), vivid: vivid(), custom: custom_colour().unwrap_or(CUSTOM_DEFAULT) } |
| 544 | } |
| 545 | |
| 546 | |
| 547 | |
| 548 | pub fn set_accent(a: AccentId) { |
| 549 | if a == AccentId::Custom && custom_colour().is_none() { |
| 550 | CUSTOM.store(CUSTOM_DEFAULT, Relaxed); |
| 551 | } |
| 552 | ACCENT.store(a as usize, Relaxed); |
| 553 | refresh(); |
| 554 | } |
| 555 | |
| 556 | pub fn set_vivid(v: u8) { |
| 557 | VIVID.store(v.min(100), Relaxed); |
| 558 | refresh(); |
| 559 | } |
| 560 | |
| 561 | |
| 562 | pub fn set_custom(rgb: u32) { |
| 563 | CUSTOM.store(rgb & 0xffffff, Relaxed); |
| 564 | ACCENT.store(AccentId::Custom as usize, Relaxed); |
| 565 | refresh(); |
| 566 | } |
| 567 | |
| 568 | |
| 569 | pub fn accent_path() -> PathBuf { |
| 570 | config_path().with_file_name("accent") |
| 571 | } |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | pub fn parse_accent(text: &str) -> (AccentId, u8, Option<u32>) { |
| 577 | let (mut id, mut vivid, mut custom) = (AccentId::DEFAULT, VIVID_DEFAULT, None); |
| 578 | for line in text.lines().map(str::trim) { |
| 579 | match line.split_once('=') { |
| 580 | Some(("accent", v)) => id = AccentId::from_name(v.trim()).unwrap_or(id), |
| 581 | Some(("vivid", v)) => vivid = v.trim().parse::<u32>().map_or(vivid, |n| n.min(100) as u8), |
| 582 | Some(("custom", v)) => custom = parse_hex(v).or(custom), |
| 583 | None => id = AccentId::from_name(line).unwrap_or(id), |
| 584 | _ => {} |
| 585 | } |
| 586 | } |
| 587 | (id, vivid, custom) |
| 588 | } |
| 589 | |
| 590 | |
| 591 | pub fn accent_text() -> String { |
| 592 | let mut text = format!("accent={}\nvivid={}\n", accent().name(), vivid()); |
| 593 | if let Some(c) = custom_colour() { |
| 594 | text.push_str(&format!("custom=#{c:06x}\n")); |
| 595 | } |
| 596 | text |
| 597 | } |
| 598 | |
| 599 | |
| 600 | pub fn load_accent() { |
| 601 | if let Ok(text) = std::fs::read_to_string(accent_path()) { |
| 602 | let (id, vivid, custom) = parse_accent(&text); |
| 603 | if let Some(c) = custom { |
| 604 | CUSTOM.store(c, Relaxed); |
| 605 | } |
| 606 | VIVID.store(vivid, Relaxed); |
| 607 | set_accent(id); |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | |
| 612 | pub fn save_accent() -> std::io::Result<()> { |
| 613 | let path = accent_path(); |
| 614 | if let Some(dir) = path.parent() { |
| 615 | std::fs::create_dir_all(dir)?; |
| 616 | } |
| 617 | std::fs::write(path, accent_text()) |
| 618 | } |
| 619 | |
| 620 | |
| 621 | |
| 622 | pub fn config_path() -> PathBuf { |
| 623 | crate::keymap::Keymap::config_path().with_file_name("theme") |
| 624 | } |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | pub fn load() { |
| 630 | if let Ok(text) = std::fs::read_to_string(config_path()) |
| 631 | && let Some(id) = PaletteId::from_name(text.trim()) |
| 632 | { |
| 633 | set(id); |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | |
| 638 | |
| 639 | pub fn save(id: PaletteId) -> std::io::Result<()> { |
| 640 | let path = config_path(); |
| 641 | if let Some(dir) = path.parent() { |
| 642 | std::fs::create_dir_all(dir)?; |
| 643 | } |
| 644 | std::fs::write(path, format!("{}\n", id.name())) |
| 645 | } |
| 646 | |
| 647 | |
| 648 | pub mod cool { |
| 649 | |
| 650 | |
| 651 | |
| 652 | pub const BG_CANVAS: u32 = 0x0b0d10; |
| 653 | |
| 654 | pub const BG_PANEL: u32 = 0x151a21; |
| 655 | |
| 656 | |
| 657 | pub const BG_RAISED: u32 = 0x212936; |
| 658 | |
| 659 | pub const BG_TIMELINE: u32 = 0x0e1218; |
| 660 | |
| 661 | |
| 662 | pub const BG_HOVER: u32 = 0x2f3a4a; |
| 663 | |
| 664 | |
| 665 | pub const BG_HOVER_DIM: u32 = 0x1d2531; |
| 666 | |
| 667 | |
| 668 | pub const BG_SELECTED: u32 = 0x0d4b5c; |
| 669 | |
| 670 | |
| 671 | pub const SCRIM: u32 = 0x0b0d10cc; |
| 672 | |
| 673 | |
| 674 | pub const SCRIM_LIGHT: u32 = 0x0b0d1055; |
| 675 | |
| 676 | |
| 677 | pub const STROKE_DIVIDER: u32 = 0x2a3442; |
| 678 | pub const STROKE_SELECTED: u32 = 0x22d3ee; |
| 679 | |
| 680 | |
| 681 | pub const FG_PRIMARY: u32 = 0xe9eff7; |
| 682 | |
| 683 | |
| 684 | pub const FG_SECONDARY: u32 = 0xa7b6c9; |
| 685 | pub const FG_DISABLED: u32 = 0x6c7a8b; |
| 686 | |
| 687 | |
| 688 | pub const ACCENT_PRIMARY: u32 = 0x22d3ee; |
| 689 | |
| 690 | pub const ACCENT_HOVER: u32 = 0x67e8f9; |
| 691 | |
| 692 | |
| 693 | pub const ACCENT_PLAYHEAD: u32 = 0xff9db0; |
| 694 | |
| 695 | pub const ACCENT_WASH: u32 = 0x22d3eeaa; |
| 696 | |
| 697 | |
| 698 | pub const CLIP_VIDEO: u32 = 0x2b5fa8; |
| 699 | pub const CLIP_AUDIO: u32 = 0x276b43; |
| 700 | pub const CLIP_IMAGE: u32 = 0x1a6a6a; |
| 701 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 702 | |
| 703 | |
| 704 | |
| 705 | |
| 706 | |
| 707 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 708 | 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, |
| 709 | 0xd69a4f, 0x4fd6a8, 0xb14fd6, |
| 710 | ]; |
| 711 | |
| 712 | |
| 713 | pub const STATUS_ERROR: u32 = 0xef4444; |
| 714 | pub const STATUS_WARNING: u32 = 0xf59e0b; |
| 715 | pub const STATUS_SUCCESS: u32 = 0x34d399; |
| 716 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 717 | |
| 718 | |
| 719 | pub const DROP_REFUSE: u32 = 0x8f2740; |
| 720 | |
| 721 | |
| 722 | pub const SUB_FG: u32 = 0xffffff; |
| 723 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 724 | |
| 725 | |
| 726 | pub const EQ_GRID: u32 = 0x2a3442; |
| 727 | pub const EQ_SPECTRUM_INK: u32 = 0x7f95ad66; |
| 728 | pub const EQ_FILL_INK: u32 = 0x22d3ee26; |
| 729 | pub const EQ_BELL_INK: u32 = 0x22d3ee66; |
| 730 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 731 | |
| 732 | pub const INK1: u32 = FG_PRIMARY; |
| 733 | pub const INK2: u32 = FG_SECONDARY; |
| 734 | pub const INK3: u32 = 0x98a2af; |
| 735 | pub const INK4: u32 = FG_DISABLED; |
| 736 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 737 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 738 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 739 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 740 | pub const DARK_EDGE: u32 = INK3; |
| 741 | pub const DARK_SEAM: u32 = SCRIM; |
| 742 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 743 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 744 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 745 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 746 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 747 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 748 | } |
| 749 | |
| 750 | |
| 751 | |
| 752 | |
| 753 | pub mod warm { |
| 754 | |
| 755 | pub const BG_CANVAS: u32 = 0x0c0a09; |
| 756 | pub const BG_PANEL: u32 = 0x1d1917; |
| 757 | pub const BG_RAISED: u32 = 0x383029; |
| 758 | pub const BG_TIMELINE: u32 = 0x151211; |
| 759 | pub const BG_HOVER: u32 = 0x4a413b; |
| 760 | pub const BG_HOVER_DIM: u32 = 0x241f1d; |
| 761 | |
| 762 | |
| 763 | |
| 764 | pub const BG_SELECTED: u32 = 0x6a3118; |
| 765 | pub const SCRIM: u32 = 0x0c0a09cc; |
| 766 | pub const SCRIM_LIGHT: u32 = 0x0c0a0955; |
| 767 | |
| 768 | |
| 769 | pub const STROKE_DIVIDER: u32 = 0x3a322e; |
| 770 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 771 | |
| 772 | |
| 773 | pub const FG_PRIMARY: u32 = 0xf2ece6; |
| 774 | pub const FG_SECONDARY: u32 = 0xbdb1a8; |
| 775 | pub const FG_DISABLED: u32 = 0x8a7f78; |
| 776 | |
| 777 | |
| 778 | pub const ACCENT_PRIMARY: u32 = 0xff7a45; |
| 779 | pub const ACCENT_HOVER: u32 = 0xff9a6e; |
| 780 | |
| 781 | |
| 782 | pub const ACCENT_PLAYHEAD: u32 = 0xffc23a; |
| 783 | pub const ACCENT_WASH: u32 = 0xff7a45aa; |
| 784 | |
| 785 | |
| 786 | pub const CLIP_VIDEO: u32 = 0x2b4c7e; |
| 787 | pub const CLIP_AUDIO: u32 = 0x2c5a3a; |
| 788 | pub const CLIP_IMAGE: u32 = 0x1f5560; |
| 789 | pub const CLIP_TEXT: u32 = 0x4a3070; |
| 790 | |
| 791 | |
| 792 | |
| 793 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 794 | 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, |
| 795 | 0x4fa8d6, 0x8fc94f, 0xd67aa8, |
| 796 | ]; |
| 797 | |
| 798 | |
| 799 | pub const STATUS_ERROR: u32 = 0xc85050; |
| 800 | pub const STATUS_WARNING: u32 = 0xe0a53a; |
| 801 | pub const STATUS_SUCCESS: u32 = 0x4fbf72; |
| 802 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 803 | pub const DROP_REFUSE: u32 = 0x8a2f24; |
| 804 | |
| 805 | |
| 806 | pub const SUB_FG: u32 = 0xffffff; |
| 807 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 808 | |
| 809 | |
| 810 | pub const EQ_GRID: u32 = 0x4a413b; |
| 811 | pub const EQ_SPECTRUM_INK: u32 = 0xbdb1a866; |
| 812 | pub const EQ_FILL_INK: u32 = 0xff7a4526; |
| 813 | pub const EQ_BELL_INK: u32 = 0xff7a4566; |
| 814 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 815 | |
| 816 | pub const INK1: u32 = FG_PRIMARY; |
| 817 | pub const INK2: u32 = FG_SECONDARY; |
| 818 | pub const INK3: u32 = 0xaca5a0; |
| 819 | pub const INK4: u32 = FG_DISABLED; |
| 820 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 821 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 822 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 823 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 824 | pub const DARK_EDGE: u32 = INK3; |
| 825 | pub const DARK_SEAM: u32 = SCRIM; |
| 826 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 827 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 828 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 829 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 830 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 831 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 832 | } |
| 833 | |
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | pub mod forest { |
| 839 | |
| 840 | pub const BG_CANVAS: u32 = 0x080d0a; |
| 841 | pub const BG_PANEL: u32 = 0x121b16; |
| 842 | pub const BG_RAISED: u32 = 0x1e2c24; |
| 843 | pub const BG_TIMELINE: u32 = 0x0b1310; |
| 844 | pub const BG_HOVER: u32 = 0x2c4034; |
| 845 | pub const BG_HOVER_DIM: u32 = 0x1a2620; |
| 846 | |
| 847 | |
| 848 | |
| 849 | pub const BG_SELECTED: u32 = 0x14503a; |
| 850 | pub const SCRIM: u32 = 0x080d0acc; |
| 851 | pub const SCRIM_LIGHT: u32 = 0x080d0a55; |
| 852 | |
| 853 | |
| 854 | pub const STROKE_DIVIDER: u32 = 0x25362c; |
| 855 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 856 | |
| 857 | |
| 858 | pub const FG_PRIMARY: u32 = 0xe7f3eb; |
| 859 | pub const FG_SECONDARY: u32 = 0xa8c4b4; |
| 860 | pub const FG_DISABLED: u32 = 0x6e8579; |
| 861 | |
| 862 | |
| 863 | pub const ACCENT_PRIMARY: u32 = 0x34d399; |
| 864 | pub const ACCENT_HOVER: u32 = 0x6ee7b7; |
| 865 | pub const ACCENT_PLAYHEAD: u32 = 0xff9db0; |
| 866 | pub const ACCENT_WASH: u32 = 0x34d399aa; |
| 867 | |
| 868 | |
| 869 | pub const CLIP_VIDEO: u32 = 0x2b5fa8; |
| 870 | |
| 871 | |
| 872 | |
| 873 | pub const CLIP_AUDIO: u32 = 0x256b44; |
| 874 | pub const CLIP_IMAGE: u32 = 0x1a6a6a; |
| 875 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 876 | |
| 877 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 878 | 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, |
| 879 | 0xd6a45f, 0x5fa8d6, 0xc15fd6, |
| 880 | ]; |
| 881 | |
| 882 | |
| 883 | |
| 884 | |
| 885 | pub const STATUS_ERROR: u32 = 0xf07171; |
| 886 | pub const STATUS_WARNING: u32 = 0xe3b341; |
| 887 | pub const STATUS_SUCCESS: u32 = 0x7bd88f; |
| 888 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 889 | pub const DROP_REFUSE: u32 = 0x7a2a33; |
| 890 | |
| 891 | |
| 892 | pub const SUB_FG: u32 = 0xffffff; |
| 893 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 894 | |
| 895 | |
| 896 | pub const EQ_GRID: u32 = 0x25362c; |
| 897 | pub const EQ_SPECTRUM_INK: u32 = 0xa8c4b466; |
| 898 | pub const EQ_FILL_INK: u32 = 0x34d39926; |
| 899 | pub const EQ_BELL_INK: u32 = 0x34d39966; |
| 900 | |
| 901 | |
| 902 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 903 | |
| 904 | pub const INK1: u32 = FG_PRIMARY; |
| 905 | pub const INK2: u32 = FG_SECONDARY; |
| 906 | pub const INK3: u32 = 0x95a79e; |
| 907 | pub const INK4: u32 = FG_DISABLED; |
| 908 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 909 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 910 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 911 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 912 | pub const DARK_EDGE: u32 = INK3; |
| 913 | pub const DARK_SEAM: u32 = SCRIM; |
| 914 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 915 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 916 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 917 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 918 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 919 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 920 | } |
| 921 | |
| 922 | |
| 923 | |
| 924 | |
| 925 | pub mod violet { |
| 926 | |
| 927 | pub const BG_CANVAS: u32 = 0x0a0a12; |
| 928 | pub const BG_PANEL: u32 = 0x171827; |
| 929 | pub const BG_RAISED: u32 = 0x252842; |
| 930 | pub const BG_TIMELINE: u32 = 0x0e0f1b; |
| 931 | pub const BG_HOVER: u32 = 0x353a5e; |
| 932 | pub const BG_HOVER_DIM: u32 = 0x1f2138; |
| 933 | pub const BG_SELECTED: u32 = 0x3b2a78; |
| 934 | pub const SCRIM: u32 = 0x0a0a12cc; |
| 935 | pub const SCRIM_LIGHT: u32 = 0x0a0a1255; |
| 936 | |
| 937 | |
| 938 | pub const STROKE_DIVIDER: u32 = 0x2e3150; |
| 939 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 940 | |
| 941 | |
| 942 | pub const FG_PRIMARY: u32 = 0xeceafb; |
| 943 | pub const FG_SECONDARY: u32 = 0xb6b4d8; |
| 944 | pub const FG_DISABLED: u32 = 0x7b79a0; |
| 945 | |
| 946 | |
| 947 | pub const ACCENT_PRIMARY: u32 = 0xa78bfa; |
| 948 | pub const ACCENT_HOVER: u32 = 0xc4b5fd; |
| 949 | pub const ACCENT_PLAYHEAD: u32 = 0xfacc15; |
| 950 | pub const ACCENT_WASH: u32 = 0xa78bfaaa; |
| 951 | |
| 952 | |
| 953 | pub const CLIP_VIDEO: u32 = 0x2f5a9e; |
| 954 | pub const CLIP_AUDIO: u32 = 0x2c6b49; |
| 955 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 956 | |
| 957 | |
| 958 | pub const CLIP_TEXT: u32 = 0x6d3fa8; |
| 959 | |
| 960 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 961 | 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, |
| 962 | 0xe8a97f, 0x7fc8e8, 0xe87fb4, |
| 963 | ]; |
| 964 | |
| 965 | |
| 966 | pub const STATUS_ERROR: u32 = 0xf87171; |
| 967 | pub const STATUS_WARNING: u32 = 0xfbbf24; |
| 968 | pub const STATUS_SUCCESS: u32 = 0x6ee7b7; |
| 969 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 970 | pub const DROP_REFUSE: u32 = 0x7c2440; |
| 971 | |
| 972 | |
| 973 | pub const SUB_FG: u32 = 0xffffff; |
| 974 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 975 | |
| 976 | |
| 977 | pub const EQ_GRID: u32 = 0x2e3150; |
| 978 | pub const EQ_SPECTRUM_INK: u32 = 0xb6b4d866; |
| 979 | pub const EQ_FILL_INK: u32 = 0xa78bfa26; |
| 980 | pub const EQ_BELL_INK: u32 = 0xa78bfa66; |
| 981 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 982 | |
| 983 | pub const INK1: u32 = FG_PRIMARY; |
| 984 | pub const INK2: u32 = FG_SECONDARY; |
| 985 | pub const INK3: u32 = 0xa4a3be; |
| 986 | pub const INK4: u32 = FG_DISABLED; |
| 987 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 988 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 989 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 990 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 991 | pub const DARK_EDGE: u32 = INK3; |
| 992 | pub const DARK_SEAM: u32 = SCRIM; |
| 993 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 994 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 995 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 996 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 997 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 998 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 999 | } |
| 1000 | |
| 1001 | |
| 1002 | |
| 1003 | |
| 1004 | pub mod rose { |
| 1005 | |
| 1006 | pub const BG_CANVAS: u32 = 0x0c0b0c; |
| 1007 | pub const BG_PANEL: u32 = 0x1a181a; |
| 1008 | pub const BG_RAISED: u32 = 0x2a272a; |
| 1009 | pub const BG_TIMELINE: u32 = 0x121012; |
| 1010 | pub const BG_HOVER: u32 = 0x3d383d; |
| 1011 | pub const BG_HOVER_DIM: u32 = 0x221f22; |
| 1012 | pub const BG_SELECTED: u32 = 0x6b1f38; |
| 1013 | pub const SCRIM: u32 = 0x0c0b0ccc; |
| 1014 | pub const SCRIM_LIGHT: u32 = 0x0c0b0c55; |
| 1015 | |
| 1016 | |
| 1017 | pub const STROKE_DIVIDER: u32 = 0x332f33; |
| 1018 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1019 | |
| 1020 | |
| 1021 | pub const FG_PRIMARY: u32 = 0xf3edef; |
| 1022 | pub const FG_SECONDARY: u32 = 0xc0b4b8; |
| 1023 | pub const FG_DISABLED: u32 = 0x8a7e82; |
| 1024 | |
| 1025 | |
| 1026 | pub const ACCENT_PRIMARY: u32 = 0xfb7185; |
| 1027 | pub const ACCENT_HOVER: u32 = 0xfda4af; |
| 1028 | pub const ACCENT_PLAYHEAD: u32 = 0x67e8f9; |
| 1029 | pub const ACCENT_WASH: u32 = 0xfb7185aa; |
| 1030 | |
| 1031 | |
| 1032 | pub const CLIP_VIDEO: u32 = 0x2f5a9e; |
| 1033 | pub const CLIP_AUDIO: u32 = 0x2c6b49; |
| 1034 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 1035 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 1036 | |
| 1037 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 1038 | 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, |
| 1039 | 0x7fc8e8, 0xe8c87f, 0x9b7fe8, |
| 1040 | ]; |
| 1041 | |
| 1042 | |
| 1043 | |
| 1044 | |
| 1045 | |
| 1046 | pub const STATUS_ERROR: u32 = 0xff4d4d; |
| 1047 | pub const STATUS_WARNING: u32 = 0xfacc15; |
| 1048 | pub const STATUS_SUCCESS: u32 = 0x4ade80; |
| 1049 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 1050 | pub const DROP_REFUSE: u32 = 0x8f2740; |
| 1051 | |
| 1052 | |
| 1053 | pub const SUB_FG: u32 = 0xffffff; |
| 1054 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 1055 | |
| 1056 | |
| 1057 | pub const EQ_GRID: u32 = 0x332f33; |
| 1058 | pub const EQ_SPECTRUM_INK: u32 = 0xc0b4b866; |
| 1059 | pub const EQ_FILL_INK: u32 = 0xfb718526; |
| 1060 | pub const EQ_BELL_INK: u32 = 0xfb718566; |
| 1061 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 1062 | |
| 1063 | pub const INK1: u32 = FG_PRIMARY; |
| 1064 | pub const INK2: u32 = FG_SECONDARY; |
| 1065 | pub const INK3: u32 = 0xa9a0a3; |
| 1066 | pub const INK4: u32 = FG_DISABLED; |
| 1067 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 1068 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 1069 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 1070 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 1071 | pub const DARK_EDGE: u32 = INK3; |
| 1072 | pub const DARK_SEAM: u32 = SCRIM; |
| 1073 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 1074 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 1075 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 1076 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 1077 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 1078 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 1079 | } |
| 1080 | |
| 1081 | |
| 1082 | |
| 1083 | pub mod amber { |
| 1084 | |
| 1085 | pub const BG_CANVAS: u32 = 0x0d0d0c; |
| 1086 | pub const BG_PANEL: u32 = 0x1b1b19; |
| 1087 | pub const BG_RAISED: u32 = 0x2b2b27; |
| 1088 | pub const BG_TIMELINE: u32 = 0x131311; |
| 1089 | pub const BG_HOVER: u32 = 0x3e3e38; |
| 1090 | pub const BG_HOVER_DIM: u32 = 0x232320; |
| 1091 | |
| 1092 | |
| 1093 | pub const BG_SELECTED: u32 = 0x5e3a0b; |
| 1094 | pub const SCRIM: u32 = 0x0d0d0ccc; |
| 1095 | pub const SCRIM_LIGHT: u32 = 0x0d0d0c55; |
| 1096 | |
| 1097 | |
| 1098 | pub const STROKE_DIVIDER: u32 = 0x35352f; |
| 1099 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1100 | |
| 1101 | |
| 1102 | pub const FG_PRIMARY: u32 = 0xf2f0e9; |
| 1103 | pub const FG_SECONDARY: u32 = 0xbdbaae; |
| 1104 | pub const FG_DISABLED: u32 = 0x87857c; |
| 1105 | |
| 1106 | |
| 1107 | pub const ACCENT_PRIMARY: u32 = 0xfbbf24; |
| 1108 | pub const ACCENT_HOVER: u32 = 0xfcd34d; |
| 1109 | pub const ACCENT_PLAYHEAD: u32 = 0x93c5fd; |
| 1110 | pub const ACCENT_WASH: u32 = 0xfbbf24aa; |
| 1111 | |
| 1112 | |
| 1113 | pub const CLIP_VIDEO: u32 = 0x2f5a9e; |
| 1114 | pub const CLIP_AUDIO: u32 = 0x2c6b49; |
| 1115 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 1116 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 1117 | |
| 1118 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 1119 | 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, |
| 1120 | 0x5fa8e8, 0x7fd69b, 0xd68fc1, |
| 1121 | ]; |
| 1122 | |
| 1123 | |
| 1124 | |
| 1125 | |
| 1126 | pub const STATUS_ERROR: u32 = 0xf05252; |
| 1127 | pub const STATUS_WARNING: u32 = 0xfb923c; |
| 1128 | pub const STATUS_SUCCESS: u32 = 0x4ade80; |
| 1129 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 1130 | pub const DROP_REFUSE: u32 = 0x7a2f24; |
| 1131 | |
| 1132 | |
| 1133 | pub const SUB_FG: u32 = 0xffffff; |
| 1134 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 1135 | |
| 1136 | |
| 1137 | pub const EQ_GRID: u32 = 0x35352f; |
| 1138 | pub const EQ_SPECTRUM_INK: u32 = 0xbdbaae66; |
| 1139 | pub const EQ_FILL_INK: u32 = 0xfbbf2426; |
| 1140 | pub const EQ_BELL_INK: u32 = 0xfbbf2466; |
| 1141 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 1142 | |
| 1143 | pub const INK1: u32 = FG_PRIMARY; |
| 1144 | pub const INK2: u32 = FG_SECONDARY; |
| 1145 | pub const INK3: u32 = 0xa5a49d; |
| 1146 | pub const INK4: u32 = FG_DISABLED; |
| 1147 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 1148 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 1149 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 1150 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 1151 | pub const DARK_EDGE: u32 = INK3; |
| 1152 | pub const DARK_SEAM: u32 = SCRIM; |
| 1153 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 1154 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 1155 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 1156 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 1157 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 1158 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 1159 | } |
| 1160 | |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | pub mod ocean { |
| 1165 | |
| 1166 | pub const BG_CANVAS: u32 = 0x05080f; |
| 1167 | pub const BG_PANEL: u32 = 0x0d1524; |
| 1168 | pub const BG_RAISED: u32 = 0x172436; |
| 1169 | pub const BG_TIMELINE: u32 = 0x08101c; |
| 1170 | pub const BG_HOVER: u32 = 0x223449; |
| 1171 | pub const BG_HOVER_DIM: u32 = 0x14202f; |
| 1172 | pub const BG_SELECTED: u32 = 0x0f3a6b; |
| 1173 | pub const SCRIM: u32 = 0x05080fcc; |
| 1174 | pub const SCRIM_LIGHT: u32 = 0x05080f55; |
| 1175 | |
| 1176 | |
| 1177 | pub const STROKE_DIVIDER: u32 = 0x1e2d42; |
| 1178 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1179 | |
| 1180 | |
| 1181 | pub const FG_PRIMARY: u32 = 0xe6eefb; |
| 1182 | pub const FG_SECONDARY: u32 = 0xa4bcd8; |
| 1183 | pub const FG_DISABLED: u32 = 0x6b8199; |
| 1184 | |
| 1185 | |
| 1186 | pub const ACCENT_PRIMARY: u32 = 0x38bdf8; |
| 1187 | pub const ACCENT_HOVER: u32 = 0x7dd3fc; |
| 1188 | pub const ACCENT_PLAYHEAD: u32 = 0xff9db0; |
| 1189 | pub const ACCENT_WASH: u32 = 0x38bdf8aa; |
| 1190 | |
| 1191 | |
| 1192 | pub const CLIP_VIDEO: u32 = 0x2f5a9e; |
| 1193 | pub const CLIP_AUDIO: u32 = 0x2c6b49; |
| 1194 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 1195 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 1196 | |
| 1197 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 1198 | 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, |
| 1199 | 0xe8a95f, 0x5fd6a0, 0xc98fe8, |
| 1200 | ]; |
| 1201 | |
| 1202 | |
| 1203 | pub const STATUS_ERROR: u32 = 0xf05252; |
| 1204 | pub const STATUS_WARNING: u32 = 0xfbbf24; |
| 1205 | pub const STATUS_SUCCESS: u32 = 0x4ade80; |
| 1206 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 1207 | pub const DROP_REFUSE: u32 = 0x8a2740; |
| 1208 | |
| 1209 | |
| 1210 | pub const SUB_FG: u32 = 0xffffff; |
| 1211 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 1212 | |
| 1213 | |
| 1214 | pub const EQ_GRID: u32 = 0x1e2d42; |
| 1215 | pub const EQ_SPECTRUM_INK: u32 = 0xa4bcd866; |
| 1216 | pub const EQ_FILL_INK: u32 = 0x38bdf826; |
| 1217 | pub const EQ_BELL_INK: u32 = 0x38bdf866; |
| 1218 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 1219 | |
| 1220 | pub const INK1: u32 = FG_PRIMARY; |
| 1221 | pub const INK2: u32 = FG_SECONDARY; |
| 1222 | pub const INK3: u32 = 0x92a3b4; |
| 1223 | pub const INK4: u32 = FG_DISABLED; |
| 1224 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 1225 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 1226 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 1227 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 1228 | pub const DARK_EDGE: u32 = INK3; |
| 1229 | pub const DARK_SEAM: u32 = SCRIM; |
| 1230 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 1231 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 1232 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 1233 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 1234 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 1235 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 1236 | } |
| 1237 | |
| 1238 | |
| 1239 | |
| 1240 | |
| 1241 | |
| 1242 | pub mod ice { |
| 1243 | |
| 1244 | pub const BG_CANVAS: u32 = 0x03060a; |
| 1245 | pub const BG_PANEL: u32 = 0x0b131c; |
| 1246 | pub const BG_RAISED: u32 = 0x18232f; |
| 1247 | pub const BG_TIMELINE: u32 = 0x060d15; |
| 1248 | pub const BG_HOVER: u32 = 0x24323f; |
| 1249 | pub const BG_HOVER_DIM: u32 = 0x121c26; |
| 1250 | |
| 1251 | |
| 1252 | pub const BG_SELECTED: u32 = 0x14476b; |
| 1253 | pub const SCRIM: u32 = 0x03060acc; |
| 1254 | pub const SCRIM_LIGHT: u32 = 0x03060a55; |
| 1255 | |
| 1256 | |
| 1257 | pub const STROKE_DIVIDER: u32 = 0x223140; |
| 1258 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1259 | |
| 1260 | |
| 1261 | pub const FG_PRIMARY: u32 = 0xf4fafe; |
| 1262 | pub const FG_SECONDARY: u32 = 0xb8cfe0; |
| 1263 | pub const FG_DISABLED: u32 = 0x71889b; |
| 1264 | |
| 1265 | |
| 1266 | pub const ACCENT_PRIMARY: u32 = 0xa5f3fc; |
| 1267 | pub const ACCENT_HOVER: u32 = 0xcffafe; |
| 1268 | pub const ACCENT_PLAYHEAD: u32 = 0xff8fa3; |
| 1269 | pub const ACCENT_WASH: u32 = 0xa5f3fcaa; |
| 1270 | |
| 1271 | |
| 1272 | pub const CLIP_VIDEO: u32 = 0x2f5a9e; |
| 1273 | pub const CLIP_AUDIO: u32 = 0x2c6b49; |
| 1274 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 1275 | pub const CLIP_TEXT: u32 = 0x6b46c1; |
| 1276 | |
| 1277 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 1278 | 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, |
| 1279 | 0xe8b47f, 0x8fd69b, 0xc79be8, |
| 1280 | ]; |
| 1281 | |
| 1282 | |
| 1283 | pub const STATUS_ERROR: u32 = 0xff6b6b; |
| 1284 | pub const STATUS_WARNING: u32 = 0xfbbf24; |
| 1285 | pub const STATUS_SUCCESS: u32 = 0x4ade80; |
| 1286 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 1287 | pub const DROP_REFUSE: u32 = 0x8f2740; |
| 1288 | |
| 1289 | |
| 1290 | pub const SUB_FG: u32 = 0xffffff; |
| 1291 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 1292 | |
| 1293 | |
| 1294 | pub const EQ_GRID: u32 = 0x223140; |
| 1295 | pub const EQ_SPECTRUM_INK: u32 = 0xb8cfe066; |
| 1296 | pub const EQ_FILL_INK: u32 = 0xa5f3fc26; |
| 1297 | pub const EQ_BELL_INK: u32 = 0xa5f3fc66; |
| 1298 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 1299 | |
| 1300 | pub const INK1: u32 = FG_PRIMARY; |
| 1301 | pub const INK2: u32 = FG_SECONDARY; |
| 1302 | pub const INK3: u32 = 0x97a8b6; |
| 1303 | pub const INK4: u32 = FG_DISABLED; |
| 1304 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 1305 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 1306 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 1307 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 1308 | pub const DARK_EDGE: u32 = INK3; |
| 1309 | pub const DARK_SEAM: u32 = SCRIM; |
| 1310 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 1311 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 1312 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 1313 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 1314 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 1315 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 1316 | } |
| 1317 | |
| 1318 | |
| 1319 | |
| 1320 | |
| 1321 | |
| 1322 | pub mod orchid { |
| 1323 | |
| 1324 | pub const BG_CANVAS: u32 = 0x0c0712; |
| 1325 | pub const BG_PANEL: u32 = 0x1a0f24; |
| 1326 | pub const BG_RAISED: u32 = 0x2a1a38; |
| 1327 | pub const BG_TIMELINE: u32 = 0x120a19; |
| 1328 | pub const BG_HOVER: u32 = 0x3b2650; |
| 1329 | pub const BG_HOVER_DIM: u32 = 0x231530; |
| 1330 | pub const BG_SELECTED: u32 = 0x6b1f5e; |
| 1331 | pub const SCRIM: u32 = 0x0c0712cc; |
| 1332 | pub const SCRIM_LIGHT: u32 = 0x0c071255; |
| 1333 | |
| 1334 | |
| 1335 | pub const STROKE_DIVIDER: u32 = 0x33203f; |
| 1336 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1337 | |
| 1338 | |
| 1339 | pub const FG_PRIMARY: u32 = 0xf6ecf8; |
| 1340 | pub const FG_SECONDARY: u32 = 0xc7b0cf; |
| 1341 | pub const FG_DISABLED: u32 = 0x8e7a97; |
| 1342 | |
| 1343 | |
| 1344 | pub const ACCENT_PRIMARY: u32 = 0xd946ef; |
| 1345 | pub const ACCENT_HOVER: u32 = 0xe879f9; |
| 1346 | pub const ACCENT_PLAYHEAD: u32 = 0xfbbf24; |
| 1347 | pub const ACCENT_WASH: u32 = 0xd946efaa; |
| 1348 | |
| 1349 | |
| 1350 | pub const CLIP_VIDEO: u32 = 0x2f5a9e; |
| 1351 | pub const CLIP_AUDIO: u32 = 0x2c6b49; |
| 1352 | pub const CLIP_IMAGE: u32 = 0x1c6270; |
| 1353 | pub const CLIP_TEXT: u32 = 0x5a45b8; |
| 1354 | |
| 1355 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 1356 | 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, |
| 1357 | 0x8fc9e8, 0xe8c48f, 0x8fe8b4, |
| 1358 | ]; |
| 1359 | |
| 1360 | |
| 1361 | pub const STATUS_ERROR: u32 = 0xf87171; |
| 1362 | pub const STATUS_WARNING: u32 = 0xfb923c; |
| 1363 | pub const STATUS_SUCCESS: u32 = 0x4ade80; |
| 1364 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 1365 | pub const DROP_REFUSE: u32 = 0x8f2740; |
| 1366 | |
| 1367 | |
| 1368 | pub const SUB_FG: u32 = 0xffffff; |
| 1369 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 1370 | |
| 1371 | |
| 1372 | pub const EQ_GRID: u32 = 0x33203f; |
| 1373 | pub const EQ_SPECTRUM_INK: u32 = 0xc7b0cf66; |
| 1374 | pub const EQ_FILL_INK: u32 = 0xd946ef26; |
| 1375 | pub const EQ_BELL_INK: u32 = 0xd946ef66; |
| 1376 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 1377 | |
| 1378 | pub const INK1: u32 = FG_PRIMARY; |
| 1379 | pub const INK2: u32 = FG_SECONDARY; |
| 1380 | pub const INK3: u32 = 0xa99ab0; |
| 1381 | pub const INK4: u32 = FG_DISABLED; |
| 1382 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 1383 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 1384 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 1385 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 1386 | pub const DARK_EDGE: u32 = INK3; |
| 1387 | pub const DARK_SEAM: u32 = SCRIM; |
| 1388 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 1389 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 1390 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 1391 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 1392 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 1393 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 1394 | } |
| 1395 | |
| 1396 | |
| 1397 | |
| 1398 | |
| 1399 | |
| 1400 | |
| 1401 | |
| 1402 | |
| 1403 | |
| 1404 | |
| 1405 | |
| 1406 | |
| 1407 | pub mod nord { |
| 1408 | |
| 1409 | pub const BG_CANVAS: u32 = 0x21262e; |
| 1410 | pub const BG_PANEL: u32 = 0x2e3440; |
| 1411 | pub const BG_RAISED: u32 = 0x3b4252; |
| 1412 | pub const BG_TIMELINE: u32 = 0x272c36; |
| 1413 | pub const BG_HOVER: u32 = 0x434c5e; |
| 1414 | pub const BG_HOVER_DIM: u32 = 0x353c4a; |
| 1415 | |
| 1416 | |
| 1417 | pub const BG_SELECTED: u32 = 0x2e4a6e; |
| 1418 | pub const SCRIM: u32 = 0x21262ecc; |
| 1419 | pub const SCRIM_LIGHT: u32 = 0x21262e55; |
| 1420 | |
| 1421 | |
| 1422 | pub const STROKE_DIVIDER: u32 = 0x434c5e; |
| 1423 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1424 | |
| 1425 | |
| 1426 | pub const FG_PRIMARY: u32 = 0xeceff4; |
| 1427 | pub const FG_SECONDARY: u32 = 0xd8dee9; |
| 1428 | |
| 1429 | |
| 1430 | pub const FG_DISABLED: u32 = 0x8a94a8; |
| 1431 | |
| 1432 | |
| 1433 | pub const ACCENT_PRIMARY: u32 = 0x88c0d0; |
| 1434 | pub const ACCENT_HOVER: u32 = 0x8fbcbb; |
| 1435 | |
| 1436 | |
| 1437 | pub const ACCENT_PLAYHEAD: u32 = 0xebcb8b; |
| 1438 | pub const ACCENT_WASH: u32 = 0x88c0d0aa; |
| 1439 | |
| 1440 | |
| 1441 | pub const CLIP_VIDEO: u32 = 0x3b5f8a; |
| 1442 | pub const CLIP_AUDIO: u32 = 0x4d6b3f; |
| 1443 | pub const CLIP_IMAGE: u32 = 0x3f6a69; |
| 1444 | pub const CLIP_TEXT: u32 = 0x6b4a78; |
| 1445 | |
| 1446 | |
| 1447 | |
| 1448 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 1449 | 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, |
| 1450 | 0xd08770, 0xa3be8c, 0xb48ead, |
| 1451 | ]; |
| 1452 | |
| 1453 | |
| 1454 | pub const STATUS_ERROR: u32 = 0xbf616a; |
| 1455 | pub const STATUS_WARNING: u32 = 0xd08770; |
| 1456 | pub const STATUS_SUCCESS: u32 = 0xa3be8c; |
| 1457 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 1458 | pub const DROP_REFUSE: u32 = 0x7a3038; |
| 1459 | |
| 1460 | |
| 1461 | pub const SUB_FG: u32 = 0xffffff; |
| 1462 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 1463 | |
| 1464 | |
| 1465 | pub const EQ_GRID: u32 = 0x434c5e; |
| 1466 | pub const EQ_SPECTRUM_INK: u32 = 0xd8dee966; |
| 1467 | pub const EQ_FILL_INK: u32 = 0x88c0d026; |
| 1468 | pub const EQ_BELL_INK: u32 = 0x88c0d066; |
| 1469 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 1470 | |
| 1471 | pub const INK1: u32 = FG_PRIMARY; |
| 1472 | pub const INK2: u32 = FG_SECONDARY; |
| 1473 | pub const INK3: u32 = 0xbfc5d0; |
| 1474 | pub const INK4: u32 = FG_DISABLED; |
| 1475 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 1476 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 1477 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 1478 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 1479 | pub const DARK_EDGE: u32 = INK3; |
| 1480 | pub const DARK_SEAM: u32 = SCRIM; |
| 1481 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 1482 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 1483 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 1484 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 1485 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 1486 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 1487 | } |
| 1488 | |
| 1489 | |
| 1490 | |
| 1491 | |
| 1492 | |
| 1493 | |
| 1494 | |
| 1495 | |
| 1496 | |
| 1497 | pub mod gruvbox { |
| 1498 | |
| 1499 | pub const BG_CANVAS: u32 = 0x1d2021; |
| 1500 | pub const BG_PANEL: u32 = 0x282828; |
| 1501 | pub const BG_RAISED: u32 = 0x3c3836; |
| 1502 | pub const BG_TIMELINE: u32 = 0x232323; |
| 1503 | pub const BG_HOVER: u32 = 0x504945; |
| 1504 | pub const BG_HOVER_DIM: u32 = 0x32302f; |
| 1505 | |
| 1506 | |
| 1507 | pub const BG_SELECTED: u32 = 0x7c3f12; |
| 1508 | pub const SCRIM: u32 = 0x1d2021cc; |
| 1509 | pub const SCRIM_LIGHT: u32 = 0x1d202155; |
| 1510 | |
| 1511 | |
| 1512 | pub const STROKE_DIVIDER: u32 = 0x504945; |
| 1513 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1514 | |
| 1515 | |
| 1516 | pub const FG_PRIMARY: u32 = 0xebdbb2; |
| 1517 | pub const FG_SECONDARY: u32 = 0xd5c4a1; |
| 1518 | pub const FG_DISABLED: u32 = 0xa89984; |
| 1519 | |
| 1520 | |
| 1521 | pub const ACCENT_PRIMARY: u32 = 0xfe8019; |
| 1522 | pub const ACCENT_HOVER: u32 = 0xfabd2f; |
| 1523 | |
| 1524 | |
| 1525 | pub const ACCENT_PLAYHEAD: u32 = 0xb8bb26; |
| 1526 | pub const ACCENT_WASH: u32 = 0xfe8019aa; |
| 1527 | |
| 1528 | |
| 1529 | pub const CLIP_VIDEO: u32 = 0x35657e; |
| 1530 | pub const CLIP_AUDIO: u32 = 0x4b661c; |
| 1531 | pub const CLIP_IMAGE: u32 = 0x2f6a63; |
| 1532 | pub const CLIP_TEXT: u32 = 0x7a4a72; |
| 1533 | |
| 1534 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 1535 | 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, |
| 1536 | 0x83a598, 0xb8bb26, 0xd3869b, |
| 1537 | ]; |
| 1538 | |
| 1539 | |
| 1540 | pub const STATUS_ERROR: u32 = 0xfb4934; |
| 1541 | pub const STATUS_WARNING: u32 = 0xfabd2f; |
| 1542 | pub const STATUS_SUCCESS: u32 = 0x8ec07c; |
| 1543 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 1544 | pub const DROP_REFUSE: u32 = 0x9d0006; |
| 1545 | |
| 1546 | |
| 1547 | pub const SUB_FG: u32 = 0xffffff; |
| 1548 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 1549 | |
| 1550 | |
| 1551 | pub const EQ_GRID: u32 = 0x504945; |
| 1552 | pub const EQ_SPECTRUM_INK: u32 = 0xd5c4a166; |
| 1553 | pub const EQ_FILL_INK: u32 = 0xfe801926; |
| 1554 | pub const EQ_BELL_INK: u32 = 0xfe801966; |
| 1555 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 1556 | |
| 1557 | pub const INK1: u32 = FG_PRIMARY; |
| 1558 | pub const INK2: u32 = FG_SECONDARY; |
| 1559 | pub const INK3: u32 = 0xbaaf9e; |
| 1560 | pub const INK4: u32 = FG_DISABLED; |
| 1561 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 1562 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 1563 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 1564 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 1565 | pub const DARK_EDGE: u32 = INK3; |
| 1566 | pub const DARK_SEAM: u32 = SCRIM; |
| 1567 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 1568 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 1569 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 1570 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 1571 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 1572 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 1573 | } |
| 1574 | |
| 1575 | |
| 1576 | |
| 1577 | |
| 1578 | |
| 1579 | |
| 1580 | pub mod dracula { |
| 1581 | |
| 1582 | pub const BG_CANVAS: u32 = 0x1e1f29; |
| 1583 | pub const BG_PANEL: u32 = 0x282a36; |
| 1584 | pub const BG_RAISED: u32 = 0x343746; |
| 1585 | pub const BG_TIMELINE: u32 = 0x22232e; |
| 1586 | pub const BG_HOVER: u32 = 0x44475a; |
| 1587 | pub const BG_HOVER_DIM: u32 = 0x2f3141; |
| 1588 | pub const BG_SELECTED: u32 = 0x6b2a70; |
| 1589 | pub const SCRIM: u32 = 0x1e1f29cc; |
| 1590 | pub const SCRIM_LIGHT: u32 = 0x1e1f2955; |
| 1591 | |
| 1592 | |
| 1593 | pub const STROKE_DIVIDER: u32 = 0x44475a; |
| 1594 | pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; |
| 1595 | |
| 1596 | |
| 1597 | pub const FG_PRIMARY: u32 = 0xf8f8f2; |
| 1598 | pub const FG_SECONDARY: u32 = 0xc3c5d8; |
| 1599 | pub const FG_DISABLED: u32 = 0x7b8bc4; |
| 1600 | |
| 1601 | |
| 1602 | pub const ACCENT_PRIMARY: u32 = 0xff79c6; |
| 1603 | pub const ACCENT_HOVER: u32 = 0xff92d0; |
| 1604 | pub const ACCENT_PLAYHEAD: u32 = 0xf1fa8c; |
| 1605 | pub const ACCENT_WASH: u32 = 0xff79c6aa; |
| 1606 | |
| 1607 | |
| 1608 | pub const CLIP_VIDEO: u32 = 0x3f5aa6; |
| 1609 | pub const CLIP_AUDIO: u32 = 0x2f7a48; |
| 1610 | pub const CLIP_IMAGE: u32 = 0x2b6e78; |
| 1611 | pub const CLIP_TEXT: u32 = 0x6a3fb0; |
| 1612 | |
| 1613 | |
| 1614 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 1615 | 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, |
| 1616 | 0x8be9fd, 0x50fa7b, 0xffb86c, |
| 1617 | ]; |
| 1618 | |
| 1619 | |
| 1620 | pub const STATUS_ERROR: u32 = 0xff5555; |
| 1621 | pub const STATUS_WARNING: u32 = 0xffb86c; |
| 1622 | pub const STATUS_SUCCESS: u32 = 0x50fa7b; |
| 1623 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 1624 | pub const DROP_REFUSE: u32 = 0x8f2a3a; |
| 1625 | |
| 1626 | |
| 1627 | pub const SUB_FG: u32 = 0xffffff; |
| 1628 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 1629 | |
| 1630 | |
| 1631 | pub const EQ_GRID: u32 = 0x44475a; |
| 1632 | pub const EQ_SPECTRUM_INK: u32 = 0xc3c5d866; |
| 1633 | pub const EQ_FILL_INK: u32 = 0xff79c626; |
| 1634 | pub const EQ_BELL_INK: u32 = 0xff79c666; |
| 1635 | pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; |
| 1636 | |
| 1637 | pub const INK1: u32 = FG_PRIMARY; |
| 1638 | pub const INK2: u32 = FG_SECONDARY; |
| 1639 | pub const INK3: u32 = 0xa6b0d7; |
| 1640 | pub const INK4: u32 = FG_DISABLED; |
| 1641 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 1642 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 1643 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 1644 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 1645 | pub const DARK_EDGE: u32 = INK3; |
| 1646 | pub const DARK_SEAM: u32 = SCRIM; |
| 1647 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 1648 | pub const NOTICE_TELL: u32 = STATUS_SUCCESS; |
| 1649 | pub const NOTICE_LOOK: u32 = STATUS_WARNING; |
| 1650 | pub const NOTICE_DECIDE: u32 = STATUS_ERROR; |
| 1651 | pub const SAFELIGHT_GROUND: u32 = BG_CANVAS; |
| 1652 | pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY; |
| 1653 | } |
| 1654 | |
| 1655 | |
| 1656 | |
| 1657 | |
| 1658 | |
| 1659 | |
| 1660 | |
| 1661 | |
| 1662 | pub mod darkroom { |
| 1663 | |
| 1664 | pub const BG_CANVAS: u32 = 0x0b0c0e; |
| 1665 | pub const BG_PANEL: u32 = 0x131518; |
| 1666 | |
| 1667 | |
| 1668 | |
| 1669 | |
| 1670 | |
| 1671 | |
| 1672 | |
| 1673 | |
| 1674 | |
| 1675 | |
| 1676 | |
| 1677 | |
| 1678 | |
| 1679 | pub const BG_RAISED: u32 = 0x1b1e22; |
| 1680 | pub const BG_TIMELINE: u32 = 0x08090b; |
| 1681 | pub const BG_HOVER: u32 = 0x24282d; |
| 1682 | pub const BG_HOVER_DIM: u32 = 0x121418; |
| 1683 | pub const BG_SELECTED: u32 = 0x1c1f24; |
| 1684 | pub const SCRIM: u32 = 0x050607cc; |
| 1685 | pub const SCRIM_LIGHT: u32 = 0x05060755; |
| 1686 | |
| 1687 | |
| 1688 | pub const STROKE_DIVIDER: u32 = 0x2a2e34; |
| 1689 | |
| 1690 | pub const STROKE_SELECTED: u32 = INK1; |
| 1691 | |
| 1692 | |
| 1693 | pub const FG_PRIMARY: u32 = INK1; |
| 1694 | pub const FG_SECONDARY: u32 = INK2; |
| 1695 | pub const FG_DISABLED: u32 = INK4; |
| 1696 | |
| 1697 | |
| 1698 | pub const ACCENT_PRIMARY: u32 = INK2; |
| 1699 | pub const ACCENT_HOVER: u32 = INK1; |
| 1700 | pub const ACCENT_PLAYHEAD: u32 = LAMP_WHITE; |
| 1701 | pub const ACCENT_WASH: u32 = 0xb4bac155; |
| 1702 | |
| 1703 | |
| 1704 | |
| 1705 | pub const CLIP_VIDEO: u32 = 0x343434; |
| 1706 | pub const CLIP_AUDIO: u32 = 0x3d3d3d; |
| 1707 | pub const CLIP_IMAGE: u32 = 0x464646; |
| 1708 | pub const CLIP_TEXT: u32 = 0x4f4f4f; |
| 1709 | |
| 1710 | |
| 1711 | |
| 1712 | |
| 1713 | |
| 1714 | |
| 1715 | |
| 1716 | |
| 1717 | |
| 1718 | pub const SOURCE_TINTS: [u32; 12] = [ |
| 1719 | 0x64b5d1, 0x647ed1, 0x8064d1, 0xb664d1, 0xd164b5, 0xd1647e, 0xd18064, 0xd1b764, 0xb5d164, |
| 1720 | 0x7ed164, 0x64d180, 0x64d1b7, |
| 1721 | ]; |
| 1722 | |
| 1723 | |
| 1724 | pub const STATUS_ERROR: u32 = NOTICE_DECIDE; |
| 1725 | pub const STATUS_WARNING: u32 = NOTICE_LOOK; |
| 1726 | pub const STATUS_SUCCESS: u32 = INK1; |
| 1727 | pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; |
| 1728 | pub const DROP_REFUSE: u32 = NOTICE_DECIDE; |
| 1729 | |
| 1730 | |
| 1731 | pub const SUB_FG: u32 = LAMP_WHITE; |
| 1732 | pub const SUB_SHADE: u32 = 0x000000cc; |
| 1733 | |
| 1734 | |
| 1735 | pub const EQ_GRID: u32 = 0x22262b; |
| 1736 | pub const EQ_SPECTRUM_INK: u32 = 0xb4bac166; |
| 1737 | pub const EQ_FILL_INK: u32 = 0xb4bac126; |
| 1738 | pub const EQ_BELL_INK: u32 = 0xb4bac166; |
| 1739 | pub const HIST_INK: [u32; 3] = [0x767e87, 0x9ba3ac, 0xc7cdd3]; |
| 1740 | |
| 1741 | |
| 1742 | pub const INK1: u32 = 0xe8eaed; |
| 1743 | pub const INK2: u32 = 0xb4bac1; |
| 1744 | pub const INK3: u32 = 0x8d959e; |
| 1745 | pub const INK4: u32 = 0x777f88; |
| 1746 | pub const DARK_CANVAS: u32 = BG_CANVAS; |
| 1747 | pub const DARK_PANEL: u32 = BG_PANEL; |
| 1748 | pub const DARK_RAISED: u32 = BG_RAISED; |
| 1749 | pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER; |
| 1750 | |
| 1751 | |
| 1752 | pub const DARK_EDGE: u32 = 0x6e757d; |
| 1753 | |
| 1754 | |
| 1755 | pub const DARK_SEAM: u32 = 0x000000b3; |
| 1756 | pub const LAMP_WHITE: u32 = 0xffffff; |
| 1757 | pub const NOTICE_TELL: u32 = 0x5e656d; |
| 1758 | pub const NOTICE_LOOK: u32 = 0xd1b564; |
| 1759 | pub const NOTICE_DECIDE: u32 = 0xe07a7a; |
| 1760 | pub const SAFELIGHT_GROUND: u32 = 0x0a0908; |
| 1761 | pub const SAFELIGHT_GLYPH: u32 = 0xff9d57; |
| 1762 | } |
| 1763 | |
| 1764 | |
| 1765 | |
| 1766 | |
| 1767 | |
| 1768 | |
| 1769 | |
| 1770 | |
| 1771 | |
| 1772 | |
| 1773 | |
| 1774 | |
| 1775 | |
| 1776 | |
| 1777 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 1778 | pub enum ClipKind { |
| 1779 | Video, |
| 1780 | Image, |
| 1781 | Audio, |
| 1782 | |
| 1783 | Title, |
| 1784 | |
| 1785 | Caption, |
| 1786 | |
| 1787 | Compound, |
| 1788 | Multicam, |
| 1789 | } |
| 1790 | |
| 1791 | impl ClipKind { |
| 1792 | pub const ALL: [ClipKind; 7] = [ |
| 1793 | ClipKind::Video, |
| 1794 | ClipKind::Image, |
| 1795 | ClipKind::Audio, |
| 1796 | ClipKind::Title, |
| 1797 | ClipKind::Caption, |
| 1798 | ClipKind::Compound, |
| 1799 | ClipKind::Multicam, |
| 1800 | ]; |
| 1801 | } |
| 1802 | |
| 1803 | |
| 1804 | |
| 1805 | #[derive(Clone, Copy, PartialEq, Debug)] |
| 1806 | pub struct ClipTone { |
| 1807 | pub strip: u32, |
| 1808 | pub body: u32, |
| 1809 | pub ink: u32, |
| 1810 | |
| 1811 | |
| 1812 | pub label: u32, |
| 1813 | } |
| 1814 | |
| 1815 | |
| 1816 | #[derive(Clone, Copy, PartialEq, Debug)] |
| 1817 | pub struct Tokens { |
| 1818 | |
| 1819 | pub e0: u32, |
| 1820 | |
| 1821 | pub e1: u32, |
| 1822 | |
| 1823 | pub e2: u32, |
| 1824 | |
| 1825 | pub e3: u32, |
| 1826 | |
| 1827 | pub e4: u32, |
| 1828 | |
| 1829 | pub well: u32, |
| 1830 | |
| 1831 | pub matte: u32, |
| 1832 | |
| 1833 | pub line: u32, |
| 1834 | |
| 1835 | pub line_hi: u32, |
| 1836 | |
| 1837 | pub edge: u32, |
| 1838 | pub ink1: u32, |
| 1839 | pub ink2: u32, |
| 1840 | pub ink3: u32, |
| 1841 | |
| 1842 | pub ink4: u32, |
| 1843 | pub accent: u32, |
| 1844 | pub accent_hover: u32, |
| 1845 | pub accent_press: u32, |
| 1846 | |
| 1847 | pub accent_fill: u32, |
| 1848 | |
| 1849 | pub on_accent: u32, |
| 1850 | |
| 1851 | pub accent_wash: u32, |
| 1852 | |
| 1853 | pub range_tint: u32, |
| 1854 | pub err: u32, |
| 1855 | pub warn: u32, |
| 1856 | pub ok: u32, |
| 1857 | |
| 1858 | pub clip: [ClipTone; 7], |
| 1859 | } |
| 1860 | |
| 1861 | impl Tokens { |
| 1862 | pub fn clip(&self, kind: ClipKind) -> ClipTone { |
| 1863 | self.clip[kind as usize] |
| 1864 | } |
| 1865 | } |
| 1866 | |
| 1867 | |
| 1868 | pub fn contrast(a: u32, b: u32) -> f64 { |
| 1869 | let lum = |hex: u32| { |
| 1870 | let lin = |shift: u32| { |
| 1871 | let c = f64::from((hex >> shift) & 0xff) / 255.; |
| 1872 | if c <= 0.03928 { c / 12.92 } else { ((c + 0.055) / 1.055).powf(2.4) } |
| 1873 | }; |
| 1874 | 0.2126 * lin(16) + 0.7152 * lin(8) + 0.0722 * lin(0) |
| 1875 | }; |
| 1876 | let (a, b) = (lum(a), lum(b)); |
| 1877 | (a.max(b) + 0.05) / (a.min(b) + 0.05) |
| 1878 | } |
| 1879 | |
| 1880 | |
| 1881 | pub fn mix(a: u32, b: u32, t: f32) -> u32 { |
| 1882 | let ch = |s: u32| { |
| 1883 | let (x, y) = (((a >> s) & 0xff) as f32, ((b >> s) & 0xff) as f32); |
| 1884 | ((x + (y - x) * t).round() as u32).min(255) << s |
| 1885 | }; |
| 1886 | ch(16) | ch(8) | ch(0) |
| 1887 | } |
| 1888 | |
| 1889 | |
| 1890 | pub const fn with_alpha(rgb: u32, alpha: u8) -> u32 { |
| 1891 | ((rgb & 0xffffff) << 8) | alpha as u32 |
| 1892 | } |
| 1893 | |
| 1894 | const fn tone(strip: u32, body: u32, ink: u32) -> ClipTone { |
| 1895 | ClipTone { strip, body, ink, label: 0 } |
| 1896 | } |
| 1897 | |
| 1898 | |
| 1899 | const DARKROOM_TOKENS: Tokens = Tokens { |
| 1900 | e0: 0x0f0f11, |
| 1901 | e1: 0x17171a, |
| 1902 | e2: 0x202024, |
| 1903 | e3: 0x2a2a2f, |
| 1904 | e4: 0x35353b, |
| 1905 | well: 0x0c0c0e, |
| 1906 | matte: 0x08080a, |
| 1907 | line: 0xffffff12, |
| 1908 | line_hi: 0xffffff14, |
| 1909 | edge: 0x6e757d, |
| 1910 | ink1: 0xececef, |
| 1911 | ink2: 0xa9a9b2, |
| 1912 | ink3: 0x85858f, |
| 1913 | ink4: 0x5a5a63, |
| 1914 | accent: 0x9dbea2, |
| 1915 | accent_hover: 0xb5d2b9, |
| 1916 | accent_press: 0x86a18a, |
| 1917 | accent_fill: 0x9dbea2, |
| 1918 | on_accent: 0x0f1510, |
| 1919 | accent_wash: 0x9dbea233, |
| 1920 | range_tint: 0x9dbea21a, |
| 1921 | err: 0xf0707a, |
| 1922 | warn: 0xe2b860, |
| 1923 | ok: 0x5acb8e, |
| 1924 | clip: [ |
| 1925 | tone(0x2f5f9e, 0x1c3350, 0xffffff), |
| 1926 | tone(0x2b8080, 0x183b3c, 0xffffff), |
| 1927 | tone(0x2e8b5e, 0x17291f, 0x6fd6a0), |
| 1928 | tone(0x7b5cc4, 0x2b2248, 0xc3b0f5), |
| 1929 | tone(0xb98a2e, 0x33280f, 0xf0cc82), |
| 1930 | tone(0x8b8f99, 0x25272c, 0xc9ccd4), |
| 1931 | tone(0xc25b8a, 0x3a1b2b, 0xf1a8c6), |
| 1932 | ], |
| 1933 | }; |
| 1934 | |
| 1935 | |
| 1936 | |
| 1937 | |
| 1938 | |
| 1939 | |
| 1940 | fn derive(p: &Palette) -> Tokens { |
| 1941 | let kind = |strip: u32, ink: u32| tone(strip, mix(strip, p.BG_CANVAS, 0.55), ink); |
| 1942 | let lift = |c: u32| mix(c, 0xffffff, 0.55); |
| 1943 | Tokens { |
| 1944 | e0: p.BG_CANVAS, |
| 1945 | e1: p.BG_PANEL, |
| 1946 | e2: p.BG_RAISED, |
| 1947 | e3: p.BG_HOVER, |
| 1948 | e4: mix(p.BG_HOVER, p.INK1, 0.08), |
| 1949 | well: p.BG_TIMELINE, |
| 1950 | matte: mix(p.BG_CANVAS, 0x000000, 0.35), |
| 1951 | line: 0xffffff12, |
| 1952 | line_hi: 0xffffff14, |
| 1953 | edge: p.DARK_EDGE, |
| 1954 | ink1: p.INK1, |
| 1955 | ink2: p.INK2, |
| 1956 | ink3: p.INK3, |
| 1957 | ink4: p.INK4, |
| 1958 | accent: p.ACCENT_PRIMARY, |
| 1959 | accent_hover: p.ACCENT_HOVER, |
| 1960 | accent_press: mix(p.ACCENT_PRIMARY, 0x000000, 0.2), |
| 1961 | accent_fill: p.ACCENT_PRIMARY, |
| 1962 | on_accent: 0x0f1510, |
| 1963 | accent_wash: with_alpha(p.ACCENT_PRIMARY, 0x33), |
| 1964 | range_tint: with_alpha(p.ACCENT_PRIMARY, 0x1a), |
| 1965 | err: p.STATUS_ERROR, |
| 1966 | warn: p.STATUS_WARNING, |
| 1967 | ok: p.STATUS_SUCCESS, |
| 1968 | clip: [ |
| 1969 | kind(p.CLIP_VIDEO, 0xffffff), |
| 1970 | kind(p.CLIP_IMAGE, 0xffffff), |
| 1971 | kind(p.CLIP_AUDIO, lift(p.CLIP_AUDIO)), |
| 1972 | kind(p.CLIP_TEXT, lift(p.CLIP_TEXT)), |
| 1973 | kind(p.NOTICE_LOOK, lift(p.NOTICE_LOOK)), |
| 1974 | kind(p.INK3, lift(p.INK3)), |
| 1975 | kind(p.SOURCE_TINTS[4], lift(p.SOURCE_TINTS[4])), |
| 1976 | ], |
| 1977 | } |
| 1978 | } |
| 1979 | |
| 1980 | |
| 1981 | fn with_labels(mut t: Tokens) -> Tokens { |
| 1982 | for tone in &mut t.clip { |
| 1983 | tone.label = [t.ink1, 0xffffff, t.e0] |
| 1984 | .into_iter() |
| 1985 | .max_by(|a, b| contrast(*a, tone.strip).total_cmp(&contrast(*b, tone.strip))) |
| 1986 | .unwrap_or(t.ink1); |
| 1987 | } |
| 1988 | t |
| 1989 | } |
| 1990 | |
| 1991 | |
| 1992 | |
| 1993 | pub fn tokens() -> &'static Tokens { |
| 1994 | |
| 1995 | |
| 1996 | let load = || *LIVE.read().unwrap_or_else(|e| e.into_inner()); |
| 1997 | let mut all = load(); |
| 1998 | if all.is_empty() { |
| 1999 | refresh(); |
| 2000 | all = load(); |
| 2001 | } |
| 2002 | all.get(ACTIVE.load(Relaxed)).unwrap_or(&all[PaletteId::DEFAULT as usize]) |
| 2003 | } |
| 2004 | |
| 2005 | |
| 2006 | static LIVE: RwLock<&'static [Tokens]> = RwLock::new(&[]); |
| 2007 | |
| 2008 | |
| 2009 | fn bases() -> &'static [Tokens] { |
| 2010 | static BASES: std::sync::OnceLock<Vec<Tokens>> = std::sync::OnceLock::new(); |
| 2011 | BASES.get_or_init(|| PaletteId::ALL.iter().map(|&id| base_tokens(id)).collect()) |
| 2012 | } |
| 2013 | |
| 2014 | fn base_tokens(id: PaletteId) -> Tokens { |
| 2015 | match id { |
| 2016 | PaletteId::Darkroom => with_labels(DARKROOM_TOKENS), |
| 2017 | _ => with_labels(derive(&PALETTES[id as usize])), |
| 2018 | } |
| 2019 | } |
| 2020 | |
| 2021 | |
| 2022 | |
| 2023 | fn refresh() { |
| 2024 | static SEEN: Mutex<Vec<(AccentSpec, &'static [Tokens])>> = Mutex::new(Vec::new()); |
| 2025 | let spec = spec_in_force(); |
| 2026 | let Ok(mut seen) = SEEN.lock() else { return }; |
| 2027 | let table = match seen.iter().find(|(s, _)| *s == spec) { |
| 2028 | Some((_, t)) => *t, |
| 2029 | None => { |
| 2030 | let t: &'static [Tokens] = Box::leak(bases().iter().map(|b| spec.apply(*b)).collect()); |
| 2031 | seen.push((spec, t)); |
| 2032 | t |
| 2033 | } |
| 2034 | }; |
| 2035 | *LIVE.write().unwrap_or_else(|e| e.into_inner()) = table; |
| 2036 | } |
| 2037 | |
| 2038 | |
| 2039 | #[cfg(test)] |
| 2040 | fn tokens_with(id: PaletteId, accent: AccentSpec) -> Tokens { |
| 2041 | accent.apply(base_tokens(id)) |
| 2042 | } |
| 2043 | |
| 2044 | |
| 2045 | #[cfg(test)] |
| 2046 | pub fn tokens_of(id: PaletteId) -> Tokens { |
| 2047 | tokens_with(id, AccentSpec::DEFAULT) |
| 2048 | } |
| 2049 | |
| 2050 | |
| 2051 | |
| 2052 | pub const WASH_HOVER: u32 = 0xffffff0f; |
| 2053 | pub const WASH_PRESS: u32 = 0xffffff1a; |
| 2054 | #[allow(dead_code, reason = "media rows adopt it in P4")] |
| 2055 | pub const WASH_ROW: u32 = 0xffffff0a; |
| 2056 | |
| 2057 | |
| 2058 | pub const PLATE_SHADOW: u32 = 0x00000080; |
| 2059 | |
| 2060 | |
| 2061 | |
| 2062 | |
| 2063 | pub const GLYPH_SLOT: f32 = 14.; |
| 2064 | |
| 2065 | |
| 2066 | |
| 2067 | |
| 2068 | pub const GHOST_ALPHA: u32 = 0x66; |
| 2069 | |
| 2070 | |
| 2071 | |
| 2072 | |
| 2073 | pub const INSPECTOR_MIN_W: f32 = 208.; |
| 2074 | pub const INSPECTOR_MAX_W: f32 = 320.; |
| 2075 | pub const INSPECTOR_FRAC: f32 = 0.24; |
| 2076 | |
| 2077 | |
| 2078 | |
| 2079 | |
| 2080 | |
| 2081 | pub fn marker_rgb(color: engine::project::MarkerColor) -> u32 { |
| 2082 | use engine::project::MarkerColor; |
| 2083 | match color { |
| 2084 | MarkerColor::Red => 0xe5484d, |
| 2085 | MarkerColor::Orange => 0xf76b15, |
| 2086 | MarkerColor::Yellow => 0xf5d90a, |
| 2087 | MarkerColor::Green => 0x46a758, |
| 2088 | MarkerColor::Blue => 0x3e8fe0, |
| 2089 | MarkerColor::Purple => 0x8e4ec6, |
| 2090 | } |
| 2091 | } |
| 2092 | |
| 2093 | |
| 2094 | |
| 2095 | pub fn inspector_w(window_w: f32) -> f32 { |
| 2096 | (window_w * INSPECTOR_FRAC).clamp(INSPECTOR_MIN_W, INSPECTOR_MAX_W) |
| 2097 | } |
| 2098 | |
| 2099 | #[cfg(test)] |
| 2100 | mod tests { |
| 2101 | use super::darkroom as d; |
| 2102 | |
| 2103 | |
| 2104 | fn luminance(hex: u32) -> f64 { |
| 2105 | let lin = |shift: u32| { |
| 2106 | let c = f64::from((hex >> shift) & 0xff) / 255.; |
| 2107 | if c <= 0.03928 { |
| 2108 | c / 12.92 |
| 2109 | } else { |
| 2110 | ((c + 0.055) / 1.055).powf(2.4) |
| 2111 | } |
| 2112 | }; |
| 2113 | 0.2126 * lin(16) + 0.7152 * lin(8) + 0.0722 * lin(0) |
| 2114 | } |
| 2115 | |
| 2116 | fn ratio(a: u32, b: u32) -> f64 { |
| 2117 | let (a, b) = (luminance(a), luminance(b)); |
| 2118 | (a.max(b) + 0.05) / (a.min(b) + 0.05) |
| 2119 | } |
| 2120 | |
| 2121 | const SURFACES: [(&str, u32); 4] = [ |
| 2122 | ("canvas", d::BG_CANVAS), |
| 2123 | ("panel", d::BG_PANEL), |
| 2124 | ("raised", d::BG_RAISED), |
| 2125 | ("hover", d::BG_HOVER), |
| 2126 | ]; |
| 2127 | |
| 2128 | |
| 2129 | #[test] |
| 2130 | fn darkroom_token_pairs_meet_their_contrast_spec() { |
| 2131 | let specs: [(&str, u32, f64); 6] = [ |
| 2132 | ("ink1", d::INK1, 4.5), |
| 2133 | ("ink2", d::INK2, 4.5), |
| 2134 | ("ink3", d::INK3, 4.5), |
| 2135 | ("err", d::NOTICE_DECIDE, 4.5), |
| 2136 | |
| 2137 | ("ink4 (disabled)", d::INK4, 3.6), |
| 2138 | |
| 2139 | ("edge", d::DARK_EDGE, 3.0), |
| 2140 | ]; |
| 2141 | for (name, fg, floor) in specs { |
| 2142 | for (surface, bg) in SURFACES { |
| 2143 | let r = ratio(fg, bg); |
| 2144 | assert!(r >= floor, "{name} on {surface}: {r:.2} < {floor}"); |
| 2145 | } |
| 2146 | } |
| 2147 | |
| 2148 | for (surface, bg) in SURFACES { |
| 2149 | assert!(ratio(d::STROKE_SELECTED, bg) >= 3.0, "focus ring on {surface}"); |
| 2150 | assert!(ratio(d::LAMP_WHITE, bg) >= 3.0, "playhead on {surface}"); |
| 2151 | } |
| 2152 | |
| 2153 | assert!(ratio(d::DARK_EDGE, d::BG_PANEL) > ratio(d::DARK_HAIRLINE, d::BG_PANEL)); |
| 2154 | } |
| 2155 | |
| 2156 | |
| 2157 | |
| 2158 | #[test] |
| 2159 | fn darkroom_tokens_meet_the_redesign_spec() { |
| 2160 | let t = super::tokens_of(super::PaletteId::Darkroom); |
| 2161 | for (name, bg) in [("e0", t.e0), ("e1", t.e1), ("e2", t.e2), ("e3", t.e3), ("e4", t.e4)] { |
| 2162 | assert!(ratio(t.ink1, bg) >= 7.0, "ink1 on {name}"); |
| 2163 | } |
| 2164 | for (name, bg) in [("e0", t.e0), ("e1", t.e1), ("e2", t.e2), ("e3", t.e3)] { |
| 2165 | assert!(ratio(t.ink2, bg) >= 4.5, "ink2 on {name}"); |
| 2166 | } |
| 2167 | |
| 2168 | for (name, bg) in [("e0", t.e0), ("e1", t.e1)] { |
| 2169 | assert!(ratio(t.ink3, bg) >= 4.5, "ink3 on {name}"); |
| 2170 | } |
| 2171 | for (name, bg) in [("e0", t.e0), ("e1", t.e1), ("e2", t.e2)] { |
| 2172 | assert!(ratio(t.accent, bg) >= 3.0, "focus ring on {name}"); |
| 2173 | for (c, hue) in [("err", t.err), ("warn", t.warn), ("ok", t.ok)] { |
| 2174 | assert!(ratio(hue, bg) >= 4.5, "{c} on {name}"); |
| 2175 | } |
| 2176 | } |
| 2177 | assert!(ratio(t.on_accent, t.accent_fill) >= 4.5, "label on the primary fill"); |
| 2178 | |
| 2179 | assert!(ratio(t.ink4, t.e1) < ratio(t.ink3, t.e1)); |
| 2180 | |
| 2181 | let l = |c| luminance(c); |
| 2182 | assert!(l(t.matte) < l(t.well) && l(t.well) < l(t.e0) && l(t.e0) < l(t.e1)); |
| 2183 | assert!(l(t.e1) < l(t.e2) && l(t.e2) < l(t.e3) && l(t.e3) < l(t.e4)); |
| 2184 | |
| 2185 | for kind in super::ClipKind::ALL { |
| 2186 | let c = t.clip(kind); |
| 2187 | |
| 2188 | assert!(ratio(c.label, c.strip) >= 4.0, "{kind:?} name on strip"); |
| 2189 | assert!(ratio(c.ink, c.body) >= 4.5, "{kind:?} ink on body"); |
| 2190 | } |
| 2191 | } |
| 2192 | |
| 2193 | use super::{AccentId, AccentSpec}; |
| 2194 | |
| 2195 | fn spec(id: AccentId, vivid: u8, custom: u32) -> AccentSpec { |
| 2196 | AccentSpec { id, vivid, custom } |
| 2197 | } |
| 2198 | |
| 2199 | |
| 2200 | |
| 2201 | #[test] |
| 2202 | fn every_preset_meets_contrast_on_every_family() { |
| 2203 | for id in super::PaletteId::ALL { |
| 2204 | for a in super::AccentId::ALL.into_iter().filter(|a| *a != AccentId::Custom) { |
| 2205 | let t = super::tokens_with(id, spec(a, 50, super::CUSTOM_DEFAULT)); |
| 2206 | for bg in [t.e0, t.e1, t.e2] { |
| 2207 | assert!(ratio(t.accent, bg) >= 3.0, "{a:?} ring on {id:?}"); |
| 2208 | } |
| 2209 | assert!(ratio(t.on_accent, t.accent_fill) >= 4.5, "{a:?} label on fill"); |
| 2210 | assert!(ratio(t.on_accent, t.accent_press) >= 4.5, "{a:?} label on press"); |
| 2211 | assert!(ratio(t.accent_hover, t.e1) >= 3.0, "{a:?} hover"); |
| 2212 | } |
| 2213 | } |
| 2214 | } |
| 2215 | |
| 2216 | #[test] |
| 2217 | fn oklch_round_trips_every_colour() { |
| 2218 | for r in (0..=255).step_by(15) { |
| 2219 | for g in (0..=255).step_by(15) { |
| 2220 | for b in (0..=255).step_by(15) { |
| 2221 | let rgb = (r << 16) | (g << 8) | b; |
| 2222 | let (l, c, h) = super::to_oklch(rgb); |
| 2223 | assert_eq!(super::from_oklch(l, c, h), rgb, "{rgb:06x}"); |
| 2224 | } |
| 2225 | } |
| 2226 | } |
| 2227 | } |
| 2228 | |
| 2229 | #[test] |
| 2230 | fn vivid_50_is_the_designed_colour_and_the_ends_move_chroma_only() { |
| 2231 | for a in AccentId::ALL { |
| 2232 | let (base, hover, _) = a.base(0x3ddc97); |
| 2233 | let t = super::tokens_with(super::PaletteId::Darkroom, spec(a, 50, 0x3ddc97)); |
| 2234 | assert_eq!((t.accent, t.accent_hover), (base, hover), "{a:?}"); |
| 2235 | let chroma = |v| super::to_oklch(super::vivid_adjust(base, v)).1; |
| 2236 | assert!(chroma(0) < chroma(50) && chroma(50) < chroma(100), "{a:?}"); |
| 2237 | let (l0, _, h0) = super::to_oklch(base); |
| 2238 | for v in [0, 100] { |
| 2239 | let (l, c, h) = super::to_oklch(super::vivid_adjust(base, v)); |
| 2240 | assert!((l - l0).abs() < 0.02, "{a:?} lightness at {v}"); |
| 2241 | if c > 0.02 { |
| 2242 | assert!((h - h0).abs() < 4., "{a:?} hue at {v}"); |
| 2243 | } |
| 2244 | } |
| 2245 | } |
| 2246 | } |
| 2247 | |
| 2248 | |
| 2249 | #[test] |
| 2250 | fn a_custom_colour_is_kept_and_its_label_is_the_better_of_ink_and_white() { |
| 2251 | for hex in [0x000000, 0xffffff, 0x0000ff, 0xff4d8d, 0x3ddc97, 0x123456] { |
| 2252 | let t = super::tokens_with(super::PaletteId::Darkroom, spec(AccentId::Custom, 50, hex)); |
| 2253 | assert_eq!(t.accent, hex); |
| 2254 | assert_eq!(t.accent_fill, hex); |
| 2255 | let score = |ink| ratio(ink, hex).min(ratio(ink, t.accent_press)); |
| 2256 | assert!(score(t.on_accent) >= score(0xffffff), "{hex:06x}"); |
| 2257 | } |
| 2258 | } |
| 2259 | |
| 2260 | #[test] |
| 2261 | fn accent_files_parse_old_and_new() { |
| 2262 | use super::parse_accent as p; |
| 2263 | assert_eq!(p("rose\n"), (AccentId::Rose, 100, None)); |
| 2264 | assert_eq!(p("accent=plum\nvivid=80\ncustom=#3ddc97\n"), (AccentId::Plum, 80, Some(0x3ddc97))); |
| 2265 | assert_eq!(p("accent=custom\nvivid=500\n"), (AccentId::Custom, 100, None)); |
| 2266 | assert_eq!(p("garbage\nvivid=x\ncustom=#12\n=\n\0"), (AccentId::Sage, 100, None)); |
| 2267 | assert_eq!(p(""), (AccentId::Sage, 100, None)); |
| 2268 | assert_eq!(super::parse_hex("3DDC97"), Some(0x3ddc97)); |
| 2269 | assert_eq!(super::parse_hex("#3ddc9"), None); |
| 2270 | assert_eq!(super::parse_hex("#3ddc9g"), None); |
| 2271 | } |
| 2272 | |
| 2273 | #[test] |
| 2274 | fn accent_names_round_trip_and_switching_changes_tokens() { |
| 2275 | for a in super::AccentId::ALL { |
| 2276 | assert_eq!(super::AccentId::from_name(a.name()), Some(a)); |
| 2277 | } |
| 2278 | assert_eq!(super::AccentId::from_name("nope"), None); |
| 2279 | assert_eq!(super::AccentId::DEFAULT, super::AccentId::Sage); |
| 2280 | let sage = super::tokens_with(super::PaletteId::Darkroom, spec(AccentId::Sage, 50, 0)); |
| 2281 | let rose = super::tokens_with(super::PaletteId::Darkroom, spec(AccentId::Rose, 50, 0)); |
| 2282 | assert_ne!(sage.accent, rose.accent); |
| 2283 | } |
| 2284 | |
| 2285 | |
| 2286 | #[test] |
| 2287 | fn every_palette_derives_a_rising_ladder_and_legible_inks() { |
| 2288 | use super::{PaletteId, tokens_of}; |
| 2289 | for id in PaletteId::ALL { |
| 2290 | let t = tokens_of(id); |
| 2291 | let l = luminance; |
| 2292 | assert!(l(t.e0) < l(t.e1) && l(t.e1) < l(t.e2) && l(t.e2) < l(t.e3), "{id:?}"); |
| 2293 | assert!(l(t.e3) < l(t.e4), "{id:?} pressed above hover"); |
| 2294 | for bg in [t.e0, t.e1, t.e2, t.e3, t.e4] { |
| 2295 | assert!(ratio(t.ink1, bg) >= 4.5, "{id:?} ink1 on {bg:06x}"); |
| 2296 | } |
| 2297 | for bg in [t.e0, t.e1, t.e2, t.e3] { |
| 2298 | assert!(ratio(t.ink2, bg) >= 4.5, "{id:?} ink2 on {bg:06x}"); |
| 2299 | } |
| 2300 | } |
| 2301 | } |
| 2302 | |
| 2303 | #[test] |
| 2304 | fn mix_and_alpha_helpers() { |
| 2305 | assert_eq!(super::mix(0x000000, 0xffffff, 0.5), 0x808080); |
| 2306 | assert_eq!(super::mix(0x123456, 0xffffff, 0.0), 0x123456); |
| 2307 | assert_eq!(super::with_alpha(0x3d8bff, 0x33), 0x3d8bff33); |
| 2308 | } |
| 2309 | } |