Re: in-between values

On Feb 1, 2011, at 3:25 AM, timeless wrote:

> On Fri, Jan 21, 2011 at 7:54 PM, Brad Kemper <brad.kemper@gmail.com> wrote:
>> I had an idea for a special value that could be used with a variety of properties,
>> for transitioning, animating, or just picking single values that are in between two
>> values that don't normally have any mid-points. So for instance:
> 
>> background-clip: mid(border-box, padding-box, 0.24) /* would clip 1/4 of the way from border-box to padding-box */
>> background-clip: mid(padding-box, border-box, 0.24) /* would clip 1/4 of the way from padding-box to border-box */
> 
> Isn't 1/4 usually 0.25? Why did you write 0.24, is there some magic going on?

Sorry. That must be a typo. It should have said 0.25.

'background-clip: mid(border-box, padding-box, 0)' would be the same as 'background-clip: border-box'. 'background-clip: mid(border-box, padding-box, 1)' would be the same as 'background-clip: padding-box'. 


>> color: mid(transparent, blue, 0.7) /* equivalent to color:blue; opacity:0.7 */
>> color: mid(blue, transparent, 0.7) /* equivalent to color:blue; opacity:0.3 */
> 
> It took me a couple of readings to understand this. You aren't using
> mid to mean 'midpoint'...

A midpoint yes, but not necessarily a halfway point. The number between 0 and 1 would indicate the position of the midpoint, with smaller numbers (0 – 0.5) being closer to the first value, and larger numbers (0.5 – 1) being closer to the second value.


> A graphic here would have helped.

I didn't think it was that complicated. But perhaps for certain properties a graphic would help to visualize the result, sure.

> T123456789B
> -------x    color: mid(transparent, blue, 0.7) /* equivalent to
> color:blue; opacity:0.7 */
>    x------- color: mid(blue, transparent, 0.7) /* equivalent to
> color:blue; opacity:0.3 */
> 
> fwiw, the other mid that comes to mind is:
> MID$(stringexpression$, start, length)
> 
> Which obviously doesn't behave the way you're using it here. I've had
> a hard enough time trying to describe this to myself that i expect
> people will mess this up while trying to use it. -- I really don't
> like the name.

I wasn't basing it on other computer languages. I was going for something short, for interpolating certain values that don't normally have other ways to specify in-between values (or at least not easily).

> We already will have calc() and eventually css variables, do we need
> another thing here? if we gave calc() the ability to operate on colors
> (and other things), would that work?

I don't see how that would work. How would you use it to, say, get a 'background-clip' value that was 1/4 of the way between 'border-box' and 'padding-box'?

>> border-style: mid(dashed,solid,0.5) /* spaces between dashes are half their normal length */
> 
> What would be the result for border-style: mid(double, dashed, 0.6)

At this point it is just spitballing, and a proper spec would have to list what properties and values could be interpolated and what the effects would be. 

But I'd say that you should first imagine something between double and solid (for numbers near zero, you would have near normal-thickness lengthwise gap between the double lines, and that gap gets thinner and thinner as you approach 0, until it disappears into a solid line). Then you can combine that with the extrapolation between solid and dashed. So for your example, the dividing white line between the double lines would be 40% of the normal thickness for 'double' (that is, 60% of "not double", more towards solid in that sense), and the spaces between the dashes would be 60% of their normal 'dashed' length.

> could i do border-style: mid(groove, mid(double, dashed, 0.4), 0.7) ?

Interesting. I would say theoretically yes, possibly, as long as we can define what the mid-way points are between 'groove' and 'double' and between 'groove' and 'dashed'. But this may be something we want to limit to not allow 'mid()' as an argument for 'mid()'. I'm not sure what the pros and cons of doing that are.

Received on Tuesday, 1 February 2011 16:36:55 UTC