最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

纯js代码制作的网页时钟

来源:动视网 责编:小采 时间:2020-11-27 20:32:26
文档

纯js代码制作的网页时钟

纯js代码制作的网页时钟: //oObj input requires that a matrix filter be applied. //deg input defines the requested angle of rotation. var deg2radians = Math.PI * 2 / 360; function MatrixFilter(obj) { if(!obj.filters)return; //alert(obj.filters.item
推荐度:
导读纯js代码制作的网页时钟: //oObj input requires that a matrix filter be applied. //deg input defines the requested angle of rotation. var deg2radians = Math.PI * 2 / 360; function MatrixFilter(obj) { if(!obj.filters)return; //alert(obj.filters.item


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
//oObj input requires that a matrix filter be applied. 
//deg input defines the requested angle of rotation. 
var deg2radians = Math.PI * 2 / 360; 
function MatrixFilter(obj) 
{ 
 if(!obj.filters)return; 
 //alert(obj.filters.item(0)); 
 var Matrix; 
 for(p in obj.filters) 
 { 
 if(p=="DXImageTransform.Microsoft.Matrix")Matrix=obj.filters["DXImageTransform.Microsoft.Matrix"]; 
 } 
 if(!Matrix) 
 { 
 obj.style.filter+="progid:DXImageTransform.Microsoft.Matrix()"; 
 } 
 Matrix=obj.filters["DXImageTransform.Microsoft.Matrix"]; 
 this.equal=function(Matrix2D_x) 
 { 
 if(Matrix2D_x.M11)Matrix.M11 = Matrix2D_x.M11; 
 if(Matrix2D_x.M12)Matrix.M12 = Matrix2D_x.M12; 
 if(Matrix2D_x.M21)Matrix.M21 = Matrix2D_x.M21; 
 if(Matrix2D_x.M22)Matrix.M22 = Matrix2D_x.M22; 
 } 
 
 if(arguments[1])this.equal(arguments[1]); 
 
 this.Rotate=function(deg) 
 { 
 rad = deg * deg2radians; 
 costheta = Math.cos(rad); 
 sintheta = Math.sin(rad); 
 var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); 
 this.equal(Matrix2D.Mul(Matrix,d)); 
 } 
 this.RotateTo=function(deg) 
 { 
 rad = deg * deg2radians; 
 costheta = Math.cos(rad); 
 sintheta = Math.sin(rad); 
 var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); 
 this.equal(d); 
 } 
 this.RotateAt=function(deg,sx,sy) 
 { 
 rad = deg * deg2radians; 
 costheta = Math.cos(rad); 
 sintheta = Math.sin(rad); 
 var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); 
 var x=sx-Matrix.Dx; 
 var y=sy-Matrix.Dy; 
 this.MoveTo(x*costheta+y*sintheta-x,-x*sintheta+y*costheta-y); 
 this.equal(Matrix2D.Mul(Matrix,d)); 
 } 
 this.RotateToAt=function(deg,sx,sy) 
 { 
 rad = deg * deg2radians; 
 costheta = Math.cos(rad); 
 sintheta = Math.sin(rad); 
 var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); 
 var x=sx; 
 var y=sy; 
 this.MoveTo(x-(x*costheta-y*sintheta),-(x*sintheta+y*costheta-x)); 
 this.equal(d); 
 } 

 this.MoveTo=function(sx,sy) 
 { 
 Matrix.Dx=sx; 
 Matrix.Dy=sy; 
 } 
 this.toMatrix2D=function() 
 { 
 return new Matrix2D(Matrix.M11,Matrix.M12,Matrix.M21,Matrix.M22); 
 } 
 this.ZoomBy=function(sx,sy) 
 { 
 var d=new Matrix2D(sx,0,0,sy); 
 this.equal(Matrix2D.Mul(Matrix,d)); 
 } 
 this.toString=function() 
 { 
 return ""+Matrix.M11+" "+Matrix.M12+"\n"+Matrix.M21+" "+Matrix.M22+"\n" 
 } 
 //Matrix.SizingMethod='clip to original'; 
 //this.fnSetRotation(30); 
 //alert(Matrix.M11); 
 //alert(obj.filters["DXImageTransform.Microsoft.Matrix"]); 
} 
function Matrix2D() 
{ 
 this.M11 = arguments[0]||1; 
 this.M12 = arguments[1]||0; 
 this.M21 = arguments[2]||0; 
 this.M22 = arguments[3]||1; 
 this.Mul_Matrix2D=function(Matrix2D_b) 
 { 
 var r=new Matrix2D(); 
 r=Matrix2D.Mul(this,Matrix2D_b); 
 return r; 
 } 
 this.toString=function() 
 { 
 return ""+this.M11+" "+this.M12+"\n"+this.M21+" "+this.M22+"\n" 
 } 
} 
Matrix2D.Mul=function(Matrix2D_a,Matrix2D_b) 
{ 
 var r=new Matrix2D(); 
 r.M11=Matrix2D_a.M11*Matrix2D_b.M11+Matrix2D_a.M12*Matrix2D_b.M21; 
 r.M12=Matrix2D_a.M11*Matrix2D_b.M12+Matrix2D_a.M12*Matrix2D_b.M22; 
 r.M21=Matrix2D_a.M21*Matrix2D_b.M11+Matrix2D_a.M22*Matrix2D_b.M21; 
 r.M22=Matrix2D_a.M21*Matrix2D_b.M12+Matrix2D_a.M22*Matrix2D_b.M22; 
 return r; 
} 


var ms=new MatrixFilter(s); 
var mm=new MatrixFilter(m); 
var mh=new MatrixFilter(h); 
var i=1; 
setInterval("ms.RotateToAt((new Date()).getSeconds()*6+6,69,69)",500); 
setInterval("mm.RotateToAt((new Date()).getMinutes()*6+6,69,69)",500); 
setInterval("mh.RotateToAt(((new Date()).getHours()+(new Date()).getMinutes()/60)*30,69,69)",500); 
//mf.MoveTo(30,70); 
//mf.ZoomBy(1.5,1.5); 
//mf.ZoomBy(1.5,1.5); 
//alert(mf.toMatrix2D()); 

//alert(Matrix2D.Mul(m2d1,m2d2)); 
//fnSetRotation(oDiv.filters.item(0),30); 
 
 

纯js代码制作的网页时钟,需要的码农可以拿去看一下。

文档

纯js代码制作的网页时钟

纯js代码制作的网页时钟: //oObj input requires that a matrix filter be applied. //deg input defines the requested angle of rotation. var deg2radians = Math.PI * 2 / 360; function MatrixFilter(obj) { if(!obj.filters)return; //alert(obj.filters.item
推荐度:
标签: 制作 js 代码
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top