Created
May 9, 2015 07:54
-
-
Save doxas/8eca18c5d8e3b1c0fa5a to your computer and use it in GitHub Desktop.
mouse move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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