We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › point involute code
Page Index Toggle Pages: 1
point involute code (Read 235 times)
point involute code
Mar 25th, 2008, 11:30am
 
hey guys

i have a open-sorce code by me. Its about fun with classes, it so creates a "painterish" and unique-interactivity. and it still a waves involutes the point based on mouse position.

this is my code

int tfade=0;

involuto[] it;
int nmb=100;

pointer pt=new pointer();

boolean startnow=true;

void setup(){
 size(500,500);
 background(240,222,58);
 
 it=new involuto[nmb];
 
 for(int a=0;a<it.length;a++){
   it[a]=new involuto();
 }
}

void draw(){
 if(startnow){
   if(tfade++>100){
     fill(240,222,58,50);
     rect(0,0,width,height);
     
     tfade=0;
   }
 
   pt.trail(0.0f,0.0f);
 
   for(int a=0;a<nmb;a++){
     it[a].trail();
   }
 }
}

void mousePressed(){
 startnow=!startnow;
}

class involuto{
 float x,y; //base position
 float xp,yp; //position [called by pointer]
 float radmo,themo; //controlled by mouse position
 
 float thtv; //theta velocity
 
 int tm; //timecount
 int tmv=int(random(5,25)); //velocity
 
 float thtm; //time-based theta
 
 involuto(){
   //no constructors here
 }
 
 void trail(){
   xp=mouseX+sin(pt.xp);
   yp=mouseY+sin(pt.yp);
   
   radmo=sqrt(sq(250-xp)+sq(250-yp));
   themo=atan2(250-xp,250-yp)*(180/PI);
   
   thtv=random(-10,10);
   themo+=thtv;
   thtv*=random(0.995,1.005);
   
   tm+=tmv*0.1;
   thtm=tmv*sin(tm);
   
   x=xp+radmo*cos(PI/180*(themo+thtm));
   y=yp+radmo*sin(PI/180*(themo+thtm));
   
   for(int a=0;a<tmv;a++){
     stroke(0,0,0,32);
     point(x-(x-xp)*sin(a),y-(y-yp)*sin(a));
   }
 }
}

class pointer{
 float xp;
 float yp;
 
 pointer(){
   //no constructors here
 }
 
 void trail(float xp0,float yp0){
   xp=xp0;
   yp=yp0;
 }
}

you can comment about your modification, mash-up, tips, .etc

enjoy!
Page Index Toggle Pages: 1