2018-08-27 17:53:36
48阅读
<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mouse coord (user help)</title>
<script type="text/javascript">
window.onload=function(){
var canvas = document.getElementById("imgCanvas");
var context = canvas.getContext("2d");
function createImageOnCanvas(imageId) {
}
function draw(e) {
var pos = getMousePos(canvas, e);
posx = pos.x;
posy = pos.y;
context.fillStyle = "#000000";
context.fillRect(posx, posy, 4, 4);
}
window.addEventListener('mousemove', draw, false);
function getMousePos(canvas, evt) {
var rect = canvas.getBoundingClientRect();
return {
x: (evt.clientX - rect.left) / (rect.right - rect.left) * canvas.width,
y: (evt.clientY - rect.top) / (rect.bottom - rect.top) * canvas.height
};
}
}
</script>
</head>
<body>
<div id="images"></div>
<canvas style="border:1px solid #000000;margin:0;padding:0;
position:relative;left:50px;top:50px;width:300px;height:300px"
id="imgCanvas" width="150" height="150"></canvas>
<script>
if (window.parent && window.parent.parent){
window.parent.parent.postMessage(["resultsFrame", {
height: document.body.getBoundingClientRect().height,
slug: "4xezb7nL"
}], "*")
}
</script>
</body>
</html>
最后生成于
2024-06-22 12:02:54
热门推荐:
此内容有帮助 ?
0