HTML-Leinwand isPointInPath () -Methode
Beispiele
Wenn der Punkt 20,50 im Strompfad, zeichnen Sie 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();
};
Versuchen »
Browser-Unterstützung
Internet Explorer 9, Firefox, Opera, Chrome und Safari Unterstützung isPointInPath () -Methode.
Hinweis: 8 und frühere Versionen von Internet Explorer unterstützt nicht das <canvas> -Element.
Definition und Verwendung
Wenn der angegebene Punkt im Strompfad, isPointInPath () -Methode true zurück, andernfalls wird false zurückgegeben.
JavaScript-Syntax: | Kontext.isPointInPath (x, y); |
---|
Parameter Wert
参数 | 描述 |
---|---|
x | 要测试的 x 坐标。 |
y | 要测试的 y 坐标。 |