Perceptually uniform colour space

It would be great to have a way to create colours according to a perceptually uniform colour space such as CIELUV or HSLuv. Here is a good explanation: Color Spaces for Human Beings. Also here: Perceptually uniform color spaces.

A nice addition to JUCE would already be a new function which would take values in the same ranges as the regular fromHSL() function, but would produce perceptually uniform colours instead.

Until then, one can add hsluv ( to one’s code and declare a free function such as:

juce::Colour juceColourFromHSLuv (float h, float s, float l, float a)
	double r, g, b; 
	hsluv2rgb (h * 360.0, s * 100.0, l * 100.0, &r, &g, &b);  
	return juce::Colour::fromFloatRGBA (float(r), float(g), float(b), a);

juceColourFromHSLuv() can then be called in the same way as the regular juce::Colour::fromHSL().

Great idea, This week I’ve been copy and pasting hexadecimal color values off a website (that calculates perceptually uniform colors) into JUCE. Which is a little painstaking.

It would also be nice to support linear color mixing, so that gradients look even. i.e. the one on the left. (on the right is JUCE-style interpolation, which appears too dark and muddy at the mid point)

Better colour mixing would be great too, good point! The gradient on the left really looks much better.

Anything one does with colours becomes much easier once one has a proper colour space. Even the JUCE logo is a good example of something for which you would want perceptually uniform colours. I think this would be used a lot if it were part of the framework.

Yes, the left bar looks much better.

Slightly off topic, but I wonder if in images something similar to audio exists, that the brighter is always perceived better than the darker image, similar to the louder mix…

Seems likely.