Drawing a Circle on Canvas - Javascript Canvas

Javascript examples for Canvas:Circle

Description

Drawing a Circle on Canvas

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
 <head> 
  <meta charset="UTF-8"> 
  <title>Drawing a Circle on Canvas</title> 
  <style type="text/css">
  canvas{//  w w  w .j a va2 s  .com
    border: 1px solid #000;
  }
</style> 
  <script type="text/javascript">
    window.onload = function(){
        var canvas = document.getElementById("myCanvas");
        var context = canvas.getContext("2d");
        context.arc(150, 100, 70, 0, 2 * Math.PI, false);
        context.stroke();
    };
</script> 
 </head> 
 <body> 
  <canvas id="myCanvas" width="300" height="200"></canvas>   
 </body>
</html>

Related Tutorials