Guest User

Untitled

a guest
Jan 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  5. <title>shapes</title>
  6. <script type="text/javascript" charset="utf-8">
  7. function shapes(){
  8.  
  9. // Get the canvas element
  10. var canvas = document.getElementById('canvas');
  11. // Set the context
  12. var canvas = canvas.getContext('2d');
  13.  
  14. // triangle
  15. // beginPath();
  16. canvas.beginPath();
  17. // moveTo(x,y);
  18. canvas.moveTo(25,25);
  19. // lineTo(x,y);
  20. canvas.lineTo(125,25);
  21. canvas.lineTo(25,125);
  22.  
  23. // square
  24. // fillRect(x,y width, height)
  25. canvas.fillRect(200, 25, 100, 100);
  26.  
  27. // rectangle
  28. canvas.fillRect(400, 25, 100, 150);
  29.  
  30. // circle
  31. // arc(x,y,radius, startAngle, engAngle, anticlickwise)
  32. canvas.moveTo(650, 100);
  33. canvas.arc(600, 100, 50, 0, Math.PI*2, true);
  34.  
  35. // By default closed paths are filled
  36. canvas.fill();
  37.  
  38.  
  39. }
  40. </script>
  41. </head>
  42. <body id="shapes" onload="shapes();">
  43. <canvas id="canvas" width="800" height="800"></canvas>
  44. </body>
  45. </html>
Add Comment
Please, Sign In to add comment