下面我又定义了一个绘制时钟指针的构造函数。
- function clockNeedle(cnt,R,lineWidth,strokeStyle,lineCap,obj){
this.R=R;
- this.cnt=cnt;
this.lineWidth=lineWidth;
- this.strokeStyle=strokeStyle;
this.lineCap=lineCap;
- this.obj=obj;
this.getNeedleCoor=function(i){
- var X=200+this.R*0.8*Math.sin(i); //起点的坐标
var Y=200-this.R*0.8*Math.cos(i);
-
var x=200-20*Math.sin(i); //终点的坐标
- var y=200+20*Math.cos(i);
return {X:X,Y:Y,x:x,y:y};
- };
this.drawNeedle=function(){
- var d=new Date().getTime();
var angle;
- switch(this.obj){
case 0:
- angle=(d/3600000%24+8)/12*360*Math.PI/180;
break;