-
Notifications
You must be signed in to change notification settings - Fork 0
/
mousePointer.js
58 lines (28 loc) · 1.52 KB
/
mousePointer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
mousePointerArmed = true;
canvas.addEventListener('mousemove', function(e) {
//alert('stupid@');
e.preventDefault();
var mousePos = getMousePos(canvas, e);
mousePos.x = Math.floor(mousePos.x);
mousePos.y = Math.floor(mousePos.y);
//mousePos.x = (mousePos.x - canvas.width/2 )/zoomFactor + pC.x
//mousePos.y = ( - mousePos.y + canvas.height - canvas.height/2 ) / zoomFactor + pC.y
var message =
'Mouse position on board: ' + (mousePos.x) + ", " +
(mousePos.y );
document.getElementById("mousePos").innerHTML=message;
//alert(message);
}, false);
// (canvasPointX - canvas.width/2 )/zoomFactor + pC.x = modelPointX
// ( - canvasPointY + canvas.height - canvas.height/2 ) / zoomFactor + pC.y = modelPointX
// // renderPoint = function(modelPointX, modelPointY){
// // var difX = modelPointX - pC.x;
// // var difY = modelPointY - pC.y;
// // var canvasPointX = difX*zoomFactor + canvas.width/2
// // (canvasPointX - canvas.width/2 )/zoomFactor + pC.x = modelPointX
// // ( - canvasPointY + canvas.height - canvas.height/2 ) / zoomFactor + pC.y = modelPointX
// // //have to invert y axis because canvas == stupid!
// // var canvasPointY = canvas.height - (difY*zoomFactor + canvas.height/2)
// // //return [canvasPointX, canvasPointY]
// // return [canvasPointX, canvasPointY]
// // }