0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

isPointInPath() に渡す点の座標系を確認する

0
Posted at

isPointInPath() の x と y は現在の変換行列の影響を受けない。translate() を使って描いたパスを調べるときも、渡す点がどの座標を表すか確認する。

マウス位置を扱う処理では、画面上の位置からキャンバス上の位置へ変換する段階を明確にする。CSS の表示サイズと描画バッファのサイズが異なる場合も、その対応を確認する。

まず変換のない状態で既知の点を試し、その後で描画に使う変換を加える。点の座標とパス側の座標を一緒に記録すると、どちらに補正が必要かを追いやすい。

指定した Path2D を調べる呼び方と、現在のパスを調べる呼び方も区別する。別のパスを参照した結果を、座標変換の問題と判断しないようにする。

参考: MDN isPointInPath()

Published by Morphio as part of our practical image workflow notes.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?