Hi folks just wanted to share a little library I put together to do color manipulation in Mint Tea. It’ll be used in the next release of Mint Tea, and allow us to do gradients and all sorts of nice color stuff:
This first release of colors:
Introduces RGB, LRGB, XYZ, LUV, UV types
Includes standard white reference point d65
Supports Linearizing/Delinearizing RGB
Includes conversions between ANSI, RGB, LRGB, XYZ, and LUV
Has blending for LUV and RGB (via LUV) with configurable mixing
Includes an ANSI to RGB color table
I’m hoping to keep it super small and in pure OCaml so we can use it for terminals but also other places like web, or other graphics settings.
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.