ポイント 20,50 は、現在のパスにある場合に四角形を描画します:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.rect(20,20,150,100);
if (ctx.isPointInPath(20,50))
{
ctx.stroke();
};
Try it Yourself ❯
表中の数字は、メソッドを完全にサポートした最初のブラウザ・バージョンを指定しています。
| メソッド | |||||
|---|---|---|---|---|---|
| isPointInPath() | Yes | 9.0 | Yes | Yes | Yes |
isPointInPath() メソッドは、指定のポイントが現在のパスにある場合は true を、それ以外の場合は false を返します。
| JavaScript 構文: | context.isPointInPath(x,y); |
|---|
| パラメータ | 説明 |
|---|---|
| x | 確認する x 座標 |
| y | 確認する y 座標 |
HTML Canvas リファレンス