randomFor method

double randomFor(
  1. int index,
  2. int salt
)

Derives an independent random in [0, 1) for particle index from its stored random01 and a salt, so different randomized properties (size, rotation, color) do not all share one stream and correlate.

Uses only double arithmetic so it is deterministic on every backend (including web). Good enough for visual randomness, not for cryptography.

Implementation

double randomFor(int index, int salt) {
  final x = math.sin(random01[index] * 127.1 + salt * 311.7) * 43758.5453;
  return x - x.floorToDouble();
}