# from the pgf Basic Layer to the pgf System Layer

I would like to translate a code from the pgf Basic Layer to the pgf System Layer. My first code is :

\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}

a\fbox{\begin{tikzpicture}
\pgftransformscale{.025}%
\pgfpathmoveto{\pgfqpoint{71.43 bp}{238.86bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{238.86bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{332.57bp}}
\pgfpathlineto{\pgfqpoint{428.57bp}{214.29bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{96.00 bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{189.71bp}}
\pgfpathlineto{\pgfqpoint{71.43 bp}{189.71bp}}
\pgfpathclose
\pgfusepath{fill,stroke}%
\pgfpathmoveto{\pgfqpoint{453.14bp}{381.71bp}}
\pgfpathlineto{\pgfqpoint{500.00bp}{381.71bp}}
\pgfpathlineto{\pgfqpoint{500.00bp}{46.86 bp}}
\pgfpathlineto{\pgfqpoint{453.14bp}{46.86 bp}}
\pgfpathclose
\pgfusepath{fill,stroke}%
\end{tikzpicture}}b
\end{document}


I get what I want :

Now with the pgf System Layer, I have the next code but I don't know how to add a bounding box

\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}

\makeatletter

a\fbox{\begin{tikzpicture}
\pgfsys@transformxyscale{.025}{.025}
\pgfsys@fill
\pgfsys@moveto{71.43bp}{238.86bp}
\pgfsys@lineto{310.29bp}{238.86bp}
\pgfsys@lineto{310.29bp}{332.57bp}
\pgfsys@lineto{428.57bp}{214.29bp}
\pgfsys@lineto{310.29bp}{96.00bp}
\pgfsys@lineto{310.29bp}{189.71bp}
\pgfsys@lineto{71.43bp}{189.71bp}
\pgfsys@closepath
\pgfsys@fillstroke
\pgfsys@fill
\pgfsys@moveto{453.14bp}{381.71bp}
\pgfsys@lineto{500.00bp}{381.71bp}
\pgfsys@lineto{500.00bp}{46.86bp}
\pgfsys@lineto{453.14bp}{46.86bp}
\pgfsys@closepath
\pgfsys@fillstroke
\end{tikzpicture}}b

\end{document}


and unhappily the result is

How to obtain the same result?

-
Why are you using a tikzpicture with PGF code and not a pgfpicture? –  Martin Scharrer Jan 20 '12 at 11:30
Looking at the definition of \pgflineto I see a \pgf@protocolsizes which I guess records the point so that the bounding box is updated. –  Martin Scharrer Jan 20 '12 at 12:00
In my first attempt, I used pgfpicture but finally I did not see differences with tikzpicture and I need to use this code inside a greater project. Thanks for \pgf@protocolsizes, because around this macro in the pgfmanual, I saw \pgf@picmaxx etc. I have 90 objects and I need 20,000 lines to define these objects. I know the size of each object, also a good solution is perhaps to set manually the bounding box. In this case, the problem now is to update the bounding box with the scale –  Alain Matthes Jan 20 '12 at 15:14

## 1 Answer

The problem seems to be the unequivalence of the commands

\pgfsys@transformxyscale{0.025}{0.025}


and

\pgftransformscale{.025}


The latter command is actually, as you nicely demonstrated, in the basic layer and does not act on the canvas itself. However if I make it a system layer transformation such that it applies to everything, I get precisely the bad drawing. Here is what I did:

\documentclass{article}
\usepackage{tikz}
\begin{document}

a\fbox{\begin{tikzpicture}
\pgflowlevel{\pgftransformscale{.025}}%
\pgfpathmoveto{\pgfqpoint{71.43 bp}{238.86bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{238.86bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{332.57bp}}
\pgfpathlineto{\pgfqpoint{428.57bp}{214.29bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{96.00 bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{189.71bp}}
\pgfpathlineto{\pgfqpoint{71.43 bp}{189.71bp}}
\pgfpathclose
\pgfusepath{fill,stroke}%
\pgfpathmoveto{\pgfqpoint{453.14bp}{381.71bp}}
\pgfpathlineto{\pgfqpoint{500.00bp}{381.71bp}}
\pgfpathlineto{\pgfqpoint{500.00bp}{46.86 bp}}
\pgfpathlineto{\pgfqpoint{453.14bp}{46.86 bp}}
\pgfpathclose
\pgfusepath{fill,stroke}%
\end{tikzpicture}}b
\makeatletter

\end{document}


and this gives

Therefore, we need to find the actual low-level equivalent of \pgftransformscale{} command. I have tried to find a direct handle but it seems that relative coordinate transformations are not so straightforward to be handled at the system layer. I can see that the unit vectors are \edefed in pgfcoretransformation.code.tex file so I don't have much hope (but my knowledge is with what is documented, I might be wrong about this).

-