| 1 |
% Copyright 2019 by Till Tantau |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Free Documentation License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
|
| 11 |
\section{SVG-Path Library} |
| 12 |
\label{section-library-svg-path} |
| 13 |
|
| 14 |
\begin{pgflibrary}{svg.path} |
| 15 |
This library defines a command that allows you to specify a path using the |
| 16 |
\textsc{svg}-syntax. |
| 17 |
\end{pgflibrary} |
| 18 |
|
| 19 |
\begin{command}{\pgfpathsvg\marg{path}} |
| 20 |
This command extends the current path by a \meta{path} given in the |
| 21 |
\textsc{svg}-path-data syntax. This syntax is described in detail in |
| 22 |
Section~8.3 of the \textsc{svg}-specification, Version~1.1. |
| 23 |
|
| 24 |
In principle, the complete syntax is supported and the library just |
| 25 |
provides a parser and a mapping to basic layer commands. For instance, |
| 26 |
|M 0 10| is mapped to |\pgfpathmoveto{\pgfpoint{0pt}{10pt}}|. There are, |
| 27 |
however, a few things to be aware of: |
| 28 |
% |
| 29 |
\begin{itemize} |
| 30 |
\item The computation underlying the arc commands |A| and |a| are not |
| 31 |
numerically stable, which may result in quite imprecise arcs. |
| 32 |
Bézier curves, both quadratic and cubic, are not affected, neither |
| 33 |
are arcs spanning degrees that are multiples of $90^{\circ}$. |
| 34 |
\item The dimensionless units of \textsc{svg} are always interpreted as |
| 35 |
points (|pt|). This is a problem with paths like |M 20000 0|, which |
| 36 |
will raise an error message since \TeX\ cannot handle dimensions |
| 37 |
larger than about 16\,000 points. |
| 38 |
\item All coordinate and canvas transformations apply to the path in |
| 39 |
the usual fashion. |
| 40 |
\item The |\pgfpathsvg| command can be freely intermixed with other |
| 41 |
path commands. |
| 42 |
\end{itemize} |
| 43 |
% |
| 44 |
\begin{codeexample}[preamble={\usepgflibrary{svg.path}}] |
| 45 |
\begin{pgfpicture} |
| 46 |
\pgfpathsvg{M 0 0 l 20 0 0 20 -20 0 q 10 0 10 10 |
| 47 |
t 10 10 10 10 h -50 z} |
| 48 |
\pgfusepath{stroke} |
| 49 |
\end{pgfpicture} |
| 50 |
\end{codeexample} |
| 51 |
% |
| 52 |
\end{command} |
| 53 |
|
| 54 |
|
| 55 |
%%% Local Variables: |
| 56 |
%%% mode: latex |
| 57 |
%%% TeX-master: "pgfmanual-pdftex-version" |
| 58 |
%%% End: |