0

Mozilla の getImageData に問題があります。キャンバスをクリックした後にマウスの座標を取得する機能を実行しました。座標は良好ですが、問題があります。Mozilla では getImageDatas の数が正しくないという問題があります。 : 10... どこに問題があるのか​​ わかりません... お願いします、助けてもらえますか? 関数は次のとおりです。http://pastebin.com/MjnG0Nbm

4

1 に答える 1

0

多分あなたの getMousePos() は常に望ましい結果をもたらすとは限りません

The amount of scrolling that has been done of the viewport area (or any other
scrollable element) is taken into account when computing the bounding rectangle.
This means that the top and left property change their values as soon as the
scrolling position changes (so their values are relative to the viewport and not
absolute). If this is not the desired behaviour just add the current scrolling
position to the top and left property (via window.scrollX and window.scrollY) to
get constant values independent from the current scrolling position.

代わりにこれを試してください:

function getMousePosition(canvas, evt) {
    return {
      x: evt.clientX - canvas.offsetLeft + window.scrollX,
      y: evt.clientY - canvas.offsetTop + window.scrollY
    };        
}
于 2013-03-10T08:36:04.070 に答える