HTML5 Canvas Degree Symbol

JavascriptWeb DevelopmentFront End Scripts

For HTML5 Canvas degree symbol, try to run the following code −

<!DOCTYPE html>
<html>
   <head>
      <meta charset="utf-8">
      <style media="screen">
         body {
            margin:5em;
            background:#eee;
            text-align:center
         }
         canvas {
            background:#fff;
            border:2px solid #ccc;
            display:block;
            margin:3em auto
         }
      </style>
   </head>
   <body>
      <script charset="utf-8">
         var c = document.getElementsByTagName('canvas')[0];
         c.width = c.height = 300;
         var context = c.getContext('2d');
         context.font = "20px sans-serif";
         context.fillText("212° Fahrenheit", 100, 100);
      </script>
   </body>
</html>
raja
Published on 06-Apr-2018 14:02:14
Advertisements