nodes/theme.py¶
Part of You’re the OS.
1"""Colour palette and process-face glyph map.
2
3Mirrors the upstream palette and its starvation-emoji ordering. The palette is
4kept whole (a few entries are unused here) so the two can be compared entry for
5entry; the emoji PNGs are substituted with ASCII faces, so the port ships with
6no image assets at all.
7"""
8
9from __future__ import annotations
10
11
12# RGBA in 0..1, opaque
13def _rgb(r: int, g: int, b: int, a: float = 1.0) -> tuple[float, float, float, float]:
14 return (r / 255.0, g / 255.0, b / 255.0, a)
15
16
17BLACK = _rgb(0, 0, 0)
18ALMOST_BLACK = _rgb(25, 25, 25)
19DARK_BG = _rgb(0, 0, 0) # background: match upstream's pure black
20WHITE = _rgb(255, 255, 255)
21GREY = _rgb(128, 128, 128)
22DARK_GREY = _rgb(99, 102, 106)
23LIGHT_GREY = _rgb(211, 211, 211)
24BLUE = _rgb(0, 0, 255)
25LIGHT_BLUE = _rgb(176, 216, 230)
26TEAL = _rgb(0, 128, 128)
27GREEN = _rgb(0, 255, 0)
28YELLOW = _rgb(255, 255, 0)
29ORANGE = _rgb(255, 165, 0)
30RED = _rgb(255, 0, 0)
31DARK_RED = _rgb(139, 0, 0)
32DARKER_RED = _rgb(80, 0, 0)
33LIME_GREEN = _rgb(177, 204, 51)
34
35# Indexed by Process.starvation_level (0..6).
36STARVATION_COLOURS = [
37 GREEN,
38 YELLOW,
39 ORANGE,
40 RED,
41 DARK_RED,
42 DARKER_RED,
43 DARK_GREY,
44]
45
46# ASCII face glyphs used in place of upstream's emoji PNGs (zero asset deps).
47STARVATION_FACES = [
48 ":D", # grinning
49 ":)", # slightly smiling
50 ":|", # neutral
51 ":(", # frowning
52 ":'(", # crying
53 "x(", # cold
54 "X_X", # skull
55]
56
57GRACEFUL_FACE = ":3" # stands in for upstream's haloed "happy departure" emoji
58
59__all__ = [
60 "BLACK",
61 "ALMOST_BLACK",
62 "DARK_BG",
63 "WHITE",
64 "GREY",
65 "DARK_GREY",
66 "LIGHT_GREY",
67 "BLUE",
68 "LIGHT_BLUE",
69 "TEAL",
70 "GREEN",
71 "YELLOW",
72 "ORANGE",
73 "RED",
74 "DARK_RED",
75 "DARKER_RED",
76 "LIME_GREEN",
77 "STARVATION_COLOURS",
78 "STARVATION_FACES",
79 "GRACEFUL_FACE",
80]