Color conversion Tests

These tests parse different color formats and then print out the coordinates in various color spaces.

sRGB to LCH

slategray 52.697472, 11.242899, 253.010088
white 100, 0.0146, NaN
black 0, 0, NaN

sRGB to (D65) XYZ

white 0.9504559270516717, 1, 1.0890577507598784

HWB to sRGB

hwb(0 20% 40%) 0.6, 0.2, 0.2
hwb(90 30% 5%) 0.625, 0.950, 0.300
hwb(30 0% 80%) 0.2, 0.1, 0
hwb(720 20% 40%) 0.6, 0.2, 0.2
hwb(-270 30% 5%) 0.625, 0.950, 0.300
hwb(0 40% 80%) 0.3333333, 0.3333333, 0.3333333
hwb(0 50% 50%) 0.5, 0.5, 0.5

sRGB to HWB

rgb(60% 20% 20%) 0, 20, 40
black NaN, 0, 100
white NaN, 100, 0

Out of RGB gamut conversions

color(rec2020 0 0 1) 230.639, -29.921, -5.0489
color(rec2020 0 0 1) 230.639, 179.655, 37.564
color(rec2020 0 0 1) 230.639, 128.483, 105.0489

sRGB to HSL

black NaN, 0, 0
white NaN, 0, 100

P3 to sRGB

color(display-p3 0.47 0.47 0.47) 0.47, 0.47, 0.47
color(display-p3 1 1 1) 1, 1, 1
color(display-p3 -0.1 -0.1 -0.1) -0.1, -0.1, -0.1
color(display-p3 0.238 0.532 0.611) 0.019595, 0.54027, 0.621351
color(display-p3 1 0 0) 1.09299, -0.226745, -0.150155
color(display-p3 0 1 0) -0.511567, 1.018276, -0.310711
color(display-p3 0 0 1) 0, 0, 1.042131

rec2100pq to XYZ and back

color(rec2100-pq 0.3720 0.3720 0.3720) 0.11118, 0.11698, 0.12740
color(xyz 0.11118, 0.11698, 0.12740) 0.3720, 0.3720, 0.3720
white 0.5807, 0.5807, 0.5807
color(display-p3 1 0 0) 0.5514, 0.2939, 0
color(display-p3 0 1 0) 0.4200, 0.5744, 0.2248
color(display-p3 0 0 1) 0.2970, 0.2026, 0.5790
color(rec2020 1 0 0) 0.5807, 0, 0
color(rec2020 0 1 0) 0, 0.5807, 0
color(rec2020 0 0 1) 0, 0, 0.5807

Jzazbz

Conversions to Absolute D65 XYZ tested against published Matlab code.

color(jzazbz 0.5 0 0) 7.986957, 8.397692, 9.136922
color(jzazbz 1 0 0) 48.187785, 50.665878, 55.125885
color(jzazbz 0.1 -0.05 0.05) 0.108518, 0.172874, 0.074937
color(xyz 0 0 0) 0.0, 0.0, 0.0
white 0.222065, -0.0002, -0.0001
color(rec2020 1 1 1) 0.22206525, -0.000161, -0.000117
color(jzazbz 0.22206525 -0.000161 -0.000117) 1, 1, 1
#FFFF80 0.212398, -0.0171, 0.0914
color(rec2020 1 0 0) 0.154543, 0.1643, 0.1351
color(rec2020 0 1 0) 0.160578, -0.2066, 0.1462
color(rec2020 0 0 1) 0.091785, -0.0775, -0.2047

JzCzHz

color(jzazbz 0.5 0 0) 0.5, 0, NaN
color(jzazbz 0.2 0.000004 -0.000003) 0.2, 0.000005, NaN
color(jzazbz 0.2 0.000005 -0.000005) 0.2, 0.00000707, NaN
color(jzazbz 0.1 -0.05 0.05) 0.1, 0.070710678, 135
color(jzczhz 0.1 0.070710678 135) 0.1, -0.05, 0.05
color(jzazbz 0.1 0.1 -0.08) 0.1, 0.12806248, 321.34019
color(jzczhz 0.1, 0.12806248, 321.34019) 0.1, 0.1, -0.08

ICtCp

color(xyz 0 0 0) 0.0, 0.0, 0.0
color(xyz 0.96422, 1.00000, 0.82521) 0.5820, 0.0344, 0.0001
white 0.5820, 0.0344, 0.0001
color(rec2020 1 1 1) 0.5820, 0.0344, 0.0001
color(rec2020 1 0 0) 0.4413, -0.1164, 0.3985
color(rec2020 0 1 0) 0.5305, -0.4247, -0.1219
color(rec2020 0 0 1) 0.3687, 0.2746, -0.2406
color(ictcp 0.4413 -0.1164 0.3985) 1, 0, 0
color(ictcp 0.5305 -0.4247 -0.1219) 0, 1, 0
color(ictcp 0.3687 0.2746 -0.2406) 0, 0, 1

OKLab

Conversions tested against results from published linear sRGB to OKLab C++ code (using better matrices, updated 2021-01-2)

white 1.000000, 0.000000, 0.000000
red 0.627955, 0.224863, 0.125846
lime 0.86644, -0.233888, 0.179498
blue 0.452014, -0.032457, -0.311528
cyan 0.905399, -0.149444, -0.039398
magenta 0.701674, 0.274566, -0.169156
yellow 0.967983, -0.071369, 0.198570
black 0.000000, 0.000000, 0.000000

OKLCh

white 1.0, 0.0001, NaN
red 0.627954, 0.257627, 29.2271
lime 0.866439, 0.294803, 142.5112
blue 0.452013, 0.313319, 264.058541

Linear-light sRGB

white 1.0, 1.0, 1.0
rgb(50% 50% 50%) 0.21404114, 0.21404114, 0.21404114

ACEScc to XYZ

color(acescc 1.0 1.0 1.0) 211.8195, 222.8610, 242.7084
color(acescc 0.4977169 0.4977169 0.4977169) 0.475228, 0.500000, 0.544529
color(acescc 0 0 0) 0.001127, 0.001186, 0.001291
color(acescc -0.358447, -0.358447, -0.358447) 0, 0, 0
color(acescc 1.0 0.0 0.0) 145.3586, 59.6545, -1.1981
color(acescc 0.0 1.0 0.0) 28.5798, 150.2844, 0.306392
color(acescc 0.0 0.0 1.0) 37.8833, 12.9243, 243.6027
color(acescc 1.0 0.0 0.0) 11.42071, -3.24602, -0.722011
color(acescc 0.0 1.0 0.0) -6.096756, 10.318155, -2.713562
color(acescc 0.0 0.0 1.0) -3.266071, -1.586111, 10.178351

Get coordinates

11.23415
11.23415
11.23415
0.03100055
0.11646942
0.54