HTML canvas isPointInPath()Method
Example
If the point 20,50 is 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 Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
Internet Explorer 9, Firefox, Opera, Chrome, and Safari support the isPointInPath() method.
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.
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 Values
| Parameter | Description |
|---|---|
| x | The x-coordinate to test. |
| y | The y-coordinate to test. |
Other Extensions
Canvas Object