There are 256 terminal color escapes available:
- 8 "system" colors (0 - 7)
- 8 "bright" system colors (8 - 15)
- 216, or 6*6*6 "RGB" colors (16 - 231)
- 24 "grayscale" colors (232 - 255)
The "RGB" colors are what I'm wondering about.
The first six colors, from 16 to 21, map to the following hex RGB values:
- 16: 000000
- 17: 000054
- 18: 000087
- 19: 0000af
- 20: 0000d7
- 21: 0000ff
Now the blue values only, in decimal:
- 16: 0
- 17: 84
- 18: 135
- 19: 175
- 20: 215
- 21: 255
In other words, the RGB value goes up by 84, then 51 (84 + 51 = 135), then 40 the rest of the way.
This cycle of 6 values from 0 to 255 is repeated 36 times, first with blue, then green, then red, eventually forming our "cube" of 216 terminal colors:
My question is: Why?
Does anyone know if there is a historical/technical reason for this, or was it just an arbitrary decision made by whoever had to decide what the color codes meant? Did this mapping come to exist before RGB was such a universal convention? Why not go up by 42, 42, 42, 43, 43, 43?