/*
Hundred shapes are actually much less than thye would seem to be. This software
attempts to constantly display 100 shapes on screen. A colder patterns of snow
flakes or naked tree branches are used as an inspiration.
*/
float lwidth = 30;
int[] wlines = new int[11];
int[] blines = new int[11];
void setup() {
size(400,400);
background(0);
strokeWeight(2.5);
noFill();
frameRate(12);
smooth();
for(int i=0; i<wlines.length; i++) {
wlines[i] = i*40-20;
blines[i] = i*40-20;
}
}
void draw() {
lwidth = 20 + mouseY*0.4;
float bgalpha = 50 - (mouseX*0.1);
fill(0,bgalpha);
rect(0,0,400,400);
noFill();
for(int j=20;j<400;j+=80) {
stroke(45);
for (int i=0; i<wlines.length; i++) {
drawLine(i,j);
if(wlines[i] > 420) {
wlines[i] = -10;
}
else {
wlines[i] += 1;
}
}
stroke(125);
for (int i=0; i<blines.length; i++) {
drawBLine(i,j+40);
if(blines[i] < -20) {
blines[i] = 420;
}
else {
blines[i] -= 1;
}
}
}
}
void drawLine(int i, int j) {
pushMatrix();
translate(wlines[i],j);
float angle = 0.0 + wlines[i]*0.007;
rotate(angle);
line(-lwidth/2,0,lwidth/2,0);
popMatrix();
}
void drawBLine(int i, int j) {
pushMatrix();
translate(blines[i],j);
float angle = 0.0 + blines[i]*0.014;
rotate(angle);
line(-lwidth/2,0,lwidth/2,0);
popMatrix();
}
Exercise 12: Use arrays and for structures to control the motion of one hundred shapes.