-
Notifications
You must be signed in to change notification settings - Fork 130
Implement color luma change function #492
Comments
Before talking about the actual function I'm trying to understand why you need it in the first place. You are unsatisfied with the non-uniformity of the lightness of HSL, is that correct? Do you know that carto supports HSLuv (http://www.hsluv.org/) which tries to modify CIELUV to allow the same colour definitions as in HSL. Internally carto uses either HSL or HSLuv, see https://cartocss.readthedocs.io/en/latest/language_elements.html#color. Cf also #354, #453. Some argue that HSLuv is not really a perceptual colour space, but it solves the problem of HSL without the possibility of yielding non-representable colours like in CIELUV. Would using HSLuv solve your problem without needing this function? This would avoid the problem of conversions as internally colours are represented as HSL/HSLuv, so you would have to convert to RGB first, then change the luma value, convert back to HSL. Needless to say that there would be a lot of rounding errors. |
Say that I'm making a cartographic choice to 1. desaturate all colors 2. darken lightest colors.
I didn't tried HSLuv (I will give it a try) but I don't think it will fit my need in this particular choice.
Yves
|
I played a little bit with HSLuv: HSLuv solves the issue of the lightness uniformity when you choose your colors. I also figured out that my lightening function is more a whitening function:
Given a non-chosen set of colors, these two color functions allows to:
I just fiddled with these color change and in the end they give a valid result to my eye, so I would certainly have a hard time to defend the theory behind them :-) |
I think data driven colours would be a Mapnik issue, not a Carto one, and suggest closing this issue as out of scope. I would also not recommend Luma. Convert to a standard perceptual colour space, set the colour properties you want, project to the gamut, and use that colour. |
Hmm, in any case, this works as expected for data driven colors: But this doesn't: And this neither: So it seems there is something else to improve before discussing this anyway. |
This translates to Mapnik XML that roughly
The other things you want are Mapnik issues. |
When dealing with data-driven colors, one often faces plain colors like yellow (255,255,0), red (255,0,0) etc. Cartographically speaking, these color are too saturated and far less than ideal.
My use case is the coloring of crosscountry skiing route relations for OSM, but I guess it’s the same for any route with a color tag.
One could desaturate() and lighten() or darken() the color, however, for some color it’s not satisfactory. For instance, the yellow visibility over a light background is not sufficient. At Opensnowmap, I implemented a while ago a pre-processing that alter the colors luma (see https://en.wikipedia.org/wiki/HSL_and_HSV).
Luma is the Y’ in Y’UV color space, and is defined by Y′601 ≈ 0.30R + 0.59G + 0.11B.
See an example below of the color change made in the Opensowmap pre-processing generating the ski routes style :
My question is, is this worth it to try to submit a PR implementing a deluma() function in function.js to decrease the luma of a color, or this is out of scope here? What would be a good name for the inverse function to increase luma ?
Below is my actual implementation in python :
The text was updated successfully, but these errors were encountered: