canvasContext.clearRect
解释:清除画布上在该矩形区域内的内容。
参数:
参数名 | 类型 | 说明 |
---|---|---|
x | Number | 矩形路径左上角的 x 坐标 |
y | Number | 矩形路径左上角的 y 坐标 |
width | Number | 矩形路径的宽度 |
height | Number | 矩形路径的高度 |
示例:
- const ctx = swan.createCanvasContext('myCanvas');
ctx.setFillStyle('red');
ctx.fillRect(0, 0, 150, 200);
ctx.setFillStyle('blue');
ctx.fillRect(150, 0, 150, 200);
ctx.clearRect(30, 30, 150, 75);
ctx.draw();