PGF/TikZ Manual

The TikZ and PGF Packages
Manual for version 3.1.10

Libraries

73 SVG-Path Library

  • TikZ Library svg.path

  • \usepgflibrary{svg.path} % and plain and pure pgf
    \usepgflibrary[svg.path] % Cont and pure pgf
    \usetikzlibrary{svg.path} % and plain when using TikZ
    \usetikzlibrary[svg.path] % Cont when using TikZ

    This library defines a command that allows you to specify a path using the svg-syntax.

  • \pgfpathsvg{path}

  • This command extends the current path by a path given in the svg-path-data syntax. This syntax is described in detail in Section 8.3 of the svg-specification, Version 1.1.

    In principle, the complete syntax is supported and the library just provides a parser and a mapping to basic layer commands. For instance, M 0 10 is mapped to \pgfpathmoveto{\pgfpoint{0pt}{10pt}}. There are, however, a few things to be aware of:

    • The computation underlying the arc commands A and a are not numerically stable, which may result in quite imprecise arcs. Bézier curves, both quadratic and cubic, are not affected, neither are arcs spanning degrees that are multiples of \(90^{\circ }\).

    • The dimensionless units of svg are always interpreted as points (pt). This is a problem with paths like M 20000 0, which will raise an error message since cannot handle dimensions larger than about 16 000 points.

    • All coordinate and canvas transformations apply to the path in the usual fashion.

    • The \pgfpathsvg command can be freely intermixed with other path commands.

    (-tikz- diagram)

    \usepgflibrary {svg.path}
    \begin{pgfpicture}
    \pgfpathsvg{M 0 0 l 20 0 0 20 -20 0 q 10 0 10 10
    t 10 10 10 10 h -50 z}
    \pgfusepath{stroke}
    \end{pgfpicture}