HTML canvas isPointInPath() methode

Definitie en gebruik

isPointInPath() De methode retourneert true;als het opgegeven punt zich op het huidige pad bevindt;anders retourneer false.

Voorbeeld

Teken een rechthoek, als het punt 20,50 zich op de huidige pad bevindt:

Uw browser ondersteunt de HTML5 canvas tag niet.

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

Syntax

context.isPointInPath(x,y);

Parameter value

Parameter Description
x Tested x coordinate
y Tested y coordinate

Browser support

The numbers in the table indicate the first browser version that fully supports this property.

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

Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.