Advertisement
lemansky

Untitled

Dec 13th, 2020
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.22 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Document</title>
  6.     <script type="text/javascript">
  7.     document.addEventListener("DOMContentLoaded", function(){
  8.         let canvas = document.getElementById('canvasId');
  9.         let canvasId = canvas.getContext("2d");  
  10.         let x = 400, y = 50, r = 20;
  11.  
  12.        
  13.  
  14.         for (let j = 0; j < 4; j++) {
  15.            for (let i = 1; i <= 5; i++) {
  16.                canvasId.beginPath();
  17.                canvasId.fillStyle = 'white';
  18.                canvasId.arc(x + i*50, y + i*50, r, 0, Math.PI*2);
  19.                canvasId.fill();
  20.                canvasId.closePath();
  21.            }
  22.            console.log(x + " " + y);
  23.            canvasId.translate(400, 300);
  24.            canvasId.rotate(90 * Math.PI / 180);
  25.            canvasId.translate(-400, -300);
  26.        }
  27.        
  28.        canvasId.beginPath();
  29.        canvasId.fillStyle = 'red';
  30.        canvasId.arc(x, y, r, 0, Math.PI*2);
  31.        canvasId.fill();
  32.        canvasId.closePath();
  33.        
  34.    });
  35.  
  36. </script>
  37. <style>
  38.     canvas{
  39.         background-color: black;
  40.     }
  41. </style>
  42. </head>
  43. <body>
  44.   <canvas width="800" height="800" id="canvasId"></canvas>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement