CanvasContext.clearRect
Clear the content in the rect.
Parameters
It is Object type.
Property | Type | Description |
x | Number | The x coordinate of the left-upper corner of the rect. |
y | Number | The y coordinate of the left-upper corner of the rect. |
width | Number | The width of the rect. |
height | Number | The 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()