HTML-Canvas isPointInPath()Methode
Beispiel
Wenn der Punkt 20,50 im aktuellen Pfad liegt, zeichne ein Rechteck:
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();
};
Selbst ausprobieren »
Browser-Unterstützung
![]()
![]()
![]()
![]()
![]()
Internet Explorer 9, Firefox, Opera, Chrome und Safari unterstützen die isPointInPath()-Methode.
Hinweis:Internet Explorer 8 und frühere Versionen unterstützen das <canvas>-Element nicht.
Definition und Verwendung
Wenn der angegebene Punkt im aktuellen Pfad liegt, gibt die isPointInPath()-Methode true zurück; andernfalls gibt sie false zurück.
| JavaScript-Syntax: | context.isPointInPath(x,y); |
|---|
Parameterwerte
| Parameter | Beschreibung |
|---|---|
| x | Die x-Koordinate zum Testen. |
| y | Die y-Koordinate zum Testen. |
Andere Erweiterungen
Canvas 对象