Open pnorman opened 6 years ago
Have you tried just using a global JavaScript function to do your color conversions? Instead of hard-coding a color in you styles, you would call this function with the parameters in whatever color space you are using.
It's normally easier to write colours in a perceptual colourspace than sRGB. This allows you do actions like specify two colours of the same brightness by keeping one number constant, instead of having to do complex sRGB calculations.
Right now what I am doing is
color: '#e4efd1' #lch(93,15,120)
which allows me to see the colour in a human-readable form and hex, but this requires specifying it in two places.Lab and Lch colour support would be good. The former is not the most natural to think in sometimes, but is an intermediate step to Lch.
My understanding of colour theory is that the conversion should be done with a D50 illuminant. The python library colormath, while not usable in a JS lib, is useful for checking that the results are right.
HSV is not a perceptual colour space and would not solve this problem. HSV was designed for real-time calculations on 1970s and 1980s hardware, having to calculate hundreds or thousands of times a second. Tangram only needs to do the colour space conversion once on load, and runs on modern hardware.