SVG reference
Drawing Arcs in SVG
- An Arc is drawn in a special way.
- Firstly, there is no HTML or SVG element that directly draws an arc.
- Arcs can be drawn using the "A" instruction within a PATH element
- <PATH d="M 120 20
A 75 45, 0, 0, 0, 200 80
" ...
- <PATH d="M 120 20
-
If you are not familiar with the PATH and it's d attribute syntax, please do so before continuing.
-
Syntax of the arc part of the draw attribute is :
- " A rX,rY angle, arc, sweep, eX,eY.
- there is also a lowercase 'relative coord' version 'a'
-
more info here: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d (opens in a new tab)
-
In short, A: Draws an Arc curve from the current point to the coordinate x,y.
-
The center of the ellipse used to draw the arc is determined automatically based on the other parameters of the command:
- rX and rY: are the two radii of the ellipse;
- angle: represents a rotation (in degrees) of the ellipse relative to the x-axis;
- arc flag and sweep flag: allows to chose which arc must be drawn as 4 possible arcs can be drawn out of the other parameters.
- large-arc-flag allows to chose one of the large arc (1) or small arc (0),
- sweep-flag allows to chose one of the clockwise turning arc (1) or counterclockwise turning arc (0)
-
The coordinate eX,eY becomes the new current point for the next command.
-
All subsequent sets of parameters are considered implicit absolute arc curve (A) commands.