9eaa8d18c0
One hue per variant (brightness steps for roles, statuses and chat colours, with cross/ring glyphs where hue alone told status), square corners, 1px phosphor frames, a faint text glow and a static scanline and vignette pattern painted once in its own repaint boundary. Light mode is a paper-white phosphor. Terminal's theme builder is shared, not forked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
119 lines
4.2 KiB
Dart
119 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'app_design_tokens.dart';
|
|
|
|
/// A CRT phosphor: the one hue Retro CRT draws everything in, and how light
|
|
/// its normal text glows on the dark tube ([text] lightness), since equal
|
|
/// lightness looks brighter in amber than in green.
|
|
enum CrtPhosphor {
|
|
/// P1 green, `#33FF66` text on a green-black tube.
|
|
green(135, 0.60),
|
|
|
|
/// P3 amber, `#FFAA00` text on a brown-black tube.
|
|
amber(40, 0.50);
|
|
|
|
const CrtPhosphor(this.hue, this.text);
|
|
|
|
/// The phosphor's hue in degrees.
|
|
final double hue;
|
|
|
|
/// The HSL lightness of normal text on the dark tube.
|
|
final double text;
|
|
|
|
/// The phosphor at [lightness] and [saturation].
|
|
Color at(double lightness, [double saturation = 1]) =>
|
|
HSLColor.fromAHSL(1, hue, saturation, lightness).toColor();
|
|
}
|
|
|
|
/// The lightness steps of one phosphor, darkest page to brightest glow (dark
|
|
/// tube) or palest page to deepest ink (paper-white phosphor in light).
|
|
/// Brightness, never hue, tells roles apart: dim secondary text, normal text,
|
|
/// a brighter accent, a brighter warning and the brightest error (each of
|
|
/// those statuses also has its own glyph or icon).
|
|
class CrtRamp {
|
|
CrtRamp(this.phosphor, this.brightness);
|
|
|
|
final CrtPhosphor phosphor;
|
|
final Brightness brightness;
|
|
|
|
bool get _dark => brightness == Brightness.dark;
|
|
|
|
/// A surface step: pages and containers, barely tinted.
|
|
Color surface(double darkL, double lightL) =>
|
|
phosphor.at(_dark ? darkL : lightL, _dark ? 0.45 : 0.40);
|
|
|
|
Color get page => surface(0.03, 0.93);
|
|
Color get frame => phosphor.at(_dark ? 0.20 : 0.70, _dark ? 0.75 : 0.32);
|
|
Color get outline => phosphor.at(_dark ? 0.32 : 0.48, _dark ? 0.75 : 0.40);
|
|
Color get dim => phosphor.at(_dark ? 0.42 : 0.28, 0.70);
|
|
Color get text => phosphor.at(_dark ? phosphor.text : 0.17);
|
|
Color get accent => phosphor.at(_dark ? phosphor.text + 0.15 : 0.22);
|
|
Color get warning => phosphor.at(_dark ? phosphor.text + 0.20 : 0.12);
|
|
|
|
/// Success sits below normal text: a finished call is the calm case, so
|
|
/// the brighter steps are left for what needs a look.
|
|
Color get success => phosphor.at(_dark ? phosphor.text - 0.16 : 0.28);
|
|
Color get error => phosphor.at(_dark ? 0.93 : 0.07);
|
|
|
|
/// A container tone under [ink]: dark tube containers glow a little, the
|
|
/// light page's sit a step deeper than the page.
|
|
Color container(double darkL, double lightL) =>
|
|
phosphor.at(_dark ? darkL : lightL, _dark ? 0.6 : 0.45);
|
|
|
|
/// The status accents, as brightness steps: success a step below normal
|
|
/// text, running a step above it, waiting and warnings brighter, errors
|
|
/// brightest.
|
|
AnsiAccents get ansi => AnsiAccents(
|
|
green: success,
|
|
cyan: phosphor.at(_dark ? phosphor.text - 0.08 : 0.24),
|
|
yellow: warning,
|
|
red: error,
|
|
magenta: dim,
|
|
blue: accent,
|
|
);
|
|
}
|
|
|
|
/// Retro CRT's colour scheme for [phosphor] in [brightness]: every colour a
|
|
/// shade of the one hue.
|
|
ColorScheme crtColorScheme(CrtPhosphor phosphor, Brightness brightness) {
|
|
final r = CrtRamp(phosphor, brightness);
|
|
final page = r.page;
|
|
return ColorScheme(
|
|
brightness: brightness,
|
|
primary: r.accent,
|
|
onPrimary: page,
|
|
primaryContainer: r.container(0.14, 0.82),
|
|
onPrimaryContainer: r.accent,
|
|
secondary: r.text,
|
|
onSecondary: page,
|
|
secondaryContainer: r.container(0.11, 0.86),
|
|
onSecondaryContainer: r.text,
|
|
tertiary: r.warning,
|
|
onTertiary: page,
|
|
tertiaryContainer: r.container(0.17, 0.78),
|
|
onTertiaryContainer: r.warning,
|
|
error: r.error,
|
|
onError: page,
|
|
errorContainer: r.container(0.20, 0.74),
|
|
onErrorContainer: r.error,
|
|
surface: page,
|
|
onSurface: r.text,
|
|
onSurfaceVariant: r.dim,
|
|
surfaceDim: page,
|
|
surfaceBright: r.surface(0.14, 0.97),
|
|
surfaceContainerLowest: r.surface(0.02, 0.97),
|
|
surfaceContainerLow: r.surface(0.05, 0.90),
|
|
surfaceContainer: r.surface(0.065, 0.87),
|
|
surfaceContainerHigh: r.surface(0.08, 0.84),
|
|
surfaceContainerHighest: r.surface(0.10, 0.80),
|
|
outline: r.outline,
|
|
outlineVariant: r.frame,
|
|
shadow: const Color(0xFF000000),
|
|
scrim: const Color(0xFF000000),
|
|
inverseSurface: r.text,
|
|
onInverseSurface: page,
|
|
inversePrimary: r.dim,
|
|
surfaceTint: const Color(0x00000000),
|
|
);
|
|
}
|