[Tex/LaTex] Tikz scale vs pgf scale

tikz-pgf

The following code shows that the tikz "scale" is different from pgf?

Changing the scale values for x and y in the tikzset command will scale the tikz rectangle but not the pgf star. Any ideas how to reconcile this? I need to be able to to scale my tikz pictures easily but have pgf use the same scale and origin.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts,shapes.geometric}
\begin{document}
\tikzset{x=0.1in,y=0.1in}
\begin{tikzpicture}
\draw[top color= black!50] (-2,-2) rectangle (5,4);

\begin{scope}
\pgfset{minimum width=1.5cm,minimum height=1.5cm}
\pgftransformshift{\pgfpoint{2cm}{2cm}}
\pgfnode{star}{center}{}{}{\pgfusepath{clip}}
\pgftransformreset
% Back to drawing
\fill[yellow] (2cm,2cm) circle (0.65cm);
\end{scope}
\end{tikzpicture}
\end{document}

Best Answer

The main difficulty is that the scale and transform shape keys belong to /tikz/ family and does not penetrate down to PGF level. Instead they are mapped with rather tedious mechanisms. Hence, we need to somewhat fake it with low level transformation commands. If for some reasons we still need to use [x=0.1in,y=0.1in] we have to add the corresponding \pgfsetxvec and \pgfsetyvec commands appropriately to mimic the TikZ effect.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{tikzpicture}[scale=.75]
\pgfgettransform{\somemacro}
\draw[top color= black!50] (-2cm,-2cm) rectangle (5cm,4cm);
\draw[style=help lines] (-2cm,-2cm) grid[step=1cm] (5cm,4cm);
\node (o) at (0,0) {0};


\begin{scope}
\pgfset{minimum width=1.5cm,minimum height=1.5cm}
\pgftransformshift{\pgfpoint{3cm}{0cm}}
\pgfnode{star}{center}{}{}{\pgfusepath{clip}}
\pgfsettransform{\somemacro}
\fill[yellow] (3cm,0cm) circle (0.65cm);
\end{scope}

\node[draw,circle,transform shape] (dum) at (2,2) {(2,2)};

\begin{scope}
\pgfset{minimum width=2cm,minimum height=2cm}
\pgftransformshift{\pgfpoint{0cm}{2.5cm}}
\pgfnode{star}{center}{}{}{\pgfusepath{clip}}
\pgfsettransform{\somemacro}
\fill[red] (0cm,2.5cm) circle (0.8cm);
\end{scope}

\end{tikzpicture}
\end{document}

enter image description here