| 367 | } |
| 368 | |
| 369 | function generateMutedTextColor(bg: RGBA, isDark: boolean, map: (rgba: RGBA) => RGBA): RGBA { |
| 370 | const lum = 0.299 * bg.r * 255 + 0.587 * bg.g * 255 + 0.114 * bg.b * 255 |
| 371 | const gray = isDark |
| 372 | ? lum < 10 |
| 373 | ? 180 |
| 374 | : Math.min(Math.floor(160 + lum * 0.3), 200) |
| 375 | : lum > 245 |
| 376 | ? 75 |
| 377 | : Math.max(Math.floor(100 - (255 - lum) * 0.2), 60) |
| 378 | |
| 379 | return map(RGBA.fromInts(gray, gray, gray)) |
| 380 | } |
| 381 | |
| 382 | export function generateSystem(colors: TerminalColors, pick: "dark" | "light"): ThemeJson { |
| 383 | const bg_snapshot = RGBA.fromHex(colors.defaultBackground ?? colors.palette[0]!) |