# How can I slant the rectangular glow box with lighting effect in TikZ

I can get the corresponding lighting effect as Ivan Andrus' codes, but here I want to rotate or slant the box with lighting effect of the following type:

So I added the codes "xslant" and "yslant", but I obtained a failed type as the following:

Here is my MWE:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\def\yslant{0.5}
\def\xslant{-0.6}
%
%
\fill[inner color=blue,outer color=blue!10!black] ($(#1.south east)$) circle(\shadowradius);
\fill[inner color=blue,outer color=blue!10!white] ($(#1.north west)$) circle (\shadowradius);
%
\begin{scope}
\clip ($(#1.south west)$) circle (\shadowradius);
($(#1.south west)$) rectangle ++(-\shadowradius,-\shadowradius);
\end{scope}

\begin{scope}
\clip ($(#1.north east)$) circle (\shadowradius);
lower left=blue,         lower right=blue!10!black]
($(#1.north east)$) rectangle ++(\shadowradius,\shadowradius);
\end{scope}

\fill[ top color=blue, bottom color=blue!10!black] ($(#1.south west)+(0,-\shadowradius)$) rectangle ($(#1.south east)$);
\fill[left color=blue,right color=blue!10!black] ($(#1.south east)$) rectangle ($(#1.north east)+(\shadowradius,0)$);
\fill[bottom color=blue,top color=blue!10!white] ($(#1.north west)$) rectangle ($(#1.north east)+(0,\shadowradius)$);
\fill[right color=blue,left color=blue!10!white] ($(#1.south west)$) rectangle ($(#1.north west)+(-\shadowradius,0)$);
\end{pgfonlayer}
}
%
\begin{tikzpicture}[yslant=\yslant,xslant=\xslant,
every node/.append style={yslant=\yslant,xslant=\xslant}]
\node [fill=blue,rectangle,rounded corners=0pt,draw=blue, ultra thick, text=white] (box) {Test!!!};
\end{tikzpicture}
\end{document}


Any help will be really appreciated!

-
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. –  percusse Jun 12 '12 at 1:35
@percusse why don't you turn your comment into an answer? –  Gonzalo Medina Jun 12 '12 at 2:06
@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 :) –  percusse Jun 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 Medina Jun 12 '12 at 2:11
@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. –  percusse Jun 12 '12 at 2:21

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}

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\def\yslant{0.5}
\def\xslant{-0.6}
%
\pgflowlevel{\pgftransformrotate{45}}
%
\fill[inner color=blue,outer color=blue!10!black] ($(#1.south east)$) circle(\shadowradius);
\fill[inner color=blue,outer color=blue!10!white] ($(#1.north west)$) circle (\shadowradius);
%
\begin{scope}
\clip ($(#1.south west)$) circle (\shadowradius);
($(#1.south west)$) rectangle ++(-\shadowradius,-\shadowradius);
\end{scope}

\begin{scope}
\clip ($(#1.north east)$) circle (\shadowradius);
\shade[upper left=blue!10!white,upper right=blue!10,lower left=blue,lower right=blue!10!black] ($(#1.north east)$) rectangle ++(\shadowradius,\shadowradius);
\end{scope}

\fill[ top color=blue, bottom color=blue!10!black] ($(#1.south west)+(0,-\shadowradius)$) rectangle ($(#1.south east)$);
\fill[left color=blue,right color=blue!10!black] ($(#1.south east)$) rectangle ($(#1.north east)+(\shadowradius,0)$);
\fill[bottom color=blue,top color=blue!10!white] ($(#1.north west)$) rectangle ($(#1.north east)+(0,\shadowradius)$);
\fill[right color=blue,left color=blue!10!white] ($(#1.south west)$) rectangle ($(#1.north west)+(-\shadowradius,0)$);
\end{pgfonlayer}
}
%