Skip to content

Instantly share code, notes, and snippets.

@doxas
Created May 9, 2015 07:54
Show Gist options
  • Save doxas/8eca18c5d8e3b1c0fa5a to your computer and use it in GitHub Desktop.
Save doxas/8eca18c5d8e3b1c0fa5a to your computer and use it in GitHub Desktop.
mouse move
function mouseMove(e) {
var cw = c.width;
var ch = c.height;
var wh = 1 / Math.sqrt(cw * cw + ch * ch);
var x = e.clientX - c.offsetLeft - cw * 0.5;
var y = e.clientY - c.offsetTop - ch * 0.5;
var sq = Math.sqrt(x * x + y * y);
var r = sq * 2.0 * Math.PI * wh;
if (sq != 1) {
sq = 1 / sq;
x *= sq;
y *= sq;
}
q.rotate(r, [y, x, 0.0], qt);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment