Re: [css4-color] Grayscale shorthand (with alpha)

Le 17/04/2012 11:01, Rudolph Gottesheim a écrit :
> I find myself writing things like rgba(0, 0, 0, .5) or rgba(192, 192,
> 192, .8) dozens of times a day, mostly for shadows. It's always some
> shade of gray with some alpha value.
>
> Do you think there's room for a grayscale color shorthand?
>
> Maybe something like *gray(255, .5)* == rgba(255, 255, 255, .5) or
> *la(50%, .9)* == hsla(0, 0%, 50%, .9)
>
> It probably seems like the few saved characters aren't worth a new
> function or syntax, but it just seems so redundant every time I type
> this stuff out. rgba(255, 255, 255, .2) ... ugh.
>
> What do you think?


I like the idea.

If my math is correct, hsla(X, 0%, Y%, Z) is always the same as rgba(Y%, 
Y%, Y%, Z). gray(Y%, Z) could be a shorthand for these, and gray(Y%) a 
shorthand for gray(Y%, 1)

Also, accept an integer in 0-255 as well as a percentage.

(Let the bike-sheding begin for the function name.)

-- 
Simon Sapin

Received on Tuesday, 17 April 2012 10:46:53 UTC