mapnik/mapnik — pull request #2308 by mojodna (2014-07-22 01:37:32+00:00)
Title: Work in HSL so luma can be preserved

Let's try this again...

[`hsl-color`](https://github.com/mapnik/mapnik/blob/bfc6c61d62be5b4aa69a09e98a38a2466ebcae30/deps/agg/src/agg_pixfmt_rgba.cpp#L74-L105) doesn't appear to use the luma from the bottom layer.

"hsl-color" is [defined by Wikipedia as](http://en.wikipedia.org/wiki/Blend_modes#Hue.2C_saturation_and_luminosity):

> The Color blend mode preserves the luma of the bottom layer, while adopting the hue and chroma of the top layer."

Cairo defines it as:

> Blend mode function:
>
> f(cA,cB) = set_lum(cA, lum(cB))
>
> Creates a color with the hue and saturation of the source and the luminosity of the destination. This preserves the gray levels of the destination and is useful for coloring monochrome images or tinting color images."

This is what I'd expect (generated using Cairo via `node-canvas`):

![mapstack](https://cloud.githubusercontent.com/assets/45/3652132/a7451cd0-1134-11e4-93e5-f36c04c6162b.png)

However, this is what Mapnik creates:

![blend](https://cloud.githubusercontent.com/assets/45/3652135/addcd722-1134-11e4-9a0b-153fe6938317.png)