I need to fill a triangular node with an image, and rotate it at various angles. My approach for filling the node with an image is based on this one, and it works great if my node is not rotated, or rotated 180 degrees. But for other rotation angles, the node and the image do not rotate in sync. I suspect the problem involves the anchor, and I tried anchor=center, but it had no effect.
MWE:
\documentclass[margin=5pt]{standalone}
\usepackage{mwe}
\usepackage{tikz}
\usepgflibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[
tile/.style={regular polygon,
regular polygon sides=3,
draw,
minimum width=5cm,
minimum height=5cm,
rotate=#1,
path picture={
\node at (path picture bounding box.center){
\includegraphics[width=5cm,angle=#1]{example-image-a}
};
}}
]
% node 1, not rotated
\node[tile={0}] at (0,0) {};
% node 2, rotated 180
\node[tile={180}] at (5,0) {};
% node 3, rotated 120
\node[tile={120}] at (0,-5) {};
% node 4, rotated 57
\node[tile={57}] at (5,-5) {};
\end{tikzpicture}
\end{document}
Result:
Follow-up question: What if the node and the image are already rotated at different angles? For example, if I want to fill an "upside-down" triangle with a "right-side-up" image, then I have to use rotate=180 for the node but angle=0 for the image. Then I want to rotate the whole thing with those angles as a starting point.


0.6cmcome from? Is that calculated somehow or just trial and error? – LarrySnyder610 May 21 '19 at 02:13shape uses incircleor something of that sort. The main point of the answer is that the center of the path picture moves, see this related question. – May 21 '19 at 02:28