Re: [css-color] Extended Named Colors

Simon Sapin <simon.sapin@exyr.org>:
> On 14/03/2014 10:29, Christoph Päper wrote:
>> 
>> Let’s not stop there. We could put basically anything inside those parentheses and it would work nicely even within shorthand properties. This includes CNS keywords!
>> 
>>   <color-name-extended> := <hue> [ ‘(’ <lightness> || <saturation> ‘)’ ]?

> Level 4 of the Color module has some proposals along these lines:

Oh, it has been updated since I last had a look at it. Basically, I was proposing

  [ <named-color> | <named-hue> ] ‘(’ <color-adjuster>* ‘)’

for which the draft has this instead:

  ‘color(’ [ <color> | <hue> ] <color-adjuster>* ‘)’

The adjusters are more powerful than what I had in mind, but the syntax is also more “coder style”.
They would – in my humble opinion – better be implemented by altering the existing color pseudo functions, e.g.:

  rgb := ‘rgb(’ <component> [‘,’ <component> ‘,’ <component>]? [‘,’ <alpha>]? ‘)’
  hsl := ‘hsl(’ <hue> [‘,’ <component> ‘,’ <component>]? [‘,’ <alpha>]? ‘)’

  <component> := [<color-ref>]? [‘+’ | ‘-’]? 
                 [ <number> | <percentage> | <color-ref> ]
               | <color-ref> [‘*’]? <percentage>
  <hue>       := [<color-ref> | <named-hue>]? [‘+’ | ‘-’]? 
                 [ <number> | <angle> | <named-hue> | <color-ref> ]
               | <color-ref> [‘*’]? <percentage>
  <color-ref> := ‘default’ | _‘inherit’_ | ‘current’ | <named-color> | <system-color>

Flexible number of parameters:
* rgb(<gray=red=green=blue>)
* rgb(<gray=red=green=blue>, <alpha>)
* rgb(<red>, <green>, <blue>)
* rgb(<red>, <green>, <blue>, <alpha>)
* hsl(<hue @100% @50%>)
* hsl(<hue @100% @50%>, <alpha>)
* hsl(<hue>, <saturation>, <lightness>)
* hsl(<hue>, <saturation>, <lightness>, <alpha>)

The <color-ref> keywords would automatically use the same component from the referenced color as the color calculation:

  rgb(red, green, blue) == rgb(100%,  50%, 100%)
  rgb(red, lime, blue)  == rgb(100%, 100%, 100%)
  rgb(blue, green, red) == rgb(  0%,  50%,   0%)

I’m not sure about ‘tint()’, ‘shade()’, ‘blend[a]()’ and ‘contrast()’, though.

Received on Friday, 14 March 2014 16:55:54 UTC