I have a tikz pic that I wish to rotate and move around. If I define the pic with number coordinates, this works fine. If I define the pic with named coordinates (handy reference points I use for many of my pics), then the transforms do not apply.
(err sorry, the picture is rather small. I guess because the default units are in centimetres?).
In the first example, I've defined a pic named line that goes from points (A) to (B).
In the example below it, I've defined a pic unnamed line that goes from points (0,0) to (1, 0) (which are A and B respectively).
I then apply a transform to the pic (xscale=-1). The named line is not transformed, while the unnamed one is.
I guess the coordinate definition of (A) and (B) is invariant to transforms? Is there a way to make them subject to the transforms? (I have quite a number of coordinates that I reuse a few times, and it would be nice to just to refer to them by labels instead of their numbers. I guess I can just \def\coordA{(0,0)} but I wanted to know if there was a Tikz solution).
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{scopes}
\tikzset{
named line/.pic = {
\draw (A) -- (B);
},
unnamed line/.pic = {
\draw (0,0) -- (1, 0);
}
}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0, 0);
\coordinate (B) at (1, 0);
\draw pic [red] {named line};
\draw pic [blue,xscale=-1] {named line};
\begin{scope}[yshift=-1cm]
\draw pic [red] {unnamed line};
\draw pic [blue,xscale=-1] {unnamed line};
\end{scope}
\end{tikzpicture}
\end{document}


picsomehow. Thanks. – mathematical.coffee Dec 09 '16 at 01:48picto make use of this, you should say\tikzset{named line/.pic = {\draw[transform coordinate] (A) -- (B);}. This should do exactly what you want. – Hood Chatham Dec 09 '16 at 01:54