This sketch is created with an older version of Processing,
and doesn't work on browsers anymore.
xxxxxxxxxx
float[]xpoints = new float[4];
float[]ypoints = new float[4];
float[]xtarget = new float[4];
float[]ytarget = new float[4];
void setup(){
size(800,800);
background(255);
fill(255,255,255,0);
stroke(0,0,0,15);
//initialize points and target
for(int i=0; i<4; i++){
xpoints[i] = random(width);
ypoints[i] = random(height);
xtarget[i] = random(width);
ytarget[i] = random(height);
}
}
void draw(){
quadDrawer();
quadCompare();
}
void quadDrawer(){
quad(xpoints[0],ypoints[0],xpoints[1],ypoints[1],xpoints[2],ypoints[2],
xpoints[3],ypoints[3]);
}
void quadCompare(){
for(int i=0; i<4; i++){
if(int(xpoints[i])<int(xtarget[i])){
xpoints[i]+=1;
}
if(int(xpoints[i])>int(xtarget[i])){
xpoints[i]-=1;
}
if(int(xpoints[i])==int(xtarget[i])){
xtarget[i] = random(width);
}
if(int(ypoints[i])<int(ytarget[i])){
ypoints[i]+=1;
}
if(int(ypoints[i])>int(ytarget[i])){
ypoints[i]-=1;
}
if(int(ypoints[i])==int(ytarget[i])){
ytarget[i] = random(height);
}
}
}