Skip to content

The Algebra of Color Design

Context: The physics and grammar of the color system.1

This document defines the “Physics” of the color system. It replaces the previous static heuristic model with a Reactive Physics Model based on continuous state interpolation.

Definition 1 (State Configuration Σ\Sigma). The system configuration is a 5-tuple Σ=⟨α,V,τ,γ,μ⟩\Sigma = \langle \alpha, \mathcal{V}, \tau, \gamma, \mu \rangle where:

  1. Atmosphere (α\alpha): The environmental vector α=⟨H,β⟩\alpha = \langle H, \beta \rangle.
    • H∈S1H \in S^1: Hue. The base angle of the environment.
    • β∈[0,1]\beta \in [ 0, 1 ]: Vibrancy Coefficient. A scalar multiplier acting on the maximum potential chroma (CC) of the environment.
  2. Voice (V\mathcal{V}): The semantic intent.
    • Let TT be the set of pre-solved lightness constants derived by the lighting function fLf_L (see Section 2.1).
    • V∈T\mathcal{V} \in T: A reference to a specific semantic intent (e.g., High Contrast).
  3. Time (τ\tau): The normalized temporal parameter.
    • τ∈[−1,1]\tau \in [ -1, 1 ]: Represents the shift from Night (−1-1) to Day (+1+1).
  4. Gain (γ\gamma): The user’s contrast preference.
    • γ∈[1,∞)\gamma \in [ 1, \infty ). Amplifies the Voice (V\mathcal{V}) target contrast. Used for High Contrast Mode.
  5. Mode (μ\mu): The rendering technique.
    • μ∈{0,1}\mu \in \{ 0, 1 \}:
      • 0: Rich Mode (Standard).
      • 1: X-Ray Mode (Forced Colors).2

2. The Architecture: Static Initialization vs. Runtime Algebra

Section titled “2. The Architecture: Static Initialization vs. Runtime Algebra”

The system is explicitly split into two domains to guarantee performance and correctness.

2.1. Pre-Computation Routine (Static Phase)

Section titled “2.1. Pre-Computation Routine (Static Phase)”

The initialization routine3 solves the “Hard Math” (APCA Contrast) offline. It calculates the exact Lightness (LL) required for a specific Voice (V\mathcal{V}) to be legible against a specific background.

It also applies a Helmholtz-Kohlrausch Buffer to offset the perceptual lightness of vibrant colors.

Ψ(K,τ)→VconstantLtarget=LAPCA+(khk⋅β)\begin{aligned} \Psi(K, \tau) &\to \mathcal{V}_{\text{constant}} \\ L_{\text{target}} &= L_{\text{APCA}} + (k_{hk} \cdot \beta) \end{aligned}

These constants are baked into the CSS as variables (e.g., --text-high-L: 98%).

The Algebra (CSS Engine)4 is a “Switching Mixer.” It resolves the final color based on the System Mode (μ\mu).

Φ(Σ)={Φrich(α,V,τ,γ)if μ=0Φxray(α,V)if μ=1\Phi(\Sigma) = \begin{cases} \Phi_{\text{rich}}(\alpha, \mathcal{V}, \tau, \gamma) & \text{if } \mu = 0 \\ \Phi_{\text{xray}}(\alpha, \mathcal{V}) & \text{if } \mu = 1 \end{cases}

Classes in the system are Operators that transform the state Σ→Σ′\Sigma \to \Sigma'.

We distinguish between two topological types of surfaces.

3.1.1. Glass Surfaces (SglassS_{\text{glass}})

Section titled “3.1.1. Glass Surfaces (SglassS_{\text{glass}})”

Glass surfaces are Filters. They inherit the Atmosphere (α\alpha) from their parent but apply Bicone Dampening to ensure the background remains a subtle tint, safe for text.

Sglass(⟨α,V,τ⟩)=⟨Dampen(α),Vreset,τ⟩S_{\text{glass}}(\langle \alpha, \mathcal{V}, \tau \rangle) = \langle \text{Dampen}(\alpha), \mathcal{V}_{\text{reset}}, \tau \rangle

3.1.2. Solid Surfaces (SsolidS_{\text{solid}})

Section titled “3.1.2. Solid Surfaces (SsolidS_{\text{solid}})”

Solid surfaces are Emitters. They represent “pre-calculated pairs” (like Primary Buttons) where the color is derived at build-time to be maximal. They do not dampen. They establish a new Atmosphere.

Ssolid(⟨α,V,τ⟩)=⟨αnew,Vnew,τ⟩S_{\text{solid}}(\langle \alpha, \mathcal{V}, \tau \rangle) = \langle \alpha_{\text{new}}, \mathcal{V}_{\text{new}}, \tau \rangle

4. The Universal Safety Theorem (Adaptive Clamping)

Section titled “4. The Universal Safety Theorem (Adaptive Clamping)”

To guarantee that text is always readable on Glass Surfaces in Rich Mode, we enforce the Universal Safety Theorem. The Chroma (CC) of any Glass Surface is mathematically constrained to lie within the Safe Bicone.

4.1. The Vibrancy Limit (ClimitC_{\text{limit}})

Section titled “4.1. The Vibrancy Limit (ClimitC_{\text{limit}})”

The maximum allowed Chroma is the intersection of three functions:

Climit=β(H)⋅Taper(L)⋅ζ(τ)C_{\text{limit}} = \beta(H) \cdot \text{Taper}(L) \cdot \zeta(\tau)
  1. The Sine Wave (β(H)\beta(H)): The hue-dependent boundary.

    β(H)=Cfloor+(Cceil−Cfloor)⋅(1+sin⁡(H+ϕ)2)\beta(H) = C_{\text{floor}} + (C_{\text{ceil}} - C_{\text{floor}}) \cdot \left( \frac{1 + \sin(H + \phi)}{2} \right)
  2. The Bicone Taper (Taper(L)\text{Taper}(L)): The lightness-dependent boundary. Defined as a Linear Taper (Absolute Value).

    Taper(L)=1−∣2L−1∣\text{Taper}(L) = 1 - |2L - 1|
  3. The Tunnel (ζ(τ)\zeta(\tau)): The motion-dependent boundary. Defined as a Parabolic Ease function.

    ζ(τ)=τ2\zeta(\tau) = \tau^2

    5

For Glass Surfaces, the resolved Chroma is the minimum of the requested Vibrancy and the Limit.

Cresolved=min⁡(Crequested,Climit)C_{\text{resolved}} = \min(C_{\text{requested}}, C_{\text{limit}})

When μ=1\mu = 1 (Forced Colors), the system enters X-Ray Mode.

  • Physics is Disabled: The Bicone/Tunnel math is skipped.
  • Topology is Transformed: Surfaces are no longer defined by Area (Background Color) but by Boundary (Border).
P(α)→BorderWidth×SystemColorP(\alpha) \to \text{BorderWidth} \times \text{SystemColor}

This ensures that the semantic structure of the UI is preserved even when the operating system strips all background colors.

  1. State is Unified: Σ=⟨α,V,τ,γ,μ⟩\Sigma = \langle \alpha, \mathcal{V}, \tau, \gamma, \mu \rangle.
  2. Safety is Geometric: The Safe Bicone ensures text legibility by clamping Chroma linearly.
  3. Mode is Topological: Rich Mode paints pixels; X-Ray Mode draws lines (The Hollow State).
  4. Execution is Split: The initialization routine solves the goals; Algebra enforces the constraints.