Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML canvas isPointInPath() method

HTML canvas isPointInPath() method

HTML canvas Reference HTML canvas Reference Manual

Example

If the point 20,50 is in the current path, then draw a rectangle:

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 »


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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.

HTML canvas Reference HTML canvas Reference Manual