Wow! nice dynamic rectangles!
Updated code, look for @@@ where I made changes,
Pressing the mouse saves a file named pic_L_0012_080309043652.png
meaning it's file #12 saved on 2008-mar-09 at 4:36:52, by pressing Left mouse button.
Of course you don't need all this in the file name, but it shows what's possible.
Code:float a =0.0;
float b =0.0;
float c =50.0;
float d =50.0;
float e =1000;
float f =0;
float g = -50;
float h = 50;
float i =1000;
float j =1000;
float k =-50;
float l= -50;
float m= 0;
float n= 1000;
float o = 50;
float p = -50;
float s= 255;
float x=10;
float v=0;
float w=10;
float z=5;
float y=10;
float speed = 1;
float direction = 8;
float speed_s=1;
float direction_s=10;
float speed_v=1.0;
float direction_v=10;
float direction_w=20;
float direction_z=10;
//@@@
String save_name = "pic";
String save_time;
int save_count=0;
void setup(){
size (1000,1000);
background(0);
}
void draw(){
stroke (255);
strokeWeight(1) ;
fill(s);
rect (a,b+z,c,d+w);
rect (e,f+z,g,h+w);
rect (i,j-z,k,l-w);
rect (m,n-z,o,p-w);
rect (a+z,b,c+w,d);
rect (e+z,f,g+w,h);
rect (i-z,j,k-w,l);
rect (m-z,n,o-w,p);
rect (a,b,c,d+z);
rect (e,f,g,h+z);
rect (i,j,k,l-z);
rect (m,n,o,p-z);
//@@@
//uncomment these lines for some random changes
//if (random(1)<0.01) {print("S");s=255-s;}
//if (random(1)<0.005) {print("s");direction_s=-direction_s;}
//if (random(1)<0.005) {print("v");direction_v=-direction_v;}
//if (random(1)<0.005) {print("w");direction_w=-direction_w;}
//if (random(1)<0.005) {print("z");direction_z=-direction_z;}
a=a+(speed*direction);
b=b+(speed*direction);
e=e-(speed*direction);
f=f+(speed*direction);
i=i-(speed*direction);
j=j-(speed*direction);
m=m+(speed*direction);
n=n-(speed*direction);
s=s-(speed_s*direction_s);
v=v+(speed_v*direction_v);
w=w+(speed*1*direction_w);
z=z+(speed*3*direction_z);
if (w<-0||w>1000){
direction_w=(direction_w*-1);
}
if (z<-0||z>500){
direction_z=(direction_z*-1);
}
if (v<0||v>250){
direction_v=(direction_v*-1);
}
if (s<0){
direction_s=-abs(direction_s);
}
else if (s>255){
direction_s=abs(direction_s);
}
if (a>500||a<0){
direction = (direction*-1);
c=c-x;
d=d-x;
g=g+x;
h=h-x;
k=k+x;
l=l+x;
o=o-x;
p=p+x;
}
if (c<0){
noLoop();
save("fileName .tga");
}
}//draw()
//@@@
void mousePressed() {
boolean mouseRight=(mouseButton==RIGHT);
save_time=nf(year()%1000,2)+nf(month(),2)+nf(day(),2)+nf(hour(),2)+nf(minute(),2)+nf(second(),2);
save_count++;
//save (save_name+"_"+save_time+".png");
if (mouseRight) {
save (save_name+"_R_"+nf(save_count,4)+"_"+save_time+".png");
}
else {
save (save_name+"_L_"+nf(save_count,4)+"_"+save_time+".png");
}
}//mousePressed()
Note: you have this line in your program:
if (c<0){ noLoop(); save("fileName .tga"); }
Remove it and the drawing can continue producing nice patterns.