HTML5 Game - Canvas Rendering Text

Description

Rendering Text

Demo

ResultView the demo in separate window

<!DOCTYPE html>
   <head>
      <style> 
         body {/*w w  w.  j  a  va  2 s .co  m*/
            background: #dddddd;
         }

         #canvas {
            position: absolute;
            left: 0px;
            top: 0px;
            margin: 20px;
            background: #ffffff;
            border: thin solid #aaaaaa;
         }
      </style>
   </head>

  <body>
    <canvas id='canvas' width='500' height='500'>
      Canvas not supported
    </canvas>

    <script>
let context = document.querySelector('#canvas').getContext('2d');

context.font = "34px Arial"; 
context.fillText("2D Drawing", 110, 100); 

       </script> 

      </script>
  </body>
</html>

Related Topic