# rotate node shape in tikz

Edit 1

Claudio gave a nice solution to my question. But the image should be included in a beamer presentation. I use for that the option transform canvas={scale=0.5} and this has a side problem with the node position. Compare the image below with that provided in Claudio's answer.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds,positioning}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\begin{document}
\thispagestyle{empty}
\tikzset{every picture/.style={transform canvas={scale=0.5}}}
\begin{tikzpicture}[
cross appereance/.style={
white,very thick,
},
cross/.style={append after command={
\pgfextra{
\begin{pgfinterruptpath}
\begin{pgfonlayer}{foreground}
\draw[cross appereance,shorten <=0.35\pgflinewidth,shorten >=0.35\pgflinewidth]
(\tikzlastnode.south) --
(\tikzlastnode.north);
\draw[cross appereance,shorten <=0.4\pgflinewidth,shorten >=0.4\pgflinewidth]
(\tikzlastnode.west) --
(\tikzlastnode.east);
\end{pgfonlayer}
\end{pgfinterruptpath}
}
}
},
]

\begin{scope}[shift={(1cm,1cm)}, every node/.style={rotate=-60}]
\end{scope}
\end{tikzpicture}
\end{document}


Original question

I made a rectangle with a white cross in the centre using the picture path and the shapes anchors (north, south,...). My problem is that when I rotate the node the cross is not rotated.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[
cross/.style={path picture={
\draw[white,very thick]
(path picture bounding box.south) -- (path picture bounding box.north) (path picture bounding box.west) -- (path picture bounding box.east);}},
]

\begin{scope}[xshift=1cm, every node/.style={rotate=-60}]
\end{scope}
\end{tikzpicture}
\end{document}


-

I guess the problem here relies on how the cross has been created: my feeling is that by exploiting the path picture bounding box as reference makes things rather complicated. I'm not sure whether is possible to rotate that (perhaps yes, but what's the effort?) and for sure there's a simpler way. Indeed, for debugging purposes it is possible to draw the path picture bounding box and notice that it isn't rotate at all with your code:

\documentclass[tikz,png,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds,positioning}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\begin{document}
\begin{tikzpicture}[
cross/.style={path picture={
\begin{pgfonlayer}{foreground}
\draw[white,very thick]
(path picture bounding box.south) -- (path picture bounding box.north) (path picture bounding box.west) -- (path picture bounding box.east);
\draw[blue]
(path picture bounding box.south west) --
(path picture bounding box.north west) --
(path picture bounding box.north east) --
(path picture bounding box.south east) -- cycle;
\end{pgfonlayer}
}},
]

\begin{scope}[xshift=1cm, every node/.style={rotate=-60}]
\end{scope}
\end{tikzpicture}
\end{document}


Similarly to what did in How to modify nodes in TikZ to automatically add a line on their top? one can proceed as follows:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds,positioning}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\begin{document}
\begin{tikzpicture}[
cross appereance/.style={
white,very thick,
},
cross/.style={append after command={
\pgfextra{
\begin{pgfinterruptpath}
\begin{pgfonlayer}{foreground}
\draw[cross appereance,shorten <=0.35\pgflinewidth,shorten >=0.35\pgflinewidth]
(\tikzlastnode.south) --
(\tikzlastnode.north);
\draw[cross appereance,shorten <=0.4\pgflinewidth,shorten >=0.4\pgflinewidth]
(\tikzlastnode.west) --
(\tikzlastnode.east);
\end{pgfonlayer}
\end{pgfinterruptpath}
}
}
},
]

\begin{scope}[xshift=1cm, every node/.style={rotate=-60}]
\end{scope}
\end{tikzpicture}
\end{document}


The result:

If you apply a transformation, then perhaps you want to change a bit the quad style otherwise besides having the label too distant there are also bad effects.

That's what happens to me:

\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{backgrounds,calc,positioning}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\tikzset{every picture/.style={transform canvas={scale=0.5}}}

\tikzset{white circle/.style={circle,minimum size=4cm, draw}}
\tikzset{green circle/.style={circle,minimum size=0.1cm, draw,bottom color=green!80}}
\tikzset{red circle/.style={circle,minimum size=0.1cm, draw,bottom color=red!80}}
\tikzset{blue circle/.style={circle,minimum size=0.1cm, draw,bottom color=blue!80}}

