Fix luminance calculation.

Use relative luminance (as described in [1]) and not the L component of
the HSL color model, as that better fits our purpose of adjusting the
foreground color to the brightness of the background.

[1] http://en.wikipedia.org/wiki/Relative_luminance