W3C home > Mailing lists > Public > www-style@w3.org > May 2013

Re: [css-color] Have you considered standardizing a rgba(#RRGGBB, <alpha-value>) notation?

From: Simon Sapin <simon.sapin@exyr.org>
Date: Thu, 09 May 2013 15:06:08 +0200
Message-ID: <518B9F40.5030602@exyr.org>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: Sebastian Zartner <sebastianzartner@gmail.com>, Jake Archibald <jaffathecake@gmail.com>, Lea Verou <lea@w3.org>, Šime Vidas <sime.vidas@gmail.com>, www-style list <www-style@w3.org>
Le 08/05/2013 17:17, Tab Atkins Jr. a écrit :
> On Wed, May 8, 2013 at 3:52 AM, Sebastian Zartner
> <sebastianzartner@gmail.com> wrote:
>> Since different kinds of color values are involved in these examples, using
>> rgba() doesn't make sense here. alpha() seems more logical to me.
>
> Agreed.  I'm thinking maybe a pair of functions for each component,
> set-*() and adjust-*(), for either overriding the given channel or
> adjusting it up or down.  Hmm, though, there's argument for both
> adjusting by a set amount, and by a percentage amount, at least for
> some channels.  I'll look into what the preprocessors do, precisely.

I don’t have much practice using such functions, but setting/adjusting 
individual color channels seems more useful in HSL space than RGB.

As to alpha, I think that multiplying is the obvious thing to do. For 
example, the used alpha here would be 0.3:

.foo {
   var-bar: rgba(255, 0, 128, 0.6);
   background: alpha(var(bar), 0.5);
}

This simplifies to "set" if the first argument’s alpha channel is 1. I’m 
not sure if the second argument or the result should be clamped to 0..1.

Cheers,
-- 
Simon Sapin
Received on Thursday, 9 May 2013 13:06:31 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 9 May 2013 13:06:32 UTC