老师,我这个clearRect怎么清除不掉呀
来源:9-3 完成案例动画部分
李知恩
2020-05-07 13:05:05
<canvas id="snow" class="snow" width="600px" height="600px">
您的浏览器不支持canvas!
</canvas>
//雪花绘制
var snow = document.getElementById("snow");
var snowCtx = snow.getContext("2d");
var posx = 20;
var posy = 20;
setInterval(function(){
//清除矩形区域
snowCtx.clearRect(0,0,snow.width,snow.height);
snowCtx.fillStyle="rgba(255,255,255,0.5)";
snowCtx.arc(posx,posy,20,0,2*Math.PI,true);
snowCtx.fill();
posy += 10;
if(posy>= snow.height){
posy=20;
}
},100);
1回答
好帮手慕星星
2020-05-07
同学你好,是清除掉的,每次绘制的时候开启新路径就可以,如下
自己再测试下,祝学习愉快!
相似问题