10

I wonder whether it is possible to create a transparent shading effect (like the one below) without an exact specification of the fill color. This solution is good until I have to change the background to a non-solid fill (demonstrated by the yellow block). Can I create the (almost, I want to see the yellow line) same effect somehow with a transparent shade?

(Sorry for the brutal yellow, it is for demonstration purposes only.)

enter image description here

\documentclass{article}
\usepackage{tikz}

\begin{document}
\parindent0pt
  \null
  \definecolor{orange}{RGB}{233,77,16}

  \thispagestyle{empty}
  \vspace{-1cm}
  \vfill
  \hfil
  \begin{tikzpicture}[overlay]
    \coordinate (gNE)                       at (+0.501\paperwidth,+0.501\paperheight);
    \coordinate (gSW)                       at (-0.501\paperwidth,-0.501\paperheight);
    \coordinate (titleN)                at (+0.000\paperwidth,+0.300\paperheight);
    \coordinate (titleS)                at (+0.000\paperwidth,+0.100\paperheight);

    \fill [color=orange] (gSW) rectangle (gNE);
    \fill [color=yellow] (0.3\paperwidth,0.51\paperheight) rectangle (0.4\paperwidth,-0.5\paperheight);
    \shade [left color=black, right color=orange] (titleS -| gSW) rectangle (titleN -| gNE);
  \end{tikzpicture}
  \vfill

\end{document}

1 Answer 1

15

You can use path fading=east from the fadings library for this:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}

\begin{document}
\parindent0pt
  \null
  \definecolor{orange}{RGB}{233,77,16}

  \thispagestyle{empty}
  \vspace{-1cm}
  \vfill
  \hfil
  \begin{tikzpicture}[overlay]
    \coordinate (gNE)                       at (+0.501\paperwidth,+0.501\paperheight);
    \coordinate (gSW)                       at (-0.501\paperwidth,-0.501\paperheight);
    \coordinate (titleN)                at (+0.000\paperwidth,+0.300\paperheight);
    \coordinate (titleS)                at (+0.000\paperwidth,+0.100\paperheight);

    \fill [color=orange] (gSW) rectangle (gNE);
    \fill [color=yellow] (0.3\paperwidth,0.51\paperheight) rectangle (0.4\paperwidth,-0.5\paperheight);
    \fill [black, path fading=east] (titleS -| gSW) rectangle (titleN -| gNE);
  \end{tikzpicture}
  \vfill

\end{document}
2
  • Thanks (+1). Although I have a different output with this code. A whitish tint is all-over the black fading box. Can it be caused by MikTeX?
    – masu
    Commented Dec 11, 2013 at 8:52
  • @masu: That's probably an issue with the viewer. What viewer are you using?
    – Jake
    Commented Dec 11, 2013 at 8:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .