tb.js 2.2 KB

1
  1. function initTb(a,d,h,k){var b=document.getElementById(a);a=b.getContext("2d");b.width=510;b.height=510;var e=b.width,f=b.height,c=b.parentNode;c.style.width="170px";c.style.height="170px";b.style.transform=b.style["-webkit-transform"]=b.style["-moz-transform"]="scale("+1/3+") translate(-510px,-510px)";c=b=0;0==d&&(d=.5);clearInterval(void 0);var c=c+1,g=parseInt(d/100*360);b==g&&clearInterval(void 0);b!=g&&(b<c?b++:b--,b=g,a.clearRect(0,0,e,f),a.beginPath(),a.strokeStyle="#cce9e2",a.lineJoin="round",a.lineWidth=12,a.arc(e/2,f/2,150,0,2*Math.PI,!1),a.stroke(),a.beginPath(),b=b*Math.PI/180,a.beginPath(),a.strokeStyle="#00bc8c",a.lineWidth=24,a.arc(e/2,f/2,150,0-90*Math.PI/180,b-90*Math.PI/180,!1),.5<d&&a.stroke(),a.fillStyle="#00bc8c",a.font='54px "Lantinghei SC","Microsoft Yahei","Hiragino Sans GB","Helvetica Neue",Helvetica,Arial,sans-serif',text_width=a.measureText(h).width,a.fillText(h,e/2-text_width/2,f/2+30),a.font='48px "Lantinghei SC","Microsoft Yahei","Hiragino Sans GB","Helvetica Neue",Helvetica,Arial,sans-serif',text_width=a.measureText(k).width,a.fillText(k,e/2-text_width/2,f/2+240))}function initTbOrange(a,d,h,k){var b=document.getElementById(a);a=b.getContext("2d");b.width=510;b.height=510;var e=b.width,f=b.height,c=b.parentNode;c.style.width="170px";c.style.height="170px";b.style.transform=b.style["-webkit-transform"]=b.style["-moz-transform"]="scale("+1/3+") translate(-510px,-510px)";var g=c=0,b=50<=d?"#00bc8c":"#ff6938";clearInterval(void 0);g+=1;d=parseInt(d/100*360);c==d&&clearInterval(void 0);c!=d&&(c<g?c++:c--,c=d,a.clearRect(0,0,e,f),a.beginPath(),a.strokeStyle="#cce9e2",a.lineJoin=a.lineCap="round",a.lineWidth=12,a.arc(e/2,f/2,150,0,2*Math.PI,!1),a.stroke(),a.beginPath(),d=c*Math.PI/180,a.beginPath(),a.strokeStyle=b,a.lineWidth=24,a.arc(e/2,f/2,150,0-90*Math.PI/180,d-90*Math.PI/180,!1),a.stroke(),a.fillStyle="#00bc8c",a.font='54px "Lantinghei SC","Microsoft Yahei","Hiragino Sans GB","Helvetica Neue",Helvetica,Arial,sans-serif',text_width=a.measureText(h).width,a.fillText(h,e/2-text_width/2,f/2+30),a.font='48px "Lantinghei SC","Microsoft Yahei","Hiragino Sans GB","Helvetica Neue",Helvetica,Arial,sans-serif',a.fillStyle="#b8542e",text_width=a.measureText(k).width,a.fillText(k,e/2-text_width/2,f/2+240))};