Showing posts with label HTML5. Show all posts
Showing posts with label HTML5. Show all posts

Tuesday, June 25, 2013

HTML5 Canvas Text


To create text with HTML5 Canvas, we can use the fillText() method

<!DOCTYPE HTML>
<html>
<head>
<script>

function init() {
      var canvas=document.getElementById("Canvastext");
      var context=canvas.getContext("2d");

      var x = 250;
      var y = 200;
      context.fillText("Hello HTML5!", x, y);
}

</script>
</head>
<body onload="init()">
      <canvas id=" Canvastext " width="578" height="200"></canvas>
</body>
</html>