Closed asepsiswu closed 1 year ago
I found solution with [transform canvas={xshift=1cm}]
in https://tex.stackexchange.com/questions/364658/tikz-spath-not-flipping-properly
I don't get that picture with your code, and that's nothing to do with the spath3
package. The black and cyan squares should be further apart. This is what I get:
The magenta spot is at the origin (outside the shifted scope).
To get what's in your picture, I need to shift the definition of the black square out of the shifted scope.
Now, to see what's going on with the red and cyan squares, you have to understand how TikZ/PGF applies transformations. When a coordinate, such as (3,4)
, is read in then the transformation is applied to that coordinate at that moment. So when the path is constructed the transformation has already been applied. Therefore the default assumption is that an ambient transformation should not be applied to an spath when it is used.
However, in recognition of the fact that sometimes a user might want to apply the ambient transformation, in the latest version then I've provided a key to do this. The key is use current transformation
and should be issued as one of the arguments to the use
key.
So with the current version here, the following works:
\documentclass[a4paper]{article}
%\url{https://github.com/loopspace/spath3/issues/20}
\usepackage{tikz}
\usetikzlibrary{spath3}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\draw [help lines] (-2,-2) grid (2,2);
\fill[spath/save=cc](0.5,0) rectangle (1,.5);
\begin{scope}[xshift=1cm]
\fill[spath/transform={cc}{xscale=-1},spath/use={cc,use current transformation},red,];
\end{scope}
\fill[cyan,fill opacity=.5](0,0) rectangle (0.5,.5);
\fill[magenta] circle[radius=2pt];
\end{tikzpicture}
\end{document}
This produces:
Thanks for your explanation and solution. I think use current transformation
is better than transform canvas
.
I found something quite unexpected.
If I save path in the scope with shift, the use path will double shift.
\documentclass[a4paper]{article} %\url{https://github.com/loopspace/spath3/issues/20} \usepackage{tikz} \usetikzlibrary{spath3} \pagestyle{empty} \begin{document} \begin{tikzpicture} \draw [help lines] (-2,-2) grid (2,2);
\fill[spath/save global=cc] (0,0) rectangle (.5,1);
\begin{scope}[xshift=1cm]
\fill[spath/transform={cc}{xshift=1cm},spath/use={cc,use current transformation},red];
\end{scope}
\begin{scope}[xshift=1cm,yshift=-1cm]
\path[spath/save=ccc] (0,0) rectangle (.5,1);
\fill[spath/transform={ccc}{xshift=1cm},spath/use={ccc,use current transformation},red!50];
\end{scope}
\end{tikzpicture}
\end{document}
That's the expected behaviour.
The transformation is applied when the path is defined as it is defined inside the scope. Then it is applied again when the path is used since you use the use current transformation
key.
Hi, I would like to shift the whole scope containing saved path with scale. The
xshift
value is directly applied to thexscale
factor, inside thescope
environment which is not expected.How to do it?
In the following example, how to place the red rectangle in the cyan one