HTML canvas isPointInPath() 方法
實例
如果點 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();
};
var ctx=c.getContext("2d");
ctx.rect(20,20,150,100);
if (ctx.isPointInPath(20,50))
{
ctx.stroke();
};
流覽器支持





Internet Explorer 9、Firefox、Opera、Chrome 和 Safari 支持 isPointInPath() 方法。
注意:Internet Explorer 8 及之前的版本不支持 <canvas> 元素。
定義和用法
如果指定的點位於當前路徑中,isPointInPath() 方法返回 true,否則返回 false。
| JavaScript 語法: | context.isPointInPath(x,y); | 
|---|
參數值
| 參數 | 描述 | 
|---|---|
| x | 要測試的 x 座標。 | 
| y | 要測試的 y 座標。 | 

 Canvas 對象
 Canvas 對象