Guest User

Untitled

a guest
Jun 25th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(){
  2.             var ctx = document.createElement('canvas');
  3.             document.body.appendChild(ctx);
  4.             ctx.width='300';
  5.             ctx.height='170';
  6.             ctx.style.background='none';
  7.             ctx.style.position = 'fixed';
  8.             ctx.style.top = '100px';
  9.             ctx.style.left = '100px';
  10.             ctx = ctx.getContext('2d');
  11.            
  12.             var b = function(n){
  13.                 var m = 1<<3;
  14.                 var br = [];
  15.                 while(m){
  16.                     br.push(n&m);
  17.                     m>>=1;
  18.                 }
  19.                 return br;
  20.             };
  21.            
  22.             var d = function(n, x, y, w){
  23.                
  24.                 var br = b(n);
  25.                 for(var i = 0; i < br.length; i++){
  26.                     if(br[i])
  27.                         ctx.fillStyle='#5ED1FF';
  28.                     else
  29.                         ctx.fillStyle='#006E99';
  30.                     ctx.lineWidth=2;
  31.                     ctx.strokeStyle='#24576B';
  32.                     var r = (w/2)-4;
  33.                     ctx.beginPath();
  34.                     ctx.arc(x,y,r,0,2*Math.PI,false);
  35.                     ctx.closePath();
  36.                     ctx.fill();
  37.                     ctx.stroke();
  38.                     ctx.lineWidth = 0;
  39.                     y+=w;
  40.                 }
  41.                
  42.             };
  43.             var d1 = function(n,x,y,w,p){
  44.                 var n1=n/10,n2=n%10;
  45.                 d(n1,x,y,w);
  46.                 d(n2,x+w+p,y,w);
  47.             };
  48.             var i=4;
  49.             var t = function(){
  50.                 ctx.clearRect(0,0,300,170);
  51.                 var dt = new Date();
  52.                 d1(dt.getHours(), 20, 25, 30,10);
  53.                
  54.                 d1(dt.getMinutes(),125, 25,30,10);
  55.                
  56.                 d1(dt.getSeconds(),230, 25, 30, 10);
  57.                 ctx.fillStyle='#006E99';
  58.                 ctx.fillRect(0,137,300,17);
  59.                 ctx.fillStyle='#5ED1FF';
  60.                 ctx.font = '10px sans-serif';
  61.                 i=i?i:4;
  62.                 ctx.fillText(i>1?dt.toString():'Hello Petar!',10,150);
  63.                 i--;
  64.                 setTimeout(t, 1000);
  65.             };
  66.             t();
  67.         })();
Add Comment
Please, Sign In to add comment