What does Design-Token Algebra conclude, in numbers, about “Perceptually Uniform Colour Spaces: From sRGB to CIELAB, CIEDE2000 and OKLab”?
Answer: The first intuition is "half the code is mid-grey". The grey at code 128, #808080, has a CIELAB lightness of 53.59, more than three units brighter than the midpoint of 50. The grey closest to lightness 50 is #777777, code 119, at 50.03. The reason is that sRGB codes are not linear light; they are encoded through a power-shaped curve, computed step by step in the next section.
Scope of the numbers: All brands, sites, colours and ratings are invented, every calculation comes from the book's programs, and legal matters are described only in general terms, not as legal advice. Each hypothesis states what would refute it.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 119, 128, 50, 50.03, 53.59, 777777
| step-by-step for gold.500 #B8913F | |
| 1 8-bit codes R 184 G 145 B 63 | |
| 2 divided by 255 | 0.721569 0.568627 0.247059 |
| 3 linearised | 0.479320 0.283149 0.049707 |
| 4 XYZ (Y of white | 1) X 0.307898 Y 0.308000 Z 0.090248 |
| reference white Xn 0.9505 Yn 1.0000 Zn 1.0890 | |
| 5 ratios to white | 0.323932 0.308000 0.082873 |
| 6 f(ratio), cube root | 0.686781 0.675332 0.435984 |
| 7 L* | 116 fy - 16 = 62.3385 ; a* = 500 (fx - fy) = 5.7246 ; b* = 200 (fy - fz) = 47.8695 |
| C* | 48.2106 ; hue angle h = 83.18 deg |
| by hand | 0.675^3 = 0.3075 ; 0.6753^3 = 0.30796 ; so fy is a little above 0.6753 |
| by hand | 116 x 0.675332 = 78.3385 ; 0.686781 - 0.675332 = 0.011449 ; x 500 = 5.7245 |
| token hex L* a* b* C* h(deg) round-trip | |
| ink.950 #111114 | 5.15 0.64 -1.73 1.85 290.2 #111114 |
| ink.900 #1B1B20 | 9.96 1.35 -3.44 3.70 291.4 #1B1B20 |
| ink.700 #3A3A42 | 24.70 1.92 -4.92 5.28 291.3 #3A3A42 |
| ink.500 #6B6B76 | 45.56 2.36 -6.11 6.55 291.1 #6B6B76 |
| ink.300 #A4A4AD | 67.62 1.75 -4.64 4.96 290.7 #A4A4AD |
| ink.100 #E4E2DC | 89.88 -0.38 3.16 3.19 96.8 #E4E2DC |
| ink.050 #F7F5F0 | 96.56 -0.20 2.64 2.64 94.4 #F7F5F0 |
| white #FFFFFF | 100.00 0.00 0.00 0.00 0.0 #FFFFFF |
| gold.700 #7A5E2A | 41.70 5.18 33.51 33.91 81.2 #7A5E2A |
| gold.500 #B8913F | 62.34 5.72 47.87 48.21 83.2 #B8913F |
| gold.300 #DDC58E | 80.32 0.62 30.71 30.72 88.8 #DDC58E |
| wine.700 #8C2F39 | 33.78 40.16 15.51 43.05 21.1 #8C2F39 |
| wine.300 #EA8F92 | 68.91 34.79 13.17 37.20 20.7 #EA8F92 |
| cobalt.700 #1F5FA8 | 40.09 7.15 -44.85 45.42 279.1 #1F5FA8 |
| cobalt.300 #83B5F3 | 72.46 -0.26 -35.96 35.96 269.6 #83B5F3 |
Show the full program
# Chapter 3. p30: sRGB hex -> linear -> XYZ (D65) -> CIELAB, every step printed, for the Hengyu primitives.
# Transfer function and matrix: IEC 61966-2-1 (sRGB), four-decimal matrix. Reference white = the row sums of
# that matrix, so #FFFFFF maps to exactly L* 100, a* 0, b* 0. CIELAB constants: CIE 15 (epsilon = 216/24389,
# kappa = 24389/27). The primitive colours are the fictional Hengyu token set of chapter 2 (programs p20-p24).
import math
M = ((0.4124, 0.3576, 0.1805),
(0.2126, 0.7152, 0.0722),
(0.0193, 0.1192, 0.9505))
WHITE = tuple(math.fsum(r) for r in M)
WHITE_D65_5DP = (0.95047, 1.0, 1.08883)
EPS, KAPPA = 216 / 24389, 24389 / 27
PRIMS = {
"ink.950": "#111114", "ink.900": "#1B1B20", "ink.700": "#3A3A42", "ink.500": "#6B6B76",
"ink.300": "#A4A4AD", "ink.100": "#E4E2DC", "ink.050": "#F7F5F0", "white": "#FFFFFF",
"gold.700": "#7A5E2A", "gold.500": "#B8913F", "gold.300": "#DDC58E",
"wine.700": "#8C2F39", "wine.300": "#EA8F92", "cobalt.700": "#1F5FA8", "cobalt.300": "#83B5F3",
"jade.600": "#2E7D5B", "jade.300": "#4EC894", "violet.700": "#6B4FA0", "violet.300": "#B7ABD8",
"red.600": "#C33A32", "red.400": "#F07A72",
}
def hex_to_rgb8(h):
return tuple(int(h[i:i + 2], 16) for i in (1, 3, 5))
def lin(c, cut=0.04045):
return c / 12.92 if c <= cut else ((c + 0.055) / 1.055) ** 2.4
def gam(c):
return 12.92 * c if c <= 0.0031308 else 1.055 * c ** (1 / 2.4) - 0.055
def xyz(rgb_lin):
return tuple(math.fsum(m * c for m, c in zip(row, rgb_lin)) for row in M)
def f(t):
return t ** (1 / 3) if t > EPS else (KAPPA * t + 16) / 116
def lab(h, white=WHITE):
x, y, z = xyz([lin(c / 255) for c in hex_to_rgb8(h)])
fx, fy, fz = f(x / white[0]), f(y / white[1]), f(z / white[2])
return 116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)
def lab_to_hex(L, a, b):
fy = (L + 16) / 116
fx, fz = fy + a / 500, fy - b / 200
def finv(t):
return t ** 3 if t ** 3 > EPS else (116 * t - 16) / KAPPA
X, Y, Z = finv(fx) * WHITE[0], finv(fy) * WHITE[1], finv(fz) * WHITE[2]
det = (M[0][0] * (M[1][1] * M[2][2] - M[1][2] * M[2][1])
- M[0][1] * (M[1][0] * M[2][2] - M[1][2] * M[2][0])
+ M[0][2] * (M[1][0] * M[2][1] - M[1][1] * M[2][0]))
inv = [[(M[(j + 1) % 3][(i + 1) % 3] * M[(j + 2) % 3][(i + 2) % 3]
- M[(j + 1) % 3][(i + 2) % 3] * M[(j + 2) % 3][(i + 1) % 3]) / det for j in range(3)]
for i in range(3)]
rgb = [math.fsum(inv[i][k] * v for k, v in enumerate((X, Y, Z))) for i in range(3)]
return "#" + "".join("%02X" % max(0, min(255, round(gam(c) * 255))) for c in rgb)
def main():
h = PRIMS["gold.500"]
r8 = hex_to_rgb8(h)
print("step-by-step for gold.500 %s" % h)
print(" 1 8-bit codes R %d G %d B %d" % r8)
nrm = [c / 255 for c in r8]
print(" 2 divided by 255 %.6f %.6f %.6f" % tuple(nrm))
li = [lin(c) for c in nrm]
print(" 3 linearised %.6f %.6f %.6f" % tuple(li))
X, Y, Z = xyz(li)
print(" 4 XYZ (Y of white = 1) X %.6f Y %.6f Z %.6f" % (X, Y, Z))
print(" reference white Xn %.4f Yn %.4f Zn %.4f" % WHITE)
ts = (X / WHITE[0], Y / WHITE[1], Z / WHITE[2])
print(" 5 ratios to white %.6f %.6f %.6f" % ts)
fs = [f(t) for t in ts]
print(" 6 f(ratio), cube root %.6f %.6f %.6f" % tuple(fs))
L, a, b = 116 * fs[1] - 16, 500 * (fs[0] - fs[1]), 200 * (fs[1] - fs[2])
print(" 7 L* = 116 fy - 16 = %.4f ; a* = 500 (fx - fy) = %.4f ; b* = 200 (fy - fz) = %.4f" % (L, a, b))
print(" C* = %.4f ; hue angle h = %.2f deg" % (math.hypot(a, b), math.degrees(math.atan2(b, a)) % 360))
print(" by hand: 0.675^3 = %.4f ; 0.6753^3 = %.5f ; so fy is a little above 0.6753"
% (0.675 ** 3, 0.6753 ** 3))
print(" by hand: 116 x 0.675332 = %.4f ; 0.686781 - 0.675332 = %.6f ; x 500 = %.4f"
% (116 * 0.675332, 0.686781 - 0.675332, 500 * (0.686781 - 0.675332)))
print()
print("token hex L* a* b* C* h(deg) round-trip")
worst = 0
for name, hx in PRIMS.items():
L, a, b = lab(hx)
back = lab_to_hex(L, a, b)
worst = max(worst, max(abs(x - y) for x, y in zip(hex_to_rgb8(hx), hex_to_rgb8(back))))
print("%-11s %s %6.2f %7.2f %7.2f %6.2f %6.1f %s"
% (name, hx, L, a, b, math.hypot(a, b), math.degrees(math.atan2(b, a)) % 360, back))
print("largest round-trip error over %d primitives: %d code(s)" % (len(PRIMS), worst))
print()
Lw, aw, bw = lab("#FFFFFF", WHITE_D65_5DP)
print("white #FFFFFF with Xn,Zn = 0.95047, 1.08883 instead of the matrix row sums:"
" L* %.4f a* %.4f b* %.4f" % (Lw, aw, bw))
diff = [v for v in range(256) if (v / 255 <= 0.03928) != (v / 255 <= 0.04045)]
print("8-bit codes whose branch differs between cut-off 0.03928 (WCAG 2.1 text) and 0.04045: %d"
% len(diff))
print("codes 10 and 11 as fractions: %.6f and %.6f" % (10 / 255, 11 / 255))
print()
grey = min(range(256), key=lambda v: abs(lab("#%02X%02X%02X" % (v, v, v))[0] - 50))
print("#808080 (code 128, half of 255) has L* %.2f" % lab("#808080")[0])
print("the grey closest to L* 50 is #%02X%02X%02X, code %d, L* %.2f"
% (grey, grey, grey, grey, lab("#%02X%02X%02X" % (grey, grey, grey))[0]))
for hx in ("#FFFF00", "#0000FF", "#00FF00", "#FF0000"):
L, a, b = lab(hx)
print("%s (HSL lightness 50%%) has L* %.2f a* %.2f b* %.2f" % (hx, L, a, b))
if __name__ == "__main__":
main()Single source and citation
Fan, Y. (2026). Design-Token Algebra across Thirty Sites, Perceptually Uniform Colour Spaces and the Millisecond Science of Brand-Authority First Impressions (Version 0.1.0), Chapter 3: Perceptually Uniform Colour Spaces: From sRGB to CIELAB, CIEDE2000 and OKLab. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-140 · v0.1.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026140,
author = {Fan, Yafu},
title = {Design-Token Algebra across Thirty Sites, Perceptually Uniform Colour Spaces and the Millisecond Science of Brand-Authority First Impressions},
year = {2026},
publisher = {5D Library},
edition = {0.1.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · Method: Three Measures of Multi-Site Visual Drift, Grades of Evidence and the Cai-Fen Module of the Yingzao Fashi
- Chapter 2 · Token Algebra: Three Layers, Themes as Functions and the Dependency Graph of Thirty Sites
- Chapter 4 · Perceptually Uniform Ramps: Lightness Steps, Contrast Constraints, Gamut Clipping and Dark-Theme Inversion
- Chapter 5 · The 50-Millisecond First Impression: Exposure, Complexity, Prototypicality and the Distance to a Sale
- Chapter 6 · Governing Thirty Sites: Release, Drift Detection, Per-Brand Re-Theming, Audit and Rollback
- Chapter 7 · Playbooks for the Four Kinds of Site, and the Distillation Spec for the Four Kits
- Chapter 8 · Practice: Unifying the Palettes of Five Representative Hengyu Sites, with a Pre-Registered First-Impression Test