HTML5 Canvas distorted

HTMLJavascriptProgramming Scripts

If the canvas looks distorted, then try to change the height and width −

<canvas id = ”canvas1” width = '400' height = '300'></canvas>

The default height and width of the canvas in HTML5 is of 2/1 ratio −

width = 300
height = 150

Example

Let us see an example −

<!DOCTYPE HTML>
<html>
   <head>
      <style>
         #mycanvas{border:1px solid red;}
      </style>
   </head>
   <body>
      <canvas id = "mycanvas" width = "100" height = "100"></canvas>
   </body>
</html>
raja
Published on 06-Apr-2018 08:02:54
Advertisements