random_color icon indicating copy to clipboard operation
random_color copied to clipboard

Reusing a pre-seeded instance should return new colors

Open RReverser opened this issue 2 years ago • 0 comments

I'm creating an instance with a .seed(0) because I want to get random colors, but I want the sequence to be consistent between reruns. This is what seed is usually leveraged for in regular PRNGs.

However, in random_color instance it seems it creates a new random number generator on every call, which means that it will always return the same color on subsequent invocations.

Example:

let mut random_color = RandomColor::new();
random_color.seed(0);

let color1 = random_color.to_rgb_array();
let color2 = random_color.to_rgb_array(); // returns same as color1
let color3 = random_color.to_rgb_array(); // same again
...

RReverser avatar Jan 28 '24 01:01 RReverser