Guest User

Untitled

a guest
Oct 16th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.17 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2.    
  3. <html lang="en">
  4. <head>
  5.     <title><!-- Insert your title here --></title>
  6.    
  7.     <link rel="stylesheet" href="style.css" type="text/css" />
  8.    
  9. <script>
  10.    
  11. function draw() {
  12.     var c = document.getElementById('canvas').getContext('2d');
  13.    
  14.     for(var j=0;j<6;j++) {
  15.        setTimeout(function(){squares(c)}, 100);
  16.        //squares(c);
  17.    }
  18. }
  19.  
  20. function squares(c)
  21. {
  22.            
  23.        for(var i=0; i<30; i++)
  24.        {
  25.            var randX = Math.floor(Math.random() *250);
  26.            var randY = Math.floor(Math.random() * 250);
  27.           // c.fillStyle ='rgb(0,' + Math.floor(255-42.5*i) + ',' + Math.floor(255-42.5*i) + ')';
  28.            c.fillStyle = 'rgb(' + (Math.floor(Math.random() * 255)) + ',' + (Math.floor(Math.random() * 255))  + ',' + (Math.floor(Math.random() * 255))  + ')';
  29.            //c.fillStyle = 'red';
  30.            c.fillRect(randX, randY, 10, 10);
  31.        }
  32. }
  33.  
  34. </script>
  35. </head>
  36. <body>
  37.     <!-- Insert your content here -->
  38.    
  39.     <canvas id="canvas" width="250" height="250"></canvas>
  40.  
  41.            
  42.         <input type='submit' value=' canvas me' onclick='draw()'>
  43.       </div>
  44. </body>
  45. </html>
Add Comment
Please, Sign In to add comment