HTML canvas isPointInPath () method
Examples
If the point 20,50 in the current path, draw a rectangle:
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();
};
try it"
Browser Support
Internet Explorer 9, Firefox, Opera, Chrome and Safari support isPointInPath () method.
Note: 8 and earlier versions of Internet Explorer do not support the <canvas> element.
Definition and Usage
If the specified point in the current path, isPointInPath () method returns true, otherwise it returns false.
JavaScript syntax: | context.isPointInPath (x, y); |
---|
Parameter Value
参数 | 描述 |
---|---|
x | 要测试的 x 坐标。 |
y | 要测试的 y 坐标。 |
HTML canvas Reference Manual