I am drawing a colored object with random RGB color values via the background()
function in Processing, waiting half a second, and then changing the position of the RGB values (e.g. swapping R with B, etc):
void draw() {
z = float(random(255));
x = float(random(255));
c = float(random(255));
background(z, x, c);
delay(500);
background(c, x, z);
}
However, the way I am declaring the color values randomly doesn't seem to be constant within the function, despite storing the values as variables; rather, the second background
call is generating entirely new values for the RGB variables.
I want the z
, x
, and c
variables to not change upon being called into the 2nd background()
command, but can't quite figure it out.
I tried making other variables, using frameRate(1)
, and moving the delay(500)
command past the 2nd background()
, but unfortunately the variables change upon being called the 2nd time, and I want them to keep their value until the next void draw()
loop.