Canvas isPointInPath() 方法
定义和用法
isPointInPath()
方法返回 true
,如果指定的点位于当前路径中;否则返回 false
。
实例
绘制一个矩形,如果点 20,50 位于当前路径中:
JavaScript:
var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.rect(20,20,150,100); if (ctx.isPointInPath(20,50)) { ctx.stroke(); };
语法
context.isPointInPath(x,y);
Parametrien arvot
Parametrit | Kuvaus |
---|---|
x | Testatun x-koordinaatin |
y | Testatun y-koordinaatin |
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ä.