- From: Romain Menke via GitHub <sysbot+gh@w3.org>
- Date: Fri, 02 May 2025 09:41:55 +0000
- To: public-css-archive@w3.org
In `php` I have code like this: ```php function pseudo_shuffled_set() { // A set of options $options = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', ); // use the request url as the random seed $request_seed = wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ); /* phpcs:ignore */ srand( crc32( $request_seed ) ); // shuffle the array $copy = array( ...$options ); $copy_length = count( $copy ) > 0; $shuffled = array(); while ( $copy_length > 0 ) { // `rand` is seeded and will yield deterministic results $i = rand( 0, count( $copy ) - 1 ); $shuffled[] = array_splice( $copy, $i, 1 )[0]; $copy_length = count( $copy ) > 0; } return $shuffled; } ``` Then when rendering a templates page I can create a shuffled set that is specific to that page and use it to add some visual variation to elements. Each page will be different from every other page (to some degree), but rendering the same page twice will yield the same result. The current `random()` function is too random as each page refresh would yield a different result. > Or are you hoping for a mix of numeric-counter() (which I'd be very much a fan of seeing) plus something like GLSL's [`noise(seed)`](https://docs.gl/sl4/noise)? I not familiar with GLSL, but this does sound correct :) -- GitHub Notification of comment by romainmenke Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12072#issuecomment-2846807826 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 2 May 2025 09:41:56 UTC