\begin{document}

\begin{frame}{A picture alone}
\centering
\begin{tikzpicture}
\pgfmathsetseed{123456}
\node (inc) at (0,5) [white circle,label=INCLUSIONE] {};

\foreach \circle in {1,...,10}{
\pgfmathrandom{0,360}
\pgfmathtruncatemacro\angle\pgfmathresult
\pgfmathrnd
\pgfmathsetmacro\distance\pgfmathresult
\node[green circle] at ($(inc.center)!\distance!(inc.\angle)$){};
}

\foreach \circle in {1,...,10}{
\pgfmathrandom{0,360}
\pgfmathtruncatemacro\angle\pgfmathresult
\pgfmathrnd
\pgfmathsetmacro\distance\pgfmathresult
\node[red circle] at ($(inc.center)!\distance!(inc.\angle)$){};
}

\foreach \circle in {1,...,10}{
\pgfmathrandom{0,360}
\pgfmathtruncatemacro\angle\pgfmathresult
\pgfmathrnd
\pgfmathsetmacro\distance\pgfmathresult
\node[blue circle] at ($(inc.center)!\distance!(inc.\angle)$){};
}
\end{tikzpicture}

\end{frame}

\begin{frame}{Title}

Without change the style:

\begin{center}
\begin{tikzpicture}[
cross appereance/.style={
white,very thick,
},
cross/.style={append after command={
\pgfextra{
\begin{pgfinterruptpath}
\begin{pgfonlayer}{foreground}
\draw[cross appereance,shorten <=0.35\pgflinewidth,shorten >=0.35\pgflinewidth]
(\tikzlastnode.south) --
(\tikzlastnode.north);
\draw[cross appereance,shorten <=0.4\pgflinewidth,shorten >=0.4\pgflinewidth]
(\tikzlastnode.west) --
(\tikzlastnode.east);
\end{pgfonlayer}
\end{pgfinterruptpath}
}
}
},
]

\begin{scope}[every node/.style={rotate=-60}]
\end{scope}
\end{tikzpicture}
\end{center}

By changing the style:

\begin{center}
\begin{tikzpicture}[
cross appereance/.style={
white,very thick,
},
cross/.style={append after command={
\pgfextra{
\begin{pgfinterruptpath}
\begin{pgfonlayer}{foreground}
\draw[cross appereance,shorten <=0.35\pgflinewidth,shorten >=0.35\pgflinewidth]
(\tikzlastnode.south) --
(\tikzlastnode.north);
\draw[cross appereance,shorten <=0.4\pgflinewidth,shorten >=0.4\pgflinewidth]
(\tikzlastnode.west) --
(\tikzlastnode.east);
\end{pgfonlayer}
\end{pgfinterruptpath}
}
}
},
]

\begin{scope}[every node/.style={rotate=-60}]
\end{scope}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}


The results:

-
It is workng fine like a standalone, but I would like to include the picture in a beamer slide. For that I scale all the tikzpicture with transform canvas={scale=0.5}. In this case the quads are not showing. –  zunbeltz Jun 14 '13 at 10:06
Did you used my working code? With my approach I don't perceive problems in Beamer with \tikzset{every picture/.style={transform canvas={scale=0.5}}} added to the preamble. Perhaps it is worth to modify your question in order to resemble your real needs. –  Claudio Fiandrino Jun 14 '13 at 10:13
Your example is working fine. The problem is that the shape appear very far from the label (which is ok). It also hapens in your code if you change xshift to shift={(1cm,1cm)}. –  zunbeltz Jun 14 '13 at 10:33
Sorry, but I'm confused: The problem is that the shape appear very far from the label (which is ok). Hence, it is a problem or it is ok? It appears far since you applied the canvas transformation, but, again, if you can provide a MWE with that picture plus another I can give you some more information. –  Claudio Fiandrino Jun 14 '13 at 18:38
Sorry for not being clear enough. I made an edit to the question with the problem (MWE and image included). –  zunbeltz Jun 17 '13 at 7:59