Advertisement
Guest User

Untitled

a guest
Jul 31st, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.91 KB | None | 0 0
  1. <HTML>
  2.   <BODY STYLE="padding:0; margin:0; background-color:#000">
  3.   <CANVAS ID="myCanvas" WIDTH="1920" HEIGHT="1080" STYLE="margin:0; padding:0; width:100%; height:100%;"></CANVAS>
  4.  
  5.   <SCRIPT>
  6.     var c = document.getElementById("myCanvas");
  7.     c.width = window.innerWidth;
  8.     c.height = window.innerHeight;
  9.  
  10.     var ctx = c.getContext("2d");
  11.     ctx.fillStyle = "#F00";
  12.     ctx.fillRect(0,0,c.width,c.height);
  13.     var ctxCopy= ctx.getImageData(0,0,c.width,c.height);
  14.  
  15.     var start = new Date();
  16.     var end = new Date('2016-08-30');
  17.     var diff = end - start;
  18.  
  19.     var prog = 0, oldProg = 0, progRows = 0, oldProgRows = 0;
  20.  
  21.  
  22.     var timer = setInterval("updateGraph()", 1000);
  23.  
  24.     function updateGraph(){
  25.       c.width = window.innerWidth;
  26.       c.height = window.innerHeight;
  27.  
  28.       var now = new Date();
  29.  
  30.       if (now >= end){
  31.         ctx.fillStyle = "#0F0";
  32.         ctx.fillRect(0,0,c.width,c.height);
  33.       }
  34.  
  35.       else if(end < start || now < start){
  36.        ctx.fillStyle = "#F00";
  37.        ctx.fillRect(0,0,c.width,c.height);
  38.      }
  39.  
  40.      else {
  41.        oldProg = prog;
  42.        oldProgRows = progRows;
  43.  
  44.        prog = (c.width * c.height * (now - start)) / diff;
  45.        progRows = Math.floor(prog / c.width);
  46.  
  47.        ctxCopy= ctx.getImageData(0,0,c.width,c.height);
  48.  
  49.        ctx.fillStyle = "#F00";
  50.        ctx.fillRect(0, 0, c.width, c.height);
  51.  
  52.        ctx.fillStyle = "#00F";
  53.        ctx.fillRect(0, 0, c.width, progRows);
  54.        ctx.fillRect(0, progRows, (prog - (progRows * c.width)), 1);
  55.  
  56.        ctx.fillStyle = "#0F0";
  57.        ctx.fillRect(0, 0, c.width, oldProgRows);
  58.        ctx.fillRect(0, oldProgRows, (oldProg - (oldProgRows * c.width)), 1);
  59.  
  60.        setTimeout(function(){
  61.          ctx.fillRect(0, 0, c.width, progRows);
  62.          ctx.fillRect(0, progRows, (prog - (progRows * c.width)), 1);
  63.        }, 500);
  64.      }
  65.    }
  66.  
  67.  </SCRIPT>
  68.  
  69.   </BODY>
  70. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement