color icon indicating copy to clipboard operation
color copied to clipboard

Color Temperature

Open DaAwesomeP opened this issue 1 year ago • 3 comments

Hello,

We are using this library to control and visualize LED luminaries/fixtures and it has been immensely useful.

Some of our fixtures work with color temperatures instead of colors. This consists of a Kelvin temperature and a brightness. Would it be possible to implement this scale? I think it would be similar to the GRAY method at least for the brightness part.

https://en.wikipedia.org/wiki/Color_temperature

Here is a Correlated Color Temperature (CCT) conversion example in Python (from the very popular Colour library): https://colour.readthedocs.io/en/develop/_modules/colour/temperature/hernandez1999.html

Similar to the GRAY model, any color can be mapped/correlated to color temperature, but converting the other direction will not result in the original input.

DaAwesomeP avatar Aug 31 '22 19:08 DaAwesomeP

I guess that brightness might actually be implemented as alpha? What would be most consistent with the library?

DaAwesomeP avatar Aug 31 '22 19:08 DaAwesomeP

Another idea: ::color::rgb c; std::cout << ::color::get::temperature( c ) << std::endl;

Due to extensive calculation might be better to restrict to xyz space. ::color::xyz x; std::cout << ::color::get::temperature( x ) << std::endl;

Currently I stop API extension to avoid API bloating. This feature might be able to pass that restriction. I need time to think about that.

dmilos avatar Sep 02 '22 08:09 dmilos

OK, let me know! I can work on a PR.

I am definitely most interested in treating it as a class/type rather than just a method, as then it will have its own memory footprint just like the others. Currently I use a template class to select the color space and then abstract out writing the channels to fixtures by index.

DaAwesomeP avatar Sep 02 '22 13:09 DaAwesomeP