ข้อมูลอ้างอิงHTML

HTML โดยตัวอักษร HTML ตามหมวดหมู่ รองรับ HTML Browser แอตทริบิวต์ HTML HTML Global Attributes เหตุการณ์ HTML HTML สี HTML Canvas HTML เสียง/วิดีโอ ชุดอักขระ HTML HTML Doctypes การเข้ารหัส URL HTML รหัสภาษา HTML รหัสประเทศ HTML ข้อความ HTTP วิธี HTTP ตัวแปลง PX เป็น EM แป้นพิมพ์ลัด


ผ้าใบ HTML clearRect ()วิธี การ

❮ อ้างอิงผ้าใบ HTML

ตัวอย่าง

ล้างสี่เหลี่ยมภายในสี่เหลี่ยมที่กำหนด:

YourbrowserdoesnotsupporttheHTML5canvastag.

จาวาสคริปต์:

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 300, 150);
ctx.clearRect(20, 20, 100, 50);

รองรับเบราว์เซอร์

ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่รองรับวิธีการนี้อย่างเต็มที่

Method
clearRect() Yes 9.0 Yes Yes Yes

ความหมายและการใช้งาน

clearRect() วิธีการล้างพิกเซลที่ระบุภายในสี่เหลี่ยมที่กำหนด

ไวยากรณ์ JavaScript: บริบท .clearRect ( x,y,width,height );

ค่าพารามิเตอร์

Parameter Description Play it
x The x-coordinate of the upper-left corner of the rectangle to clear
y The y-coordinate of the upper-left corner of the rectangle to clear
width The width of the rectangle to clear, in pixels
height The height of the rectangle to clear, in pixels

❮ อ้างอิงผ้าใบ HTML