jquery画布圈
我用画布画了一个倒计时 工作代码:jquery画布圈,jquery,Jquery,我用画布画了一个倒计时 工作代码: window.onload=function(){ canvas=document.getElementById('timer'), 秒=document.getElementById('counter'), ctx=canvas.getContext('2d'), 秒=180, 倒计时=秒; ctx.lineWidth=8; ctx.strokeStyle=“#528f20”; 变量 startAngle=0, 时间=0, intv=setInterval(
window.onload=function(){
canvas=document.getElementById('timer'),
秒=document.getElementById('counter'),
ctx=canvas.getContext('2d'),
秒=180,
倒计时=秒;
ctx.lineWidth=8;
ctx.strokeStyle=“#528f20”;
变量
startAngle=0,
时间=0,
intv=setInterval(函数(){
var endAngle=(Math.PI*时间*2/秒);
ctx.arc(65、35、30、星形、端角、假);
startAngle=端角;
ctx.stroke();
倒计时--;
如果(倒计时>60){
seconds.innerHTML=Math.floor(倒计时/60);
seconds.innerHTML+=“:”+倒计时%60;
}
否则{
seconds.innerHTML=倒计时;
}
如果(++time>sec,倒计时==0){clearInterval(intv),$(“#timer,#counter”).remove(),$(“#timers”).prepend(“”)}
}, 10);
}
我的问题是,如何才能让这幅画看起来更好,所以没有像素
我在jquerycanvas上搜索了很多,但似乎找不到我要找的地方 默认情况下,画布图形是抗锯齿的 你总是在以前的画面上画画 (证据) 您可以通过调用
ctx.clearRect(0, 0, 200, 200);
这将清除左上角先前绘制的200px正方形
ctx.clearRect(0, 0, 200, 200);