We are about to switch to a new forum software. Until then we have removed the registration on this forum.
what i want to do is each time loop of draw comes a new "action" is randomly chosen. I know i would do if random a number then the action. but I'm not sure how to write it out. also how to i write out for draw to pick a new number randomly each time. (also i marked each action with dotted lines)
//PImage bg;
float x;
float r = 0.0;
void setup (){
size(800,800);
smooth();
//bg = loadImage("a.jpg");
}
void draw () {
//background(bg);
background(0);
{for (float x=1; x < 2; x=x+.05) { //------------------------------------------------
shape();
}
}
{for (float x=1; x < 20; x=x+.5) { //----------------------------------------------------
shape();
}
}
{for (float x=1; x < 200; x=x+.5) { //---------------------------------------------------
shape();
}
}
{for (float x=1; x < 2000; x=x+.5) { //----------------------------------------------------
shape();
}
}
{for (float x=1; x < 1000; x=x+.05) { //------------------------------------------------------
shape();
}
}
}
void shape (){
translate(390,393);
scale(r);
for(int i = 0; i < 5; i++){
int c = color(random(0,255), random(0,255), random(0,255));
stroke(c);
noFill();
rectMode(CENTER);
rect(0,0,10,10);
r += 0.5;
if (r > 55) {
r = 0;
}
}
}
``
Answers
Here is some example code that draws one of three different shapes at random every frame.