float theta, dtheta; float x,y,xo,yo,dx,dy; float r; // radius in ticks or pixels float v; // velocity in mm/tick float d; int framecnt=0; void setup() { size(400,400); framerate(60); smooth(); background(100); strokeWeight(3); stroke(0); x = width/2; y = height/2; theta = 0; dtheta = 0.1; r = 25; d = 6; } void draw() { framecnt++; xo = x; yo = y; theta += dtheta; //float a = (framecnt/100) * TWO_PI; dtheta = 0.1 * sin( framecnt/21.0 ) + random(-0.02,0.02); dx = d * sin(theta); dy = d * cos(theta); x = x + dx; y = y - dy; // torroidial mapping, sir if( x > width ) x = 0; if( x < 0 ) x = width; if( y > height ) y = 0; if( y < 0 ) y = height; drawIcon( x,y,theta ); } void keyPressed() { if( key == ']' ) { dtheta += 0.01; } else if( key == '[' ) { dtheta -= 0.01; } else if( key == ' ' ) { if( framerate < 10 ) framerate(30); else framerate(5); } } void drawIcon( float x, float y, float theta ) { // println("x="+(int)x+" y="+(int)y+" theta="+theta); translate(x,y); rotate(theta); fill( (x+y)%127 + 40, 0, 100-((y+x)%127) ); ellipse( 0,0, 20,20); line( 0,0, 0,-12); } void blech() { dx = r * sin(theta); dy = r * cos(theta); x = x + dx; y = y - dy; theta -= dtheta; //theta %= TWO_PI; println("x,y="+x+","+y+" dx,dy:"+dx+","+dy+" r:"+r+" framcnt:"+framecnt); //float th = (framecnt/30.0) * (2*PI); r = R * abs((sin(theta) - 0.2 * sin(theta))); }