<tfoot id='Nj8NO'></tfoot>
    1. <i id='Nj8NO'><tr id='Nj8NO'><dt id='Nj8NO'><q id='Nj8NO'><span id='Nj8NO'><b id='Nj8NO'><form id='Nj8NO'><ins id='Nj8NO'></ins><ul id='Nj8NO'></ul><sub id='Nj8NO'></sub></form><legend id='Nj8NO'></legend><bdo id='Nj8NO'><pre id='Nj8NO'><center id='Nj8NO'></center></pre></bdo></b><th id='Nj8NO'></th></span></q></dt></tr></i><div id='Nj8NO'><tfoot id='Nj8NO'></tfoot><dl id='Nj8NO'><fieldset id='Nj8NO'></fieldset></dl></div>
    2. <legend id='Nj8NO'><style id='Nj8NO'><dir id='Nj8NO'><q id='Nj8NO'></q></dir></style></legend>

        <bdo id='Nj8NO'></bdo><ul id='Nj8NO'></ul>
      1. <small id='Nj8NO'></small><noframes id='Nj8NO'>

        在画布中单击是三个像素

        Click in Canvas is three pixels off(在画布中单击是三个像素)
          <tfoot id='oIKVO'></tfoot>

              <tbody id='oIKVO'></tbody>

              • <bdo id='oIKVO'></bdo><ul id='oIKVO'></ul>

                <small id='oIKVO'></small><noframes id='oIKVO'>

                <legend id='oIKVO'><style id='oIKVO'><dir id='oIKVO'><q id='oIKVO'></q></dir></style></legend>
                  <i id='oIKVO'><tr id='oIKVO'><dt id='oIKVO'><q id='oIKVO'><span id='oIKVO'><b id='oIKVO'><form id='oIKVO'><ins id='oIKVO'></ins><ul id='oIKVO'></ul><sub id='oIKVO'></sub></form><legend id='oIKVO'></legend><bdo id='oIKVO'><pre id='oIKVO'><center id='oIKVO'></center></pre></bdo></b><th id='oIKVO'></th></span></q></dt></tr></i><div id='oIKVO'><tfoot id='oIKVO'></tfoot><dl id='oIKVO'><fieldset id='oIKVO'></fieldset></dl></div>
                  本文介绍了在画布中单击是三个像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我花了一整天的时间试图点击我的画布以返回像素 xy 偏移量.这是一项多么艰巨的任务!

                  这就是我最终得到的结果:

                  <!DOCTYPE html><html><头><meta charset="utf-8"><title>JS斌</title></头><身体><script src="https://code.jquery.com/jquery-1.10.2.js"></script><div id="logX">x</div><div id="logY">y</div><div style="margin-left:100px"><div style="margin-left:100px"><canvas id="myCanvas" width="100" height="1000" style="border:20px solid #000000;"></canvas></div></div><脚本>var canvas = document.getElementById('myCanvas');canvas.addEventListener('click', on_canvas_click, false);函数getNumericStyleProperty(样式,道具){返回 parseInt(style.getPropertyValue(prop),10);}功能 on_canvas_click(ev) {var boundingRect = ev.target.getBoundingClientRect();var x = ev.clientX - boundingRect.left,y = ev.clientY - boundingRect.top;var style = getComputedStyle(canvas, null);x -= getNumericStyleProperty(style, "margin-left");y -= getNumericStyleProperty(style, "margin-top");x -= getNumericStyleProperty(style, "border-left-width");y -= getNumericStyleProperty(style, "border-top-width");x -= getNumericStyleProperty(style, "padding-left");y -= getNumericStyleProperty(style, "padding-top");$("#logX").text(ev.target.getBoundingClientRect().left+ ", " + ev.clientX+ ", " + canvas.offsetLeft+ ", " + x);$("#logY").text(ev.target.getBoundingClientRect().top+ ", " + ev.clientY+ ", " + canvas.offsetTop+ ", " + y);}//$( document ).on( "mousemove", function( event ) {//$( "#log" ).text( "pageX: " + event.pageX + ", pageY: " + event.pageY );/
                                  
                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to make rooftext effect and valley text effect in HTML5 (or Fabric.js)(如何在 HTML5(或 Fabric.js)中制作屋顶文字效果和山谷文字效果)
                  Draw border around nontransparent part of image on canvas(在画布上的图像不透明部分周围绘制边框)
                  dragging and resizing an image on html5 canvas(在 html5 画布上拖动图像并调整其大小)
                  What#39;s the difference between a boolean as primitive and a boolean as property of an object?(作为原始对象的布尔值和作为对象属性的布尔值有什么区别?)
                  I want to do animation of an object along a particular path(我想沿特定路径对对象进行动画处理)
                  How to upload image into HTML5 canvas(如何将图像上传到 HTML5 画布中)
                    <bdo id='3CiWk'></bdo><ul id='3CiWk'></ul>
                  • <tfoot id='3CiWk'></tfoot>

                        <i id='3CiWk'><tr id='3CiWk'><dt id='3CiWk'><q id='3CiWk'><span id='3CiWk'><b id='3CiWk'><form id='3CiWk'><ins id='3CiWk'></ins><ul id='3CiWk'></ul><sub id='3CiWk'></sub></form><legend id='3CiWk'></legend><bdo id='3CiWk'><pre id='3CiWk'><center id='3CiWk'></center></pre></bdo></b><th id='3CiWk'></th></span></q></dt></tr></i><div id='3CiWk'><tfoot id='3CiWk'></tfoot><dl id='3CiWk'><fieldset id='3CiWk'></fieldset></dl></div>

                          <small id='3CiWk'></small><noframes id='3CiWk'>

                        • <legend id='3CiWk'><style id='3CiWk'><dir id='3CiWk'><q id='3CiWk'></q></dir></style></legend>

                            <tbody id='3CiWk'></tbody>