Add \pgflowlevel{\pgftransformrotate{45}} both in tikzpicture environment and after the \begin{pgfonlayer}{shadow} in the macro definition and it should work. If you want to keep the rotation local, put the contents in a scope in the tikzpicture copy. No need for the other copy.
–
percusseJun 12 '12 at 1:35

@GonzaloMedina It's kind of a sledgehammer to kill a mosquito. So I'll wait a little before I do that unless someone else joins in :)
–
percusseJun 12 '12 at 2:08

@percusse I was thinking about a transform canvas={rotate=30} kind of solution... but I am not sure it will work with the shadow layer.
–
Gonzalo MedinaJun 12 '12 at 2:11

1

@GonzaloMedina I think the shading doesn't follow the current transformation matrix so that kind of upper level transformations might not be powerful enough to affect the shading coordinate calculations hence the low level proposition.
–
percusseJun 12 '12 at 2:21

1 Answer
1

This is one of the cases where I do something and hope that it's picked up by the correct mechanism. The reason for the misaligned shading pattern is that the actual shader does not know you have rotated the picture. It's very much like the view out of the window regardless of the window shape. You just see the same stuff through. So we have to somehow pass the news to the shader.

As usual with shadings, it depends on the PDF viewer and to the contrary of the usual case, Adobe Reader renders it correctly but Sumatra fails to get the corners right. On a different machine it's the other way around. So you have been warned :P

We simply add low level canvas transformations to the required places via \pgflowlevel{} command. I use rotate here but can be other transformations too. As discussed in the comments you can keep the transformation local by surrounding it with \begin{scope}...\end{scope}