W3C home > Mailing lists > Public > www-style@w3.org > September 2008

Re: Color Lightening and Darkening

From: Mikko Rantalainen <mikko.rantalainen@peda.net>
Date: Mon, 01 Sep 2008 14:10:05 +0300
Message-ID: <48BBCD8D.6070404@peda.net>
To: CSS <www-style@w3.org>
James Elmore wrote:
> On Aug 28, 2008, at 10:05 AM, Daniel Glazman wrote:
>> Dave Artz wrote:
>>> Can we get a second opinion 6 years later?  If a script kid can 
>>> do it in PHP...
>> I am no color expert and I am ready to read pros and cons here.
> I am no expert, either, but I can see a few problems. First, and 
> hardest, is that color is not a simple linear progression.


> Should lighter be linear or geometric, or should it be something 
> else, which more closely matches the human perception; and what about
> filters and gamma corrections on output: will those be taken into 
> account as well? And, what about the different colors (RGB)? If all 
> three colors are the same intensity (#888888, for example) then it is
> fairly simple to lighten or darken the colors by changing them all 
> the same amount. But what if they are different (e.g., #4488CC)? 
> should all be adjusted the same amount? (To #2266AA? Or #3377BB? 
> Probably not.) Or should they be adjusted some proportional way (e.g.
> 25%, giving #336699)?

CSS already defines an alpha channel which has *exactly* the same
problems. If the target audience of CSS is happy with the CSS alpha
channel, then a similar "darker" feature would be enough.

How about we just define "darker" to mean "inherited used value" with
color rgba(0,0,0,0.1) on top. CSS already defines (to some detail) how
that is rendered. Then the "lighter" could be defined to mean "inherited
used value" combined with rgba(255,255,255,0.1).

> And, if we agree on how to lighten a color, what do we say to the
> next person, who asks CSS to lighten JUST THE RED? (or Green? or
> Blue?)

Can be done once rgba() and hsla() are first expanded to accept 3
separate alpha values (one for each channel). Then lighter-red could be
a combination with rgba3(0,0,0,0.1,0,0) or something along those lines.

As I wrote in another message, just make sure that there's some feature
to always get acceptable contrast between background and foreground colors.


Received on Monday, 1 September 2008 11:10:53 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:39 UTC