HTML5 Game - Compare the textBaseline and textAlign

Description

Compare the textBaseline and textAlign

Demo

ResultView the demo in separate window

<!DOCTYPE html>
   <head>
      <style> 
         body {/*  w  w  w.  j ava2s . c o  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='1500' height='1500'>
      Canvas not supported
    </canvas>

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

     context.textBaseline = "top"; 
     context.fillText("( 0 , 0 )", 80, 50); 

      context.textAlign = "right"; 
      context.textBaseline = "bottom"; 
      context.fillText("( 500 , 375 )", 80, 50); 
       </script> 

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

Related Topic