examples/resources/js/treasure-hunt.js
function getCursorPosition(event) {
  let cursorX;
  let cursorY;
  let rect = htmlElement.getBoundingClientRect();
  if (event.touches !== undefined) {
    cursorX = event.touches[0].clientX;
    cursorY = event.touches[0].clientY;
  } else {
    cursorX = event.clientX;
    cursorY = event.clientY;
  }
  return {
    x: cursorX - rect.left,
    y: cursorY - rect.top,
  };
}
function getCursorPosition(event) {
  let cursorX;
  let cursorY;
  let rect = htmlElement.getBoundingClientRect();
  if (event.touches !== undefined) {
    cursorX = event.touches[0].clientX;
    cursorY = event.touches[0].clientY;
  } else {
    cursorX = event.clientX;
    cursorY = event.clientY;
  }
  return {
    x: cursorX - rect.left,
    y: cursorY - rect.top,
  };
}
function getCursorPosition ( event ) { let cursorX ; let cursorY ; let rect = htmlElement . getBoundingClientRect ( ) ; if ( event . touches !== undefined ) { cursorX = event . touches [ 0 ] . clientX ; cursorY = event . touches [ 0 ] . clientY ; } else { cursorX = event . clientX ; cursorY = event . clientY ; } return { x : cursorX - rect . left , y : cursorY - rect . top , } ; }
Get cursor position on canvas.
@param {Object} event
@return {Object}
@private
Get cursor position on canvas .