Advertisement
avr39ripe

canvasIntro

May 26th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2.  
  3. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5.     <meta charset="utf-8" />
  6.     <title></title>
  7.     <style>
  8.         canvas {
  9.             /*border: 1px solid black;*/
  10.         }
  11.     </style>
  12. </head>
  13. <body>
  14.     <canvas id="draw" width="640" height="480">
  15.     </canvas>
  16.     <script>
  17.         let canvas = document.getElementById('draw');
  18.         let ctx = canvas.getContext('2d');
  19.         let width = 640;
  20.         let height = 480;
  21.         let size = 200;
  22.  
  23.         /*
  24.         ctx.fillRect((width / 2 ) - ( size / 2), (height / 2 ) - ( size / 2), size, size);
  25.         ctx.fillStyle = 'blue';
  26.         ctx.fillRect((width / 2 ) - ( size / 2 /2), (height / 2 ) - ( size / 2 / 2), size/2, size/2);
  27.         //ctx.fillStyle = 'rgb(0,150,0)';
  28.         //ctx.fillRect(90,90,150,150);
  29.         //ctx.fillStyle = 'rgba(150,0,0,0.5)';
  30.         //ctx.clearRect(50,50,150,150);
  31.         */
  32.  
  33.         let radius = 150;
  34.         ctx.beginPath();
  35.         ctx.moveTo((width / 2 ) + radius, (height / 2 ));
  36.         // Math.PI / 180 * deg
  37.         ctx.arc((width / 2 ), (height / 2 ), radius, 0, 2 * Math.PI );
  38.         //ctx.fill();
  39.         ctx.strokeStyle = 'red';
  40.         ctx.stroke();
  41.  
  42.  
  43.         //ctx.lineTo((width / 2 ) + size,(height / 2 ) + size);
  44.         //ctx.lineTo(0,0);
  45.         //ctx.lineTo(size,0);
  46.         //ctx.stroke();
  47.         //ctx.fillStyle = 'rgba(0,200,0,0.5)';
  48.         //ctx.fill();
  49.         //ctx.closePath();
  50.        
  51.  
  52.     </script>
  53.  
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement