responsive-sketchpad.js
function getCursorRelativeToCanvas (e) {
            var cur = {};

            if (isTouchEvent(e)) {
                cur.x = e.touches[0].pageX - canvas.offsetLeft;
                cur.y = e.touches[0].pageY - canvas.offsetTop;
            } else {
                var rect = that.canvas.getBoundingClientRect();
                cur.x = e.clientX - rect.left;
                cur.y = e.clientY - rect.top;
            }

            return getPointRelativeToCanvas(cur);
        }
function getCursorRelativeToCanvas (e) {
            var cur = {};

            if (isTouchEvent(e)) {
                cur.x = e.touches[0].pageX - canvas.offsetLeft;
                cur.y = e.touches[0].pageY - canvas.offsetTop;
            } else {
                var rect = that.canvas.getBoundingClientRect();
                cur.x = e.clientX - rect.left;
                cur.y = e.clientY - rect.top;
            }

            return getPointRelativeToCanvas(cur);
        }
function getCursorRelativeToCanvas ( e ) { var cur = { } ; if ( isTouchEvent ( e ) ) { cur . x = e . touches [ 0 ] . pageX - canvas . offsetLeft ; cur . y = e . touches [ 0 ] . pageY - canvas . offsetTop ; } else { var rect = that . canvas . getBoundingClientRect ( ) ; cur . x = e . clientX - rect . left ; cur . y = e . clientY - rect . top ; } return getPointRelativeToCanvas ( cur ) ; }
Get location of the cursor in the canvas
Get location of the cursor in the canvas