float R,r,d; float theta,dtheta; float x,y,xo,yo; void setup() { size(400,400); framerate(60); smooth(); background(127); strokeWeight(7); theta = 0.0; dtheta = 0.2; R = 43; // radius of outer fixed circle r = 15; // radius of inner rolling circle d = 15; // distance from center of rolling circle update_xy(); theta %= TWO_PI; } float dr = 0.4; float s0 = 5; float s1 = 11; void update_xy() { //x = (R-r)*cos(theta) + d*cos( ((R-r)/r)*theta ); //y = (R-r)*sin(theta) - d*sin( ((R-r)/r)*theta ); x = r * cos(theta); y = r * sin(theta); } void draw() { translate(width/2,height/2); xo = x; yo = y; update_xy(); float dx = (x-xo); float dy = (y-yo); float t = atan2(dy,dx); float rx = dx/cos(t); float ry = dy/sin(t); // println("dx:"+dx+" dy:"+dy+" t:"+t+" rx:"+rx+" ry:"+ry+ // " r:"+(int)r+" x:"+(int)x+" y:"+(int)y); theta += dtheta; //d += random(-0.5,0.5); r += dr; // + random(-0.2,0.2); strokeWeight(random(s0,s1)); if( r> 200 ) { dr = random(-0.8,-0.5); stroke( 80+random(0,60),20,80+random(0,80)); s0 = 8; s1 = 10; } if( r < 0 ) { dr = random(0.6,0.8); stroke( random(0,40) ); s0 = 10; s1 = 12; } line( x,y, xo,yo ); if( drawPlatelets ) { strokeWeight(1); fill(90,0,20); ellipse( x,y, random(20,50),random(30,40)); } } boolean drawPlatelets = true; void keyPressed() { drawPlatelets = !drawPlatelets; }