W3C home > Mailing lists > Public > www-style@w3.org > August 2009

Re: Gradient syntax proposal

From: Brad Kemper <brad.kemper@gmail.com>
Date: Wed, 19 Aug 2009 07:49:13 -0700
To: James Elmore <James.Elmore@cox.net>
Message-Id: <67FE478D-8EBE-407A-942E-7EB48726BCD4@gmail.com>
Cc: CSS <www-style@w3.org>

On Aug 19, 2009, at 7:19 AM, James Elmore wrote:

>> I'm just thinking there would be times when you wanted a gradient a  
>> fixed distance from the end, not just the beginning, not  
>> necessarily a mirror of the beginning measurement, so it would be  
>> nice to have a way to specify that without a lot of calc(), which  
>> is even harder to read. A second slash version doesn't seem so bad  
>> for that. Basically just a slash instead of a comma there.
>>
>
> I was thinking last night (away from my beloved computer so I could  
> not send immediately ;) and thought about the possibility of using  
> negative numbers for both percentages and lengths. Positive values  
> are distances / percentages of the length FROM THE START of the  
> gradient line; negatives are FROM THE END of the line. This makes  
> the gradient syntax simpler -- no extra slash.

That was actually my first idea, before I came up with the second  
slash idea. But it means changing what the tokens mean for unit  
measurements, which can complicate the implementation, I think. But  
more importantly (to me), I might actually want negative percentages  
and lengths to represent color stops that are outside the box. I find  
that it is not uncommon when working in PhotoShop on gradients, to  
start dragging the gradient tool from outside one edge, and let it up  
outside of the opposite edge.

In other words, I can use the distance of the first and last color  
stops control how pure the first and last colors you actually see are.  
For example:

linear-gradient(top / white -20%, yellow 50% / black -30%)

The above would have yellow in the middle, a whitish yellow at the  
top, and a blackish yellow at the bottom. And if I wanted it to start  
a little whiter and/or end a little blacker, then I could just move  
those end points inward with smaller percentages (instead of having to  
pick new RGB colors or figure out new hex colors for those stops).

> The developers will need to handle more 'overlap' possible problems  
> -- especially with mixing lengths and percentages from both start  
> and end, this could be harder. What do the rest of you think of this?
>
> It might be worthwhile to limit the negatives to the end of the list  
> of color stops. E.g., after the first negative, all the rest MUST BE  
> negatives or it is an error. This limits mixing negatives and  
> positives and simplifies, somewhat, the problems.
>
> Personally, I prefer to allow any value, anywhere in the list of  
> color stops, but could live with the above limitation. A scenario  
> where developer(s) wanted to intermix positives and negatives would  
> not be too hard to create, but at least allowing negatives  
> (distances from the end of the gradient line) would reduce much of  
> the need for calc's.

The slash idea works well with the previous ideas of listing the  
gradients in order, in order to be able to easily interpolate  
placement of the stops when a percentage or length is omitted for that  
stop.
Received on Wednesday, 19 August 2009 14:49:56 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:20 GMT