Stupid Web Tricks: Orbit Animation

Click inside the box to see the orbiting Domo-Kun. Click inside it again to stop the animation.

This little widget is just the result of experimenting with JavaScript's trig methods (Math.cos and Math.sin among others). I was also thinking about domo-kun, and one thing led to another. This is the result.

I used YAHOO.util.Event for the convenience of having a cross-browser Event listener model.

I suppose the only interesting thing is the rounding error because of the series computation in the Math methods. For example, Math.sin(2 * Math.PI) isn't zero, but a number on the order of 10-16, which is obviously fine when moving silly characters on the screen.