/*abstraction flap
created with processing 0135
by rce12
- click anywhere to paint
- press spacebar to clear screen and painter
my first work with ArrayList. I was use that to flexible
interaction [clicking anywhere, funky motion, etc.] and i was
creating a unique-aquarel-monochrome painter where you cilickin
at location.
*/
ArrayList flap;
void setup(){
size(500,500);
background(255);
flap=new ArrayList();
smooth();
}
void draw(){
for(int a=0;a<flap.size();a++){
flapper fp=(flapper)flap.get(a);
fp.interact();
fp.trail();
}
}
void mousePressed(){
//launch that
flapper launch=new flapper();
launch.x=mouseX;
launch.y=mouseY;
flap.add(launch);
}
void keyPressed(){
//reset
if(key==' '){
background(255);
flap.clear();
}
}
class flapper{
float x,y,x2,y2,x3,y3;
float theta,theta_tic;
float spd,spd_fd;
int gval=(int)random(255);
int style=(int)random(3);
flapper(){
//construct this
x=width/2;
y=height/2;
theta=random(-TWO_PI,TWO_PI)+random(-0.5,0.5);
spd=random(0.5,5);
spd_fd=random(0.9,1.1);
theta_tic=random(-0.01,0.01);
}
void interact(){
//create moves
x+=spd*cos(theta);
y+=spd*sin(theta);
//move on
theta+=theta_tic;
spd*=spd_fd;
//tickle
if(random(100)>99){
spd=-spd;
}
//collide
if((x<-width)||(x>width*2)||(y<-height)||(y>height*2)){
return;
}
}
void trail(){
//assign previous move for create trail
x3=x2;y3=y2;
x2=x;y2=y;
//draw
stroke(gval,42);
line(x,y,x3,y3);
//another flow in any direction
if(style==0){
line(width-x,y,width-x3,y3);
}else if(style==1){
line(x,height-y,x3,height-y3);
}else if(style==2){
line(width-x,height-y,width-x3,height-y3);
}
}
}