# Recover scaling factor in TikZ

Does it exist some tikz register (let say \zoomfactor) that provides the curent scale factor. For example can I do something like :

\begin{tikzpicture}[scale=2]
\begin{scope}[scale=1.5]
\draw (0,0) circle (\zoomfactor);
\end{scope}
\end{tikzpicture}


and to obtain circle of size 3=2*1.5 ?

-

You can get the current transformation entries to extract the scale but if there are different x and y scalings(or combinations e.g. full matrix) in action, this would fail and retrieve only the x scaling. Also it uses 1cm as the unit vector.

\documentclass{article}
\usepackage{tikz}

\newcommand{\getzoomfactor}{%
\pgfgettransformentries{\myxscale}{\@tempa}{\@tempa}{\myyscale}{\@tempa}{\@tempa}
\gdef\zoomfactor{\myxscale*1cm}
}

\begin{document}

\begin{tikzpicture}[scale=2]
\begin{scope}[scale=1.5]
\getzoomfactor
\draw (0,0) circle (\zoomfactor);
\node {\zoomfactor};
\end{scope}
\end{tikzpicture}

\end{document}


-
Thanks, \myxscale is what I was searching for. In your example you can put \myxscale in place of \zoomfactor and it works withouyt assuming 1cm as the unit vector. –  Kpym Dec 13 '12 at 18:00
@Kpym If you mix numbers without units with numbers with units you'll always get trouble. So some care is needed. –  percusse Dec 13 '12 at 19:34