The SVG <path> : Arcs

SVG has dedicated <circle> and <ellipse> elements, but if you only want to draw a section of a circular or elliptical arc, you need to use a <path> element with an arc command. The arc command defines the shape of the ellipse that should be used to connect two points. But it also has to define which of four possible arcs (all following the shape of that ellipse) should be used to connect those points.

The arc format is " [A|a]rx,ry, x-axis-rotation, large-arc-flag, sweep-flag, x,y ". As with the other path directions, the arc starts at the end-point of the previous direction (which might be simply a "move" command to start a path).

If you're used to SVG <circle> and <ellipse> elements, you'll be struck by the fact that the centre of the shape is never specified. Instead, it's calculated to fit the other requirements. The example shows how this can get confusing.

The large-arc-flag is easy to understand: it tells the path to take the long way around the ellipse. The sweep-flag is less intuitively named, but can be understood as the "clockwise" flag; it forces the arc to be positioned such that the chosen (long or short) arc makes a clockwise curve between the start and end points.

One final point: Arc notation falls apart if you try to draw a complete circle or ellipse, where the end-point is the same as the start-point. The large-arc-flag will be ignored and the segment interpretted as a zero-length line. That's because there are infinite possible ways to position an ellipse (not just four) when only a single point is defined — that point could be anywhere on the shape. If you do want to draw a complete circle as part of a path, you'll have to break it down into two arcs: "M0,50 A50,50,0 1 1 100,50 A50,50,0 1 1 0,50 Z" is the circle that exactly fills a 100×100 square.