我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

canvas如何实现十二星座星空图

这篇文章将为大家详细讲解有关canvas如何实现十二星座星空图,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

成都创新互联公司-专业网站定制、快速模板网站建设、高性价比向阳网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式向阳网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖向阳地区。费用合理售后完善,10多年实体公司更值得信赖。

效果如下:

canvas如何实现十二星座星空图

代码如下:




 
 canvas星座
 



 

请选择您的出生日期

 
 你的浏览器不支持canvas  var box=document.getElementById('box');  var birth=document.getElementById('birth');  var btn=document.getElementById('btn');  var canvas=document.getElementById("canvas");  var ctx=canvas.getContext("2d");  var g1,date,timer;  ctx.font = "30px Courier New";  /*星座位置*/  var star={  "白羊座":[   [[0.30,0.78],[0.34,0.66],[0.28,0.48],[0.60,0.26],[0.65,0.20],[0.71,0.23],[0.70,0.32],[0.72,0.36]],   [ [0,1,2,3,4,5],[3,6,7]]  ],  "天秤座":[   [[0.16,0.67],[0.34,0.60],[0.60,0.27],[0.75,0.23],[0.84,0.47],[0.63,0.74],[0.51,0.78]],   [[0,1,2,3,4,5,6]]  ],  "摩羯座":[   [[0.78,0.21],[0.78,0.34],[0.75,0.45],[0.75,0.70],[0.69,0.78],[0.31,0.66],[0.22,0.49],[0.30,0.53],[0.53,0.54]],   [[0,1,2,3,4,5,6,7,8,1]]  ],  "水瓶座":[   [[0.45,0.21],[0.37,0.35],[0.27,0.51],[0.30,0.58],[0.29,0.64],[0.48,0.79],[0.51,0.71],[0.58,0.68],[0.73,0.74],[0.43,0.53],[0.53,0.47]],   [[0,1,2,3,4,5,6,7,8],[2,9,10]]  ],  "双鱼座":[   [[0.28,0.43],[0.28,0.53],[0.36,0.73],[0.43,0.78],[0.50,0.70],[0.53,0.62],[0.57,0.58],[0.63,0.43],[0.67,0.39],[0.74,0.39],[0.77,0.34],[0.72,0.30],[0.75,0.22],[0.23,0.50],[0.66,0.33]],   [[0,1,2,3,4,5,6,7,8,9,10,11,12],[0,13,1],[8,14,11]]  ],  "金牛座":[   [[0.29,0.21],[0.39,0.36],[0.50,0.51],[0.50,0.57],[0.61,0.63],[0.77,0.71],[0.79,0.79],[0.22,0.43],[0.39,0.57],[0.60,0.71],[0.67,0.76]],   [[0,1,2,3,4,5,6],[7,8,3],[4,9,10]]  ],  "双子座":[   [[0.18,0.37],[0.25,0.45],[0.35,0.55],[0.39,0.68],[0.49,0.77],[0.51,0.63],[0.57,0.78],[0.28,0.29],[0.42,0.32],[0.61,0.49],[0.72,0.60],[0.83,0.59],[0.69,0.75],[0.22,0.54],[0.35,0.43],[0.48,0.21]],  [[0,1,2,3,4],[2,5,6],[7,8,9,10,11],[9,12],[13,1,14,8,15]]  ],  "巨蟹座":[   [ [0.16,0.39],[0.27,0.36],[0.52,0.49],[0.57,0.65],[0.83,0.78],[0.44,0.21]],   [[0,1,2,3,4],[2,5]]  ],  "狮子座":[   [   [0.16,0.75],[0.23,0.67],[0.39,0.77],[0.71,0.53],[0.64,0.39],[0.55,0.37],[0.47,0.27],[0.54,0.24],[0.60,0.27],[0.85,0.56]],   [[0,1,2,3,4,5,6,7,8],[3,9]]  ],  "处女座":[   [[0.16,0.59],[0.35,0.63],[0.44,0.70],[0.62,0.51],[0.77,0.46],[0.84,0.37],[0.60,0.42],[0.65,0.26],[0.34,0.75]],   [[0,1,2,3,4,5],[3,6,7],[2,8]]  ],  "天蝎座":[   [[0.17,0.50],[0.28,0.63],[0.19,0.70],[0.28,0.78],[0.41,0.77],[0.49,0.72],[0.57,0.55],[0.59,0.44],[0.69,0.31],[0.74,0.21],[0.82,0.29],[0.79,0.44],[0.73,0.50],[0.38,0.47]],   [[0,1,2,3,4,5,6,7,8,9,10,11,12],[1,13],[8,11]]  ],  "射手座":[   [[0.22, 0.66],[0.24,0.51],[0.45,0.40],[0.54,0.37],[0.59,0.43],[0.66,0.50],[0.63,0.60],[0.66,0.67],[0.74,0.53],[0.77,0.39],[0.49,0.47],[0.29,0.68],[0.30,0.78],[0.48,0.21],[0.52,0.27],[0.59,0.29]],   [[0,1,2,3,4,5,6,7,8,9],[2,10,11,12],[10,4],[13,14,15,3],[14,3]]  ]  };  /*根据出生日期获取星座信息*/  function getStarSign(ts){  var d=new Date(ts),sign=d.getMonth()*100+d.getDate();  switch(true)  {   case sign<20:   return "摩羯座";   case sign<119:   return "水瓶座";   case sign<221:   return "双鱼座";   case sign<320:   return "白羊座";   case sign<421:   return "金牛座";   case sign<522:   return "双子座";   case sign<623:   return "巨蟹座";   case sign<723:   return "狮子座";   case sign<823:   return "处女座";   case sign<923:   return "天秤座";   case sign<1022:   return "天蝎座";   case sign<1122:   return "射手座";   default:   return "摩羯座";  }  }  /*绘制星座*/  function constellation(ctx,ary,w,h){  /*创建线条*/  var points=ary[0], lines=ary[1];  ctx.strokeStyle="#FFF";  var len=lines.length,i,ii,line,point;  ctx.beginPath();  while(len--)  {   i=1;   line=lines[len];   ii=line.length;   point=points[line[0]];   ctx.moveTo(point[0]*w,point[1]*h);   for(;i

关于“canvas如何实现十二星座星空图”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。


网站题目:canvas如何实现十二星座星空图
标题来源:http://mswzjz.cn/article/ihhcii.html

其他资讯