Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(){
- var ctx = document.createElement('canvas');
- document.body.appendChild(ctx);
- ctx.width='300';
- ctx.height='170';
- ctx.style.background='none';
- ctx.style.position = 'fixed';
- ctx.style.top = '100px';
- ctx.style.left = '100px';
- ctx = ctx.getContext('2d');
- var b = function(n){
- var m = 1<<3;
- var br = [];
- while(m){
- br.push(n&m);
- m>>=1;
- }
- return br;
- };
- var d = function(n, x, y, w){
- var br = b(n);
- for(var i = 0; i < br.length; i++){
- if(br[i])
- ctx.fillStyle='#5ED1FF';
- else
- ctx.fillStyle='#006E99';
- ctx.lineWidth=2;
- ctx.strokeStyle='#24576B';
- var r = (w/2)-4;
- ctx.beginPath();
- ctx.arc(x,y,r,0,2*Math.PI,false);
- ctx.closePath();
- ctx.fill();
- ctx.stroke();
- ctx.lineWidth = 0;
- y+=w;
- }
- };
- var d1 = function(n,x,y,w,p){
- var n1=n/10,n2=n%10;
- d(n1,x,y,w);
- d(n2,x+w+p,y,w);
- };
- var i=4;
- var t = function(){
- ctx.clearRect(0,0,300,170);
- var dt = new Date();
- d1(dt.getHours(), 20, 25, 30,10);
- d1(dt.getMinutes(),125, 25,30,10);
- d1(dt.getSeconds(),230, 25, 30, 10);
- ctx.fillStyle='#006E99';
- ctx.fillRect(0,137,300,17);
- ctx.fillStyle='#5ED1FF';
- ctx.font = '10px sans-serif';
- i=i?i:4;
- ctx.fillText(i>1?dt.toString():'Hello Petar!',10,150);
- i--;
- setTimeout(t, 1000);
- };
- t();
- })();
Add Comment
Please, Sign In to add comment