Re: [csswg-drafts] [css-values-5] seeded random values (#12072)

Thinking out loud: could it be something like an inherited property that sets the `fixed` value for all random functions on an element tree? And maybe even with an ability to set different values to different `<dashed-ident>`, like `random-base-value: 0.5, --foo 0.2, --bar 0.6` etc., so you could adjust it differently for various shared idents? (0.5 for all `random()` calls by default, `0.2` for any using `--foo` etc, regardless of the `element-shared` presence).

If I were to dream bigger, what if you could somehow pass an ident for a _custom function_ that would be used as a callback, replacing the base value for each random()?

```CSS
@function --my-random-seed(--type type(auto | <dashed-ident>): auto, --element-shared <boolean>) {
  result: if(…);
}
```

Basically, a callback that could be used to output a static base value conditionally based on the `random()`'s type and if it is element-shared. If you'd be able to use `sibling-index()` etc, in such a function, you could substitute the actual random with a “good enough” [pseudo-random value](https://kizu.dev/tree-counting-and-random/#basic-algorithm), etc.

But that might be overkill :) (but now that we're getting custom functions, I am starting to think if there are places in our CSS APIs that we could extend with them in some way).

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


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

Received on Tuesday, 26 August 2025 22:40:19 UTC