//float base = 0; float sz = 50; import gifAnimation.*; GifMaker gifExport; SmallHeart h1; SmallHeart h2; SmallHeart h3; float BIGNUM = 40; void setup() { size(500,500); gifExport = new GifMaker(this, "atomicraw.gif"); gifExport.setRepeat(0); // make it an "endless" animation smooth(); strokeWeight(4); noStroke(); h1 = new SmallHeart(); h2 = new SmallHeart(); h3 = new SmallHeart(); } float bigAngle = 0; void draw(){ frameRate(10); background(255); bigAngle += PI/BIGNUM; h1.moveAndDraw(bigAngle,false); h2.moveAndDraw(bigAngle+PI*2/3,false); h3.moveAndDraw(bigAngle+PI*4/3,false); fill(200,0,0); drawHeart(250,250,100); h1.moveAndDraw(bigAngle,true); h2.moveAndDraw(bigAngle+PI*2/3,true); h3.moveAndDraw(bigAngle+PI*4/3,true); if(frameCount > BIGNUM * 2){ gifExport.finish(); } else { gifExport.setDelay(10); gifExport.addFrame(); } // gifExport.setDelay(1); // gifExport.addFrame(); //base += .025; } class SmallHeart{ float a; void moveAndDraw(float bigAngle, boolean inFront){ float oldX = cos(a) * 200; float oldY = sin(a) * 20; float newX = rotatedX(oldX,oldY,bigAngle); float newY = rotatedY(oldX,oldY,bigAngle); pushMatrix(); stroke(0); noFill(); translate(250,250); rotate(bigAngle); arc(0,0,400,40, inFront?0:PI, inFront?PI:PI*2 ); popMatrix(); if(inFront) { if(a >= 0 && a <= PI){ fill(150,0,0); drawHeart(250 + newX,250 + newY,20); } } else { if(a >= PI && a <= 2 * PI){ fill(150,0,0); drawHeart(250 + newX,250 + newY,20); } } a += PI/BIGNUM; while( a > PI*2){ a -= PI * 2; } } } float rotatedX(float x, float y, float a){ return x * cos(a) - y * sin(a); } float rotatedY(float x, float y, float a){ return y * cos(a) + x * sin(a); } void drawHeart(float x, float y, float sz){ noStroke(); pushMatrix(); translate(x,y); arc(-sz*.4,0,sz,sz,PI,2*PI); arc(sz*.4,0,sz,sz,PI,2*PI); triangle(-sz*.9,0,sz*.9,0,0,sz); popMatrix(); }