Re: [css4-color] 4 Parameters in RGB() and HSL()

2012/1/25 Christoph Päper <christoph.paeper@crissov.de>:
> Several pseudo functions accept different numbers of parameters, the rightmost parameters are then optional, original ones don’t change their meaning. In CSS3: Color rgba() and hsla() have been added without taking advantage of this polymorphous capability. They also have been criticized for always denoting the alpha value as a number in the range 0.0–1.0, not as a percentage.
>
> Could we therefore make
>
>  rgb(100%, 80%, 60%, 40%)
>  hsl(300deg, 60%, 40%, 20%)
>  rgb(255, 0, 64, 127)
>
> valid in Level 4?

I agree that rgba/hsla were mistakes and should have been done as you
suggest, but I'm not sure it's worthwhile changing rgb/hsl at this
point (or making rgba/hsla's fourth argument optional).  I plan to
work on Colors 4 later this year, though, so I'll keep it in mind.

I'm definitely in favor of making the alpha value take a percentage as
well as a number.  It's in my list of things to change when I start
editing the spec.  (Along with allowing the first argument of hsl to
be an <angle>.)

Your third example - rgb(255, 0, 64, 127) - will always be invalid,
though - CSS can't distinguish between <integer> and <number> in
general, so the fact that alpha already takes a number in [0,1] means
we can't also have it take an integer in [0,255], because a value of 1
would be ambiguous and have *substantially* different effects based on
interpretation.

~TJ

Received on Wednesday, 25 January 2012 19:12:56 UTC