XML technologies / SVG / Using complex graphic elements and formatting / Using paths correctly / Absolute and relative coordinates

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

As the example showed, paths can use relative and absolute coordinates. Unlike other SVG elements, however, a single command cannot mix them. For each command in the d attribute, choose entirely relative or entirely absolute positions. The command letter’s case determines this: uppercase requires absolute values; lowercase requires relative values. Within a path, however, commands using relative values can be mixed with commands using absolute values, as the example shows.

The following example uses l+100 –50 to create a line relative to the starting point, followed by a line to 50/50 using absolute coordinates.

<path d="M200 200 l+100 -50 L50 50" />

Nevertheless, use coordinates consistently within a path. Mixing absolute and relative positions can produce unwanted results when moving the starting position.

Note:
A path’s starting point must always use absolute values, because relative values refer to the current path point, which does not yet exist at the beginning.

   

 

 

 

back to top