I'm trying to create a slanted shading effect on a tikz picture. I already have this effect working for the top and bottom, but have not found a way to get this working right for the left and right one.
Here's the code I used for this:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadings, patterns}
\begin{document}
\definecolor{lightblue}{rgb}{0,0.8,1}
\definecolor{grey}{rgb}{0.9,0.9,0.9}
\begin{tikzpicture}
\shade[bottom color=black!0,top color=black!50] (0,0) -- (-0.25,-0.25) -- (3.75,-0.25) -- (4,0);
\shade[bottom color=black!50,top color=black!0] (2,2) -- (2.25,2.25) -- (6.25,2.25) -- (6,2);
\draw[draw=black!50!grey,-,dashed] (2,2) -- (1.5,2);
\draw[draw=black!50!grey,-,dashed] (6,2) -- (6.5,2);
\draw[draw=black!50!grey,-,dashed] (0,0) -- (-0.25,-0.25);
\draw[draw=black!50!grey,-,dashed] (2,2) -- (2.25,2.25);
\draw[draw=black!50!grey,-,dashed] (6,2) -- (6.25,2.25);
\draw[draw=black!50!grey,-,dashed] (4,0) -- (3.75,-0.25);
\draw[draw=black!50!grey,-,dashed] (4,0) -- (4.5,0);
\node at (2,2)[circle,fill,inner sep=1.5pt]{};
\draw[pattern={north west lines},pattern color=lightblue,draw=none] (0,0) -- (2,2) -- (6,2) -- (4,0);
\node at (2,2)[circle,fill,inner sep=0.8pt]{};
\draw (0,0) -- (2,2);
\node at (0,0)[draw=blue,circle,fill=blue,inner sep=1.5pt]{};
\draw (2,2) -- (6,2);
\draw (4,0) -- (0,0);
\node at (0,0)[draw=blue,circle,fill=blue,inner sep=0.6pt]{};
\node at (6,2)[circle,fill,inner sep=1.5pt]{};
\draw[draw=green, thick] (6,2) -- (4,0);
\node at (6,2)[circle,fill,inner sep=0.8pt]{};
\node at (4,0)[circle,fill,inner sep=1.5pt]{};
\draw[draw=red,thick,->] (3,1) -- (3,3);
\draw[thick,draw=red] ([xshift=2mm]3,1) arc[start angle=0,end angle=90,radius=2mm];
\node[draw=red,fill=red,inner sep=0.25pt,circle] at (3.0707,1.0707) {};
\draw[draw=green,thick,->,dashed] (5,1) -- (7,1) node[right] {Edge};
\draw[draw=red,thick,->,dashed] (3,2.5) -- (7,2.5) node[right] {Normal Vector};
\draw[draw=blue,thick,->,dashed] (0,0) -- (-1,0) node[left] {Vertex};
\draw[draw=lightblue,thick,->, dashed] (2,1.5) -- (-1,1.5) node[left] {Face};
\end{tikzpicture}
\end{document}
I have tried to use something like \shade[right color=black!100,left color=black!0,xslant=1,shading angle=45] (-0.5,0) rectangle (0,2);
, but the shading doesn't slant with the parameter, but rather creates a cutout of the shade that is slanted:
Does anyone have an idea on how I can get the desired effect?
Thank you!
white
is in the upper left corner of the rectangle around your path. Take a look at\shade[right color=black,left color=white,xslant=1,shading angle=45] (-0.5,0) rectangle (0,2); \clip (-0.5,1) rectangle ++ (1.5,1); \shade[right color=black,left color=white,draw=red,shading angle=45] (-0.5,0) rectangle ([xslant=1]0,2);
. The shading will be calculated across the rectangle bounding box around your path, irregardless of any transformations.