For each digest I do a little heart-based doodle. This month (for the annual "Valentines" issue) I took it a step further and made this little animation:
Here is the Processing2 source code.
Small bits of cleverness involved:
- Because I wanted the heart electrons to stay upright, I looked up how to manually do a sin/cos based rotation rather than rely on rotate() which would have changed their entire angle - though now I'm wondering if I could have just done a normal rotate() call, and then a counter-rotate call when I actually drew the little heart.
- I draw half the orbit lines first, then the heart, then the other half, to get the 3D effect. Similarly, I draw the orbiting heart if it's in the"behind" part of its rotation first, then the big heart, then I draw the small heart if it's "in front".
- I increment the angles by divisors of PI (in this case PI/40) and then twice that divisor (80) makes a nice looping animation. Admittedly it was a mix of getting the numbers right from first principles and via experimentation.
I wasn't entirely happy with how I drew each heart, using the old "two circles and a triangle" method, but there's enough cool stuff going on that I don't think people notice. Also, I noticed the hearts didn't draw quite smoothly in the fullsize version (I think errors with sub-pixel increments) but resizing from 500px to 125px via ImageMagick fixed that.
Also, here's a fireworks animation I made in July of 2011:
|source code here|
Animations are fun to make.