- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Thu, 06 Mar 2025 16:53:59 +0000
- To: public-css-archive@w3.org
Hm, just spitballing if we could handle this via `calc-range()` or whatever (the "interpolation" variety).
It would need the `by C` ability added to the between-stops interpolation qualities. But that's also a little strange - A+n\*C doesn't necessarily hit B; the current `random()` spec handles this by just suggesting you write your B to slightly overshoot, and lets the actual end of the range be exactly an A+n\*C value. We'd need to be able to round the endpoint down a little...
```css
@function --step-range-limit(--a, --b, --c) {
--dist: calc(var(--b) - var(--a));
--step: calc(var(--dist) / var(--c));
--rounded-dist: round(down, var(--dist), var(--step));
result: calc(var(--a) + var(--rounded-dist));
}
@function --step-count(--a, --b, --c) {
--dist: calc(var(--b) - var(--a));
--step: calc(var(--dist) / var(--c));
result: calc(1 + round(down, var(--dist) / var(--step), 1));
}
/* then `random(A, B, by C)` computes to... */
calc-range(R,
0: A,
by steps(--step-count(A, B, C), jump-none),
1: --step-range-limit(A, B, C)
)
```
Tho, no, sigh, that still doesn't get me some of the argument handling. I guess I will just need to make `random()` handle this.
--
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11742#issuecomment-2704405578 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 6 March 2025 16:54:00 UTC