Browse Source

working on canvas mouse position

master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
c4b05cb3e5
  1. 22
      web/chunkymap.php

22
web/chunkymap.php

@ -1078,20 +1078,24 @@ function echo_chunkymap_canvas($show_player_names_enable, $decachunks_enable, $c
draw_map(); draw_map();
} }
function getMousePos(canvas, e) { //function getMousePos(canvas, e) {
var rect = canvas.getBoundingClientRect(); // var rect = canvas.getBoundingClientRect();
return { // return {
x: e.clientX - rect.left, // x: e.clientX - rect.left,
y: e.clientY - rect.top // y: e.clientY - rect.top
}; // };
} //}
function get_relative_mouse_point(e) { function get_relative_mouse_point(e) {
var xOffset=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft); var xOffset=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft);
var yOffset=Math.max(document.documentElement.scrollTop,document.body.scrollTop); var yOffset=Math.max(document.documentElement.scrollTop,document.body.scrollTop);
//return {
//x:parseInt(e.clientX+xOffset-my_canvas.offsetLeft),
//y:parseInt(e.clientY+yOffset-my_canvas.offsetTop)
//};
return { return {
x:parseInt(e.clientX+xOffset-my_canvas.offsetLeft), x:parseInt(e.clientX+xOffset),
y:parseInt(e.clientY+yOffset-my_canvas.offsetTop) y:parseInt(e.clientY+yOffset)
}; };
} }

Loading…
Cancel
Save