W3C home > Mailing lists > Public > public-css-archive@w3.org > October 2020

Re: [csswg-drafts] [css-values-4] How to interpolate <ratio>? (#4953)

From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
Date: Tue, 20 Oct 2020 13:37:44 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-712856076-1603201062-sysbot+gh@w3.org>
So, the proposal is that the interpolation between two ratios `r1` and `r2` at distance `p` should be

```
exp((1 - p) * log(r1) + p * log(r2))
````
? Or equivalently,

```
(r1 ** (1 - p)) * (r2 ** p)
````
Note that `0 / 1` has a -infinity logarithm, so interpolating between `0 / 1` and `1 / 1` won't be fluid. But that was already the case for `1 / 0` and `1 / 1`.

Also note that doing it linearly has the advantage that you can fix `height: h` and interpolate `aspect-ratio`from `r1` to `r2`, then `width` changes linearly from `h * r1` to `h * r2`. If ratios are interpolated logarithmically, we lose this property, but we didn't have it either when fixing `width: w` instead.

Example table:

| Fixed style | Interpolation | `p = 0` | `p = .5` | `p = 1` |
| --- | --- | --- | --- | --- |
| `height: 5px` | `2/1` -> `18/1`<br>linearly | `aspect-ratio: 2/1`<br>`width: 10px` | `aspect-ratio: 10/1`<br>`width: 50px` | `aspect-ratio: 18/1`<br>`width: 90px` |
| `width: 180px` | `2/1` -> `18/1`<br>linearly | `aspect-ratio: 2/1`<br>`height: 90px` | `aspect-ratio: 10/1`<br>`height: 18px` | `aspect-ratio: 18/1`<br>`height: 10px` |
| `height: 5px` | `2/1` -> `18/1`<br>logarithmically | `aspect-ratio: 2/1`<br>`width: 10px` | `aspect-ratio: 6/1`<br>`width: 30px` | `aspect-ratio: 18/1`<br>`width: 90px` |
| `width: 180px` | `2/1` -> `18/1`<br>logarithmically | `aspect-ratio: 2/1`<br>`height: 90px` | `aspect-ratio: 6/1`<br>`height: 30px` | `aspect-ratio: 18/1`<br>`height: 10px` |

So this would make it symmetric, seems good to me.

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4953#issuecomment-712856076 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 20 October 2020 13:37:45 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:20 UTC