Rotating a square on an HTML5 Canvas so that it always fits in the corner. Move the mouse over the canvas to see the result.
Copyright © 2011 Gavin Kistner. Written to support this Stack Overflow answer.