Skip to main content

HTML5 canvas arc example

Here is the code :

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>just testing</title>
<script src="js/jqery2.js"></script>
<script type="text/javascript">
$(document).ready(function() {

});
</script>
</head>

<body>

  <canvas id="myCanvas" width="578" height="250"></canvas>
    <script>
      var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');
      var x = canvas.width / 2;
      var y = canvas.height / 2;
      var radius = 75;
      var startAngle = 1.1 * Math.PI;
      var endAngle = 1.9 * Math.PI;
      var counterClockwise = false;

      context.beginPath();
      context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
      context.lineWidth = 15;

      // line color
      context.strokeStyle = 'black';
      context.stroke();
    </script>
   
</body>
</html>






Comments