How to use Canvas Arc in HTML5

In this article I am going to explain about Canvas Arc in Html5.
  • 2520

Canvas Arc in Html5

Canvas Arc is an canvas tool. That is mainly use for user interface. For its use Arc() method that defined center point, radius, starting point, ending point, and drowning direction of an element.  We defined this properties within style tad in Html document with canvas.

Syntax

<script>

    contextname.arc(x, y, radius, SAngle, EAngle, direction);

</script>

Example

<html>

  <head>

    <style>

      body {

        margin: 0px;

        padding: 0px;

      }

       </style>

    <script>

        window.onload = function () {

            var mycnv = document.getElementById("mymycnv");

            var cntx = mycnv.getcntx("2d");

            var x = mycnv.width / 2;

            var y = mycnv.height / 2;

            var radius = 75;

            var strAgl = 1.1 * Math.PI;

            var EdnAgl = 1.9 * Math.PI;

            var colckwise = false;

 

            cntx.beginPath();

            cntx.arc(x, y, radius, strAgl, EdnAgl, colckwise);

            cntx.lineWidth = 15;

            // line color

            cntx.strokeStyle = "black";

            cntx.stroke();

        };

 

    </script>

  </head>

  <body>

    <canvas id="mymycnv" width="578" height="250"></canvas>

  </body>

</html>

Output

arc.jpg

Further Readings

You may also want to read these related articles: here

Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

 

© 2019 DotNetHeaven. All rights reserved.