Facebook
From Buff Lechwe, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 114
  1. <!doctype html>
  2. <html>
  3. <head>
  4.     <title>2D Context</title>
  5.     <script>
  6.         window.onload = setup2d;
  7.  
  8.         function setup2d()
  9.         {
  10.             const canvas = document.getElementById("my-canvas");
  11.                 const context = canvas.getContext('2d');
  12.                 context.fillStyle = "rgb(200,0,0)";
  13.                 context.fillRect (10, 10, 100, 100);
  14.                 context.fillStyle = "rgb(0,200,0)";
  15.                 context.fillRect (20, 20, 100, 100);
  16.                 context.fillStyle = "rgb(0,0,200)";
  17.                 context.fillRect (30, 30, 100, 100);
  18.         }
  19.     </script>
  20. </head>
  21. <body>
  22. <canvas id="my-canvas" width="150" height="150">
  23. </canvas>
  24. <p>22</p>
  25. <p>J4334</p>
  26. </body>
  27. </html>