Advertisement
lemansky

Untitled

Dec 13th, 2021
1,018
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.79 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", () => {
  8.         let canvas = document.getElementById('canvasId');
  9.         let context = canvas.getContext("2d");  
  10.         let x = 400, y = 50;
  11.  
  12.         context.fillStyle = 'red';
  13.         context.beginPath();
  14.         context.arc(x, y, 20, 0, 2*Math.PI);
  15.         context.closePath();
  16.         context.fill();
  17.  
  18.         for (var i = 0; i < 5; i++) {
  19.            x += 50;
  20.            y += 50;
  21.            context.fillStyle = 'white';
  22.            context.beginPath();
  23.            context.arc(x, y, 20, 0, 2*Math.PI);
  24.            context.closePath();
  25.            context.fill();
  26.        }
  27.  
  28.        for (var i = 0; i < 5; i++) {
  29.            x -= 50;
  30.            y += 50;
  31.            context.fillStyle = 'white';
  32.            context.beginPath();
  33.            context.arc(x, y, 20, 0, 2*Math.PI);
  34.            context.closePath();
  35.            context.fill();
  36.        }
  37.  
  38.        for (var i = 0; i < 5; i++) {
  39.            x -= 50;
  40.            y -= 50;
  41.            context.fillStyle = 'white';
  42.            context.beginPath();
  43.            context.arc(x, y, 20, 0, 2*Math.PI);
  44.            context.closePath();
  45.            context.fill();
  46.        }
  47.  
  48.        for (var i = 0; i < 4; i++) {
  49.            x += 50;
  50.            y -= 50;
  51.            context.fillStyle = 'white';
  52.            context.beginPath();
  53.            context.arc(x, y, 20, 0, 2*Math.PI);
  54.            context.closePath();
  55.            context.fill();
  56.        }
  57.  
  58.    });
  59.  
  60. </script>
  61. <style>
  62.     canvas{
  63.         background-color: black;
  64.     }
  65. </style>
  66. </head>
  67. <body>
  68.   <canvas width="800" height="800" id="canvasId"></canvas>
  69. </body>
  70. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement