GSDP:GAM100/CProcessing/randomSeed()
From Inside
< GSDP:GAM100 | CProcessing
randomSeed()
Description
Lets you set a specific seed for random to produce the same pseudo-random number each time the program is run. By default, the program will produce different results every time it is run.
Parameters
randomSeed(int seed)
- seed - (int) The value you want to use to seed the random number generator.
Example
void init()
{
// Seed with a specific value
randomSeed(5);
rectMode(CENTER);
// Create a random color
// This color will be the same every time the program is run since we set a specific seed
int val1 = randomRangeInt(0, 255);
int val2 = randomRangeInt(0, 255);
int val3 = randomRangeInt(0, 255);
fill(color(val1, val2, val3, 255));
// Draw a square in the center of the screen
rect((float)canvasWidth/2, (float)canvasHeight/2, 50.0f, 50.0f);
}