HTML5 Game - Canvas Display Message

Description

Display Message

Demo

ResultView the demo in separate window

<!DOCTYPE html>
   <head>
      <style> 
         body {/*from   w w w . j  av a 2 s  . com*/
            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');

let msg2 = "from java2s.com"; 
context.font = "24px Arial"; 
context.fillText(msg2, canvas.width / 2, 330); 
context.strokeText(msg2, canvas.width / 2, 330); 




       </script> 

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

Related Topic