Categories

2 Train | code

int num = 50;
float[] x1 = new float[num];
float[] y1 = new float[num];
float[] x2= new float[num];
float[] y2 = new float[num];
float[] x3 = new float[num];
float[] y3 = new float[num];

void setup(){
size(640,320);
noStroke();
}

void draw(){
background(0);

fill(255);

for (int i = 0; i < num-3; i++){
x1[i] = x1[i+3];
y1[i] = y1[i+3];
x2[1] = x2[i+3]+5;
y2[1] = y2[i+3]+5;
x3[1] = x3[i+3]+20;
y3[1] = y3[i+3]+20;
}
x1[num-1] = mouseX + random(-10,10);
y1[num-1] = mouseY + random(-10,10);
x2[num-1] = mouseX + random(-10,10);
y2[num-1] = mouseY + random(-10,10);
x3[num-1] = mouseX + random(-10,10);
y3[num-1] = mouseY + random(-10,10);

for(int k = 0; k < num; k++){
fill(random(255),random(255),random(255));
triangle(x1[k],y1[k],x2[k],y2[k],x3[k],y3[k]);
}
}

No Comments

Leave a Comment: