# Draw a rectangle hiding an area of a picture

I have something drawn as a tikzpicture:

\begin{tikzpicture}
\node[above] at (8,13) {$...$};
\filldraw[fill=white!20] (2,0) rectangle (6,12);
\draw (2,4) -- (2,12); \draw (2,12) -- (6,12); \draw (6,12) -- (6,4);
\draw [dashed] (6,3) -- (1,3);
...
\end{tikzpicture}


Now I would like to draw a non-transparent white rectangle which hides a part of the picture, so that what is under the rectangle becomes invisible or less visible (e.g. gray). Does anyone know how to do it?

-
\draw (2,4) -- (2,12); ... is not useful after \filldraw ... –  Alain Matthes Aug 15 '12 at 16:11

You can simply move the \filldraw command to be after what you want hidden, and control the opacity with fill opacity=<opacity>:

If you want what is underneath to be complely hidden, adding fill opacity=1.0 captures the specific intent (even though it is the default).

## Note:

• I changed the color to yellow!20 to make the effect clearer in the image here. Replacing this with fill=white will give you the desired result.

## Code:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\foreach \OpacitySetting in {1.0, 0.95, 0.75}{%
\begin{tikzpicture}
\draw [blue, ultra thick] (0,2) -- (4,2);
\filldraw[fill=yellow!20, fill opacity=\OpacitySetting] (1,0) rectangle (3,4)
node [above left, text opacity=1.0]  {opacity=\OpacitySetting};
\end{tikzpicture}%
\hspace{0.25cm}%
}%
\end{document}

-
Thank you... How can I do not show the edges of the rectangle? –  SoftTimur Aug 15 '12 at 16:49
@SoftTimur \draw draws just the edge of the rectangle, \fill just fills the rectangle without drawing the edge, while \filldraw does both. In other words, replace \filldraw with \fill. –  Torbjørn T. Aug 15 '12 at 16:57