Javascript examples for Canvas:Text
position text on canvas
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script src="name.js"></script> <meta charset="ISO-8859-1"> <title>Animate my name</title> </head> <body> <canvas id="myCanvas" width="400" height="400"></canvas> <script> $(document).ready(function(){ var canvas = $("#myCanvas")[0]; canvas.width = window.innerWidth; canvas.height = window.innerHeight; var width_ = canvas.width/2; var ctx = canvas.getContext("2d"); ctx.beginPath();/*from w w w . ja va2 s .c om*/ ctx.font = "60px Comic"; ctx.textAlign='center'; ctx.fillText("sanjana", width_, 100);//why with width text is not visible }); </script> </body> </html>