canvas教程

canvas自适应圆形时钟绘制(2)

字号+ 作者:H5之家 来源:H5之家 2017-09-01 10:00 我要评论( )

最终完整代码如下所示 Document ); if (drawing.getContext){ ); ; ; ; R; function drawStatics(){cxt.save();cxt.translate(R,R);cxt.beginPath();cxt.lineWidth R;cxt.arc( cxt.stroke();cxt.beginPath();cxt.fo

  最终完整代码如下所示

Document); if(drawing.getContext){ ); ; ; ; R; function drawStatics(){ cxt.save(); cxt.translate(R,R); cxt.beginPath(); cxt.lineWidth R; cxt.arc( cxt.stroke(); cxt.beginPath(); cxt.font ; cxt.textAlign ; cxt.textBaseline ; ){ r1; r1; cxt.fillText(i,x,y); } cxt.beginPath(); ){ r2; r2; cxt.beginPath(); ){ cxt.arc(x,y,cw{ cxt.arc(x,y,cw/8,0,2*Math.PI,false); } cxt.fill(); } cxt.restore(); } function drawDot(){ cxt.save(); cxt.translate(R,R); cxt.beginPath(); cxt.arc( cxt.fill(); cxt.restore(); } function drawSecond(second){ cxt.save(); cxt.translate(R,R); cxt.beginPath(); cxt.rotate(radius); cxt.lineWidth = 2; cxt.moveTo(); cxt.lineTo(R); cxt.strokeStyle ; cxt.stroke(); cxt.restore(); } function drawMinute(minute,second){ cxt.save(); cxt.translate(R,R); cxt.beginPath(); second; cxt.rotate(radius + sRaiuds); cxt.lineWidth = 4; cxt.lineCap ; cxt.moveTo(0,cw); cxt.lineTo( cxt.stroke(); cxt.restore(); } function drawHour(hour,minute){ cxt.save(); cxt.translate(R,R); cxt.beginPath(); minute; cxt.rotate(radius + mRaiuds); cxt.lineWidth = 6; cxt.lineCap ; cxt.moveTo()); cxt.stroke(); cxt.restore(); } function draw(){ cxt.clearRect(,W,H); drawStatics(); Date(); drawHour(now.getHours(),now.getMinutes()); drawMinute(now.getMinutes(),now.getSeconds()); drawSecond(now.getSeconds()); drawDot(); } draw(); setInterval(draw,500); }

 

爱编程-编程爱好者经验分享平台

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
网友点评
>