SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 93 in 1 day
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>js</title>
  6.     <style type="text/css">
  7.   #canvasId{
  8.     background: black;
  9.   }
  10. </style>
  11. </head>
  12. <body>
  13.    
  14.  
  15.     <script type="text/javascript">
  16.                
  17.        var $height =0 ;
  18.  
  19.  
  20.      document.addEventListener("DOMContentLoaded", function(){
  21.       var canvas = document.getElementById('canvasId');
  22.       var context = canvas.getContext("2d");
  23.        
  24.  
  25.  
  26.        for(var i = 0; i<10; i++){
  27.  
  28.        
  29.  
  30.         var $color = "rgb(" +
  31.         Math.floor((Math.random()*185)+70) + ", " +
  32.         Math.floor((Math.random()*185)+70)+ ", " +
  33.         Math.floor((Math.random()*185)+70)+ ")";
  34.  
  35.         var $x = Math.floor((Math.random()*701)+0) ;
  36.  
  37.         var $y = Math.floor((Math.random()*501)+0) ;
  38.  
  39.         var $shape = Math.floor((Math.random()*2)+1);
  40.  
  41.         var $radius =   Math.floor((Math.random()*51)+50);
  42.         var $width = Math.floor((Math.random()*51)+50);
  43.  
  44.         context.fillStyle = $color;
  45.        
  46.        if($shape%2==0){
  47.  
  48.         context.beginPath();
  49.         context.arc($x, $y, $radius, 0, Math.PI*2);
  50.         context.fill();
  51.              }
  52.  
  53.              else{
  54.                   context.fillRect($x, $y, $radius, $width);
  55.                  }
  56.     }
  57.  
  58.            
  59.        
  60.  
  61.             });
  62.     </script>
  63.  
  64.  
  65.      <canvas id="canvasId" class="d-block" width="700" height="600"></canvas>
  66. </body>
  67. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top