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 & HelpSyntax Questions › Help with constant size change (code included)
Page Index Toggle Pages: 1
Help with constant size change (code included) (Read 511 times)
Help with constant size change (code included)
Nov 7th, 2009, 10:47am
 
I've been experimenting with this one for fun, but it's doing something I rather it didn't. If you copy the code and observe it, you'll notice that a 3D trail of ellipses follows your mouse and changes constantly in size/color. After a while, however, the size changing stops and it's just a solid tube trailing after the mouse. If you click, you can erase and start a clean slate, but the size changing is still stopped. How can I fix it so it will continue to "jitter" size like at the beginning for a while longer?
Here it is:
Code:
float speed2=1; 
float gravity=0.1;
float x, y, mx, my,speed;

void setup(){
 size(900,600);
 background(0);
 smooth();
}

void draw(){
 mx = mx + (mouseX-mx)/200;  
 my += (mouseY-my)/200;  



 speed=speed+gravity;
 x=x+ speed;
 y=y+speed2;


 if((x>height)|| (x<0)){

   speed=speed*-1;
 }

 if((y>width)|| (y<0)){

   speed2=speed2*-1;
 }

 stroke(0,0,0,100);
 fill(x,y,255,100);
 ellipse(mx+random(2),my+random(2),x/6,x/6);

 if(mousePressed){
   background(0);
 }
}
Re: Help with constant size change (code included)
Reply #1 - Nov 7th, 2009, 11:26am
 
Nevermind, that aspect fo he sketch works now- does anyone know how to make the changing colors have a bigger variety?
Re: Help with constant size change (code included)
Reply #2 - Nov 7th, 2009, 11:54am
 
you can switch to HSB colorMode and use the whole color Range
http://processing.org/reference/colorMode_.html
and maybe use map, to make it change throughout the whole width and hight, not only the first 255px...
Page Index Toggle Pages: 1