CanvasContext.clearRect

Clear the content in the rect.

Parameters

It is Object type.

FieldTypeDescription
xNumberThe x coordinate of the left-upper corner of the rect
yNumberThe y coordinate of the left-upper corner of the rect
widthNumberThe width of the rect
heightNumberThe height of the rect

Sample Code

copy
//.axml
<canvas id="awesomeCanvas" style="border: 1px solid; background: red;"/>
copy
// .js
const ctx = my.createCanvasContext('awesomeCanvas')
ctx.setFillStyle('blue')
ctx.fillRect(250, 10, 250, 200)
ctx.setFillStyle('yellow')
ctx.fillRect(0, 0, 150, 200)
ctx.clearRect(10, 10, 150, 75)
ctx.draw()