Canvas Draw text inside a circle in Javascript


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){
        var canvas1 = document.getElementById("canvas");
        var context = canvas1.getContext("2d");
        context.beginPath();
        context.fillStyle = "blue";
        context.strokeStyle = "black";
        context.font = "20px Georgia";
        context.lineWidth = 10;
        context.arc(100, 100, 75, 0, 2 * Math.PI, false);
        context.fill();
        context.beginPath();
        context.fillStyle = "red";
        context.fillText("Hello World!", 40, 100);
        context.fill();
}); 
</script>
</head>
<body>
  <canvas id="canvas" width=300 height=300></canvas>
</body>
</html>

Comments

Popular posts from this blog

Shutdown Computer With Funny Reason

Hidden Attribute in javascript

Draw animated loading spinner canvas in Javascript