HTML canvas isPointInPath() method
Example
If the point 20,50 is in the current path, then 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();
};
Try it »
Browser support





Internet Explorer 9, Firefox, Opera, Chrome and Safari support the isPointInPath() method.
**Note:** Internet Explorer 8 and earlier versions do not support
Definition and Usage
If the specified point is in the current path, the isPointInPath() method returns true; otherwise it returns false.
| JavaScript syntax: | context.isPointInPath(x,y); |
|---|
Parameter value
| Parameters | Description |
|---|---|
| x | The x-coordinate to test. |
| y | The y-coordinate to test. |
Canvas object