The main reasons are:
-
usability – its trivial for folks to put tag triples with their color profile – if you have 3 floats you can pack 'em up and say “this is an
`rgb
or an`xyz
color”. -
flexibility – some functions can work over multiple types of colors, say a generic mixer/blender can just say its input type is
[ rgb | xyz ] -> xyz
.Other functions like the pretty printer can take in all colors so their type is
[ rgb | lrgb | xyz | luv | ansi ]
-
extensibility – if you’re currently handling any colors, we can still add new profiles without breaking your code.
We could’ve used a record too for each type: {r;g;b}
, {x;y;z}
, {sr;sg;sb}
, etc, but the tuple of int/float felt the most ergonomic.
I’m a big fan of the maximum type-safety that will not get in the way of DX.