HTML canvas isPointInPath() Method
ตัวอย่าง
วาดรูปสี่เหลี่ยมผืนผ้าถ้าจุด 20,50 อยู่ในเส้นทางปัจจุบัน:
จาวาสคริปต์:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.rect(20, 20, 150, 100);
if (ctx.isPointInPath(20, 50)) {
ctx.stroke();
};
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่รองรับวิธีการนี้อย่างเต็มที่
Method | |||||
---|---|---|---|---|---|
isPointInPath() | Yes | 9.0 | Yes | Yes | Yes |
ความหมายและการใช้งาน
เมธอด isPointInPath() คืนค่า จริง หากจุดที่ระบุอยู่ในเส้นทางปัจจุบัน มิฉะนั้น จะเป็นเท็จ
ไวยากรณ์ JavaScript: | บริบท .isPointInPath( x,y ); |
---|
ค่าพารามิเตอร์
Parameter | Description |
---|---|
x | The x-coordinate to test |
y | The y-coordinate to test |
❮ อ้างอิงผ้าใบ HTML