TikZ and shading a rectangle

  • Follow


Hello all,

I'm trying to create a rectangle with a color gradient. While using the
following code the rectangle gets a (blue) colored line at the left
side:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\shade[left color=3Dwhite, right color=3Dblue]
      (0,0) rectangle +(9cm,2cm);
\shade[left color=3Dwhite, right color=3Dblue!20]
      (0,3cm) rectangle +(9cm,2cm);
\end{tikzpicture}
\end{document}

What is even more strange is that the line on the left changes as soon
as the color is modified to "blue!20" (the line gets wider).

I wouldn't expect a blue line at the left nor is it desired in my case.
Is it possible to create a rectangle with a color gradient without a
border at some side? At the moment I use a hack and create a white
rectangle in front of the left border. Something like this:

\draw[color=3Dwhite, fill=3Dwhite] (0,0) rectangle +(1mm,2cm);

But this is not really flexible and more like a hack. Even in the manual
of TikZ the issue arises, see manual version 2.0 on page 28. The
rectangle shading from yellow to black has at the top side a black line
which stands out because the yellow part starts there, too.

Is there some convenient/elegant solution outside?

Cheers,
Stefan

0
Reply schulzef (10) 5/7/2010 3:20:36 PM

� (at) Fri, 07 May 2010 17:20:36 +0200,
Stefan Schulze Frielinghaus <schulzef@in.tum.de> �crivait (wrote):

> But this is not really flexible and more like a hack. Even in the manual
> of TikZ the issue arises, see manual version 2.0 on page 28. The
> rectangle shading from yellow to black has at the top side a black line
> which stands out because the yellow part starts there, too.
>
> Is there some convenient/elegant solution outside?

Don't use evince as pdf viewer...

-- 
Paul Gaborit - <http://perso.mines-albi.fr/~gaborit/>
0
Reply Paul 5/7/2010 3:53:16 PM


On Fr, 2010-05-07 at 17:53 +0200, Paul Gaborit wrote:
[...]
> Don't use evince as pdf viewer...

I expected a lot of things but that my PDF viewer is the root of evil I
didn't ;-)

After a quick test, Xpdf displays both PDF files correctly. Thanks for
your hint!

Regards,
Stefan

0
Reply Stefan 5/7/2010 5:09:37 PM

2 Replies
1157 Views

(page loaded in 0.059 seconds)

Similiar Articles:













7/22/2012 12:02:39 PM


Reply: