Browse Source

show hovered position for better orientation.

Lucas Stadler 12 years ago
parent
commit
41a47a50d7
1 changed files with 11 additions and 0 deletions
  1. 11 0
      js/pixl/public/index.html

+ 11 - 0
js/pixl/public/index.html

11
			top: 0;
11
			top: 0;
12
			left: 0;
12
			left: 0;
13
		}
13
		}
14
15
		#status {
16
			position: absolute;
17
			bottom: 0;
18
			right: 0;
19
		}
14
	</style>
20
	</style>
15
</head>
21
</head>
16
22
17
<body>
23
<body>
18
	<canvas id="stage"></canvas>
24
	<canvas id="stage"></canvas>
25
	<span id="status"></span>
19
	<script>
26
	<script>
20
		window.polyfill = {};
27
		window.polyfill = {};
21
28
29
		window.pixl = {};
36
		window.pixl = {};
30
		pixl.stage = document.querySelector("#stage");
37
		pixl.stage = document.querySelector("#stage");
31
		pixl.ctx = stage.getContext("2d");
38
		pixl.ctx = stage.getContext("2d");
39
		pixl.status = document.querySelector("#status");
32
		pixl.window = {w: window.innerWidth, h: window.innerHeight};
40
		pixl.window = {w: window.innerWidth, h: window.innerHeight};
33
		pixl.world = {};
41
		pixl.world = {};
34
		pixl.pos = {x: 0, y: 0};
42
		pixl.pos = {x: 0, y: 0};
118
			if (pixl.drag.start !== undefined) {
126
			if (pixl.drag.start !== undefined) {
119
				pixl.drag.current = {x: ev.clientX, y: ev.clientY};
127
				pixl.drag.current = {x: ev.clientX, y: ev.clientY};
120
			}
128
			}
129
130
			var hovered = pixl.to_world({x: ev.clientX, y: ev.clientY});
131
			pixl.status.textContent = hovered.x + "," + hovered.y;
121
		});
132
		});
122
133
123
		pixl.stage.addEventListener("mouseup", function(ev) {
134
		pixl.stage.addEventListener("mouseup", function(ev) {