rce12
YaBB Newbies
Offline
Posts: 6
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!