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.
Copyright © verlag moderne industrie GmbH 2001
You may print the online version for your private use.
Otherwise, this chapter from “Das Einsteigerseminar SVG — Webgrafiken mit XML” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
verlag moderne industrie GmbH, Justus-von-Liebig-Straße 1, D-86899 Landsberg/Lech, fon ++49 (0) 81 91 / 125 – 0, leserservice(at)mi-verlag.de
back to top