قماش HTML clearRect () الطريقة

❮ مرجع قماش HTML

مثال

امسح مستطيل داخل مستطيل معين:

لا يدعم متصفحك HTML5canvastag.

جافا سكريبت:

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 ، العرض ، الارتفاع ) ؛

قيمه المعامل

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