Re: [csswg-drafts] [css-values] Proposal for a 'progress' function to calculate progress between two <length> values (#7268)

> While I like `progress()` as a name, with the proposed naming they seem like entirely separate things. Perhaps `mix-reverse()` or `mix-inv()` or something?

I agree that the name should reflect that this function is the inverse of `mix()`, like `asin()` is the inverse of `sin()`. 
`mix-inv()` or `inverse-mix()`or something similar would be great 👍 


> (tempted to suggest `xim()` and duck 🤣)

🤣 

> But what if we exposed the _actual_ range mapping operation? We could have a `map()` function that takes two _ranges_ and a value and maps the value from one range to the other. This would basically give us the result above in one fell swoop, without the intermediate percentage:
> 
> ...
> 
> ```css
> font-size: map(100vw in [375px, 1920px] to [24px, 32px]);
> ```

A range mapping function would be great! 

At the moment `mix()` does linear interpolation, and `map()` would do linear range mapping. 
But; there's an open issue on adding easing functions to calc (https://github.com/w3c/csswg-drafts/issues/6697). 

Easing could let us do something like 
```css
--progress: inverse-mix(100vw, 375px, 1920px);
font-size: mix(var(--progress) ease-in-out, 1rem, 1.25rem)
```

It would be great to be able to use easing functions in map as well, so the syntax should have room for extending in the future:
```css
map(100vw in [375px, 1920px] to [24px, 32px] ease-in-out)
```

Also, while a `map()` function would be great, separate `mix()` and `inverse-mix()` functions would be composable with other functions. 




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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 14 July 2022 14:42:17 UTC