Re: [csswg-drafts] [css-values-5] Maybe min, max and step should not be part of the random-caching-key (#11742)

> I want this box to have a random size, but always a 2/1 aspect ratio. With the current spec, width and height get their own random values.

I think the more obvious way to do this would be to use the same `random()` function in both, like this: `width: calc(random(per-element, 50px, 100px)*2)`.

> Another example might be that you have two elements that want a width based on a single random value, but they quantize that value in different ways.

You can do the same thing for this: pull out the `random()` function and pipe it into a `round()` function.

I think these use cases are relatively rare, and it's more obvious what you're doing if you synchronize the `random()` functions.

<hr>

I think what's more likely, actually, is that you want two `random()` functions with identical arguments to return different values. For example, maybe you want a bunch of randomly sized boxes on your page with their widths and heights between 10px and 100px:

```
width: random(10px, 100px);
height: random(10px, 100px);
```

But this will generate squares right now, right? It seems to me that requiring a shared name to tie them together makes more sense than requiring different names to differentiate. As you say, if you accidentally end up with two `random()` functions with shared used values right now, they'll get accidentally tied together.

The important thing is to make sure that `random()`'s internal randomness value is part of its computed value so that it inherits correctly; but having each unnamed instance be unique actually makes more sense to me than making identical arguments return identical values... unless they're explicit about wanting to repeat a value, people usually want more randomness out of their `random()`s, not less, right? :)

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


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

Received on Wednesday, 19 February 2025 02:11:03 UTC