Before moving further, read the following articles:
- Overview of Scalable Vector Graphics (SVG)
- Scalable Vector Graphics - Rectangle
- Scalable Vector Graphics - Circle
- Scalable Vector Graphics - Ellipse
- Scalable Vector Graphics - Line
- Scalable Vector Graphics - Polyline
- Scalable Vector Graphics - Polygon
- Scalable Vector Graphics - Path 1
Now let's proceed to learn another part of SVG Path, arc.
SVG Path - Arc
All paths are always drawn from the last virtual point to the new start point since each drawing command takes an end point. After executing the command, the virtual point will be located at the end point of that path and hence the next path will start from that point only.
So for drawing arcs, the A or a command is used with the <path> tag and it also includes absolute and relative coordinates depending on the uppercase and lowercase commands respectively.
Let's see a few examples to understand it properly.
Example 1
Absolute positioning.
- <html>
- <body>
- <svg height="300" width="700">
- <path d="M50,50 A60,60 0 0,1 130,130" style="stroke:blue; stroke-width:3; fill:none;" />
- <path d="M250,150 A90,150 0 0,1 150,50" style="stroke:red; stroke-width:3; fill:none;" />
- </svg>
- </body>
- </html>

In the preceding example, coordinates (50, 50) and (150, 150) are the starting and ending points of a circular arc respectively. And (250, 150) and (150, 50) are the starting and ending points of the elliptical arc respectively.
The first two parameters, rx=90 and ry=150, are used to set the radius of the arc in the x (rx) and y (ry) direction respectively. If a value of rx is equal to ry, then it results in a circular arc as we can see for the Blue circular arc. And if the value of rx and ry are different then the result ia an ellipse.
The third parameter rotates the arc in the x-axis direction. Usually its value is set to 0 and you do not need to change it.
The fourth and fifth parameters are “large – arc – flag” and “sweep – flag” respectively.
The “large – arc – flag” determines whether the arc drawn is to be smaller or larger to satisfy the starting point and ending point and rx and ry. The “sweep – flag” determines whether the arc is mirrored around the axis going from the starting to the ending point. In other words, it controls the direction of the arc drawn that results in a mirror effect depending on a clockwise or anti-clockwise direction.
Example 2
Relative positioning.
- <html>
- <body>
- <svg height="300" width="700">
- <path d="M50,80 a100,50 0 1,1 250,50" style="stroke:green; stroke-width:3; fill:none;" />
- <path d="M400,100 a 100,50 30 1,1 250,50" style="stroke:red; stroke-width:3; fill:none;" />
- <path d="M400,230 a 100,30 25 1,1 250,50" style="stroke:lime; stroke-width:3; fill:none;" />
- <path d="M50,250 a 100,50 140 1,1 200,50" style="stroke:orange; stroke-width:3; fill:none;" />
- </svg>
- </body>
- </html>

Example 3
Large – arc – flag = 0.
- <html>
- <body>
- <svg height="300" width="700">
- <path d="M40,20 A30,30 0 0,0 100,100" style="stroke:lime; stroke-width:3; fill:none;" />
- <path d="M130,30 A70,40 0 0,0 250,80" style="stroke:green; stroke-width:3; fill:none;" />
- </svg>
- </body>
- </html>

Example 4
Combination of large – arc – flag = 0 & 1.
- <html>
- <body>
- <svg height="300" width="700">
- <path d="M40,20 A30,30 0 0,0 70,70" style="stroke:green; stroke-width:3; fill:none;" />
- <path d="M40,20 A30,30 0 1,0 70,70" style="stroke:lime; stroke-width:3; fill:none;" />
- <path d="M130,30 A70,40 0 0,0 220,80" style="stroke:lime; stroke-width:3; fill:none;" />
- <path d="M130,30 A70,40 0 1,0 220,80" style="stroke:green; stroke-width:3; fill:none;" />
- </svg>
- </body>
- </html>
Example 5
Combination of large-arc-flag and Sweep-flag.
- <html>
- <body>
- <svg height="300" width="700">
- <path d="M40,20 A30,30 0 0,0 70,70" style="stroke:brown; stroke-width:3; fill:none;" />
- <path d="M40,20 A30,30 0 1,0 70,70" style="stroke:tomato; stroke-width:3; fill:none;" />
- <path d="M40,20 A30,30 0 1,1 70,70" style="stroke:blue; stroke-width:3; fill:none;" />
- <path d="M40,20 A30,30 0 0,1 70,70" style="stroke:cyan; stroke-width:3; fill:none;" />
- <path d="M130,30 A65,40 0 0,0 220,80" style="stroke:orange; stroke-width:3; fill:none;" />
- <path d="M130,30 A65,40 0 1,0 220,80" style="stroke:yellow; stroke-width:3; fill:none;" />
- <path d="M130,30 A65,40 0 1,1 220,80" style="stroke:black; stroke-width:3; fill:none;" />
- <path d="M130,30 A65,40 0 0,1 220,80" style="stroke:grey; stroke-width:3; fill:none;" />
- </svg>
- </body>
- </html>

Example 6
Half-filled and stroked shape.
- <html>
- <body>
- <svg height="300" width="700">
- <path d="M130,30 A65,40 0 0,0 220,80" style="stroke:red; stroke-width:3; fill:orange;" />
- <path d="M130,30 A65,40 0 1,0 220,80" style="stroke:green; stroke-width:3; fill:none; stroke-dasharray:10 3;" />
- <path d="M130,30 A65,40 0 1,1 220,80" style="stroke:black; stroke-width:3; fill:none; stroke-dasharray:10 3;" />
- <path d="M130,30 A65,40 0 0,1 220,80" style="stroke:blue; stroke-width:3; fill:cyan;" />
- </svg>
- </body>
- </html>


Gopi ChandPosted Aug 1, 2015, 1:13 AM
Thanks a lot all of you :)
Mohammed IbrahimPosted Jul 31, 2015, 8:49 PM
nice article...
Neeraj KumarPosted Jul 31, 2015, 11:38 AM
Nice Article ..
Chervine BhiwooPosted Jul 31, 2015, 9:37 AM
Great article series! Thanks!
Nilesh JadavPosted Jul 31, 2015, 9:16 AM
Nice one sir
Pankaj Kumar ChoudharyPosted Jul 31, 2015, 8:12 AM
Nice Article Sir.......
Santhakumar MunuswamyPosted Jul 30, 2015, 10:57 AM
Good article. Thanks for sharing
Rajeesh MenothPosted Jul 29, 2015, 11:20 AM
Good One