Last active
December 31, 2015 12:39
-
-
Save GideonPARANOID/7987806 to your computer and use it in GitHub Desktop.
As I always forget how to effectively do this.
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
/** | |
* @param eve an event object from function listening on the element, such as mousedown | |
* @return object describing the position of the mouse on the canvas | |
*/ | |
function mouse_pos(eve) { | |
var rect = eve.target.getBoundingClientRect(); | |
return { | |
y : eve.clientY - rect.top, | |
x : eve.clientX - rect.left | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment