HTML canvas isPointInPath() method

Definition and usage

isPointInPath() The method returns trueif the specified point is in the current path; otherwise return false.

Example

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

Your browser does not support the HTML5 canvas tag.

JavaScript:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.rect(20,20,150,100);
if (ctx.isPointInPath(20,50))
   {
   ctx.stroke();
   };

Kokeile itse

Syntaksi

context.isPointInPath(x,y);

Parametrin arvo

Parametri Kuvaus
x Testatun x-akselin koordinaatti
y Testatun y-akselin koordinaatti

Selaimen tuki

Taulukossa olevat numerot osoittavat ensimmäisen täysin tukevan selaimen version.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
4.0 9.0 3.6 4.0 10.1

Huomautus:Internet Explorer 8 ja aikaisemmat versiot eivät tue <canvas> elementtiä.