[css-color] Extended Named Colors (was: Last call comments on CSS3 module: color)

Alex Sexton <alexsexton@gmail.com>:

> Sorry for the short delay in responding to this,

Is this really a reply to a thread from May 2002?
<http://lists.w3.org/Archives/Public/www-style/2002May/0131.html>

> # R3
> 
> Lots of colors that never made it into the CSS version of the colors were
> added on October 27, 1988 in X11R3. Namely, 101 versions of gray.
> 
> gray0 0,0,0
> gray1 3,3,3
> gray2 5,5,5
> ....
> gray99 252,252,252
> gray100 255,255,255
> 
> (increments at a 3, 2 interval all the way to 255)
> 
> Naturally these were all duplicated as 'grey'. At this point in time they
> had to change 'white' from 252,252,252 to 255,255,255 because
> 'gray100' was "more white" than 'white'. Now gray100 and white were the
> same.

This reminded me of an idea I had a while ago: turn color names into pseudo functions, e.g. ‘gray’:

  ‘gray0’   = gray(0%)   /* = ‘black’ */
   …
  ‘gray50’  = gray(50%)
   …
  ‘gray’    = gray()     /* = ‘gray(50%)’ in CSS, but ‘gray75’ in X11 */
   …
  ‘gray75’  = gray(75%)  /* = ‘silver’ = ‘silver()’ */
   …
  ‘gray100’ = gray(100%) /* = ‘white’ */

I think this notation has been suggested before as a shortcut for repeated triplets in RGB functions or as an alias to also proposed single-value RGB function or as the lightness in otherwise zeroed HSL (and HSV) values. 

    ‘gray(<percent>)’ 
  = ‘rgb(<percent>, <percent>, <percent>)’ 
  = ‘rgb(<percent>)’ 
  = ‘hsl(0, 0%, <percent>)’

I would generalize the latter for all absolute color names of CSS2 (either level 2.0 or 2.1):

  <color-name-extended> := <level2-color-name> [ ‘(’ [<lightness>]? ‘)’ ]?
  ^= hsl( hue(<level2-color-name>), saturation(<level2-color-name>), <lightness> )

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> ‘)’ ]?

  <hue> := <level2-color-name> [‘-’ <level2-color-name>]?

  <lightness>        := [<absolute>]? <lightness-value> 
                      | <lightness-value> <relative>
                      | <percentage> | ‘medium’
  <saturation>       := [<absolute>]? <saturation-value> 
                      | <saturation-value> <relative>
                      | <percentage> | ‘medium’

  <lightness-value>  := ‘dark’ | ‘light’
  <saturation-value> := ‘dull’ | ‘bright’

  <absolute>         := [ ‘extra’ | ‘semi’ | ‘ultra’ | ‘very’ | ‘hardly’ ] ‘-’
  <relative>         := [ ‘er’ | ‘est’ | ‘ish’ ]

Received on Friday, 14 March 2014 10:29:50 UTC