I'd like to draw a square with the fill color darkening as one goes up or as one goes to the right. So, the square should be darkest in the upper-right corner and lightest in the lower-left corner. Is there a way to do this using PGF commands?
Asked
Active
Viewed 5,168 times
2 Answers
13
Another possibility is using tikz commands:
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\tikz\shade[shading=axis,bottom color=black!10,top color=black,shading angle=-45]
(0,0) rectangle (3,3);
\end{document}
rgallego
- 2,112
6
Such shadings are described in section 85.2 of the TikZ manual. Here's an example of what you want:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\pgfdeclareverticalshading{myshadingE}{80bp}
{color(0bp)=(white); color(80bp)=(black)}
\begin{pgfpicture}
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{3cm}{3cm}}
\pgfshadepath{myshadingE}{-45}
\pgfusepath{stroke}
\end{pgfpicture}
\end{document}

Alan Munn
- 218,180
-
Thanks so much, exactly what I wanted! I was looking at an old user guide from 2004. – arnab Jan 02 '11 at 01:30
\shadedraw– ted Jun 23 '13 at 19:21