FREE Web Template Download
HTML CSS JAVASCRIPT SQL PHP BOOTSTRAP JQUERY ANGULARJS TUTORIALS REFERENCES EXAMPLES Blog
 

HTML canvas isPointInPath() Method

HTML canvas Reference HTML Canvas Reference

Example

Draw a rectangle if the point 20,50 is in the current path:

YourbrowserdoesnotsupporttheHTML5canvastag.

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 »

Browser Support

The numbers in the table specify the first browser version that fully supports the method.

Method
isPointInPath() Yes 9.0 Yes Yes Yes

Definition and Usage

The isPointInPath() method returns true if the specified point is in the current path, otherwise false.

JavaScript syntax: context.isPointInPath(x,y);

Parameter Values

Parameter Description
x The x-coordinate to test
y The y-coordinate to test

HTML canvas Reference HTML Canvas Reference