If you name the node in the second slide you can use a fill=<color>
with fill opacity=<num>
. By naming the node we can easily access the coordinates of the vertices so that we can traverse the region we want to fill:
\draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
\fill [draw=none, fill=white, fill opacity=0.3]
(0,0.5) --
(A.north west) -- (A.north east) -- (A.south east) --
(0.5,0) -- (0.5,0.5) -- cycle;
Using a modified version showing those two images side by side to see the effect:
![enter image description here](https://i.stack.imgur.com/2dWSR.png)
Notes:
- To get the images to align I shifted the drawing of the box by
0.5\pgflinewidth
. So if you notice that your beamer image shifts from slide to slide, you will need to apply this shift as well.
- Even with this adjustment, the second image appears to be off slightly and I don't know why. So perhaps another tweak is required.
Code:
\RequirePackage[demo]{graphicx}
\documentclass{beamer}
\usetheme{Copenhagen}
\usecolortheme{whale}
\useinnertheme{rounded}
\usepackage{tikz}
\newcounter{boxes}
\newcommand\ordbox[2]{%
\stepcounter{boxes}
\tikz[remember picture,overlay]{
\node[rectangle,rounded corners,line width=2pt,draw=red,fill=pink,text height=10pt,text depth=3pt,align=left,draw opacity = 0.75, fill opacity=.75,text opacity=1] (box-\theboxes) at #2 {#1};}
}
\newcommand\tikzmark[1]{%
\tikz[remember picture,overlay] \node (#1) {};}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[scale=0.2]{../images/H1D_level_5.pdf}};
\end{tikzpicture}
\end{frame}
\begin{frame}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (A) at (0,0) {\includegraphics[scale=0.2]{../images/H1D_level_5.pdf}};
\draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
\fill [draw=none, fill=white, fill opacity=0.3] (0,0.5) -- (A.north west) -- (A.north east) -- (A.south east) -- (0.5,0) -- (0.5,0.5) -- cycle;
\end{tikzpicture}
\end{frame}
\end{document}
Code:
Modified to generate the image above.
\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\newcommand\tikzmark[1]{\tikz[remember picture,overlay] \node (#1) {};}
\newcommand*{\Size}{2.5}%
\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[scale=0.1]{./images/EiffelWide.jpg}};
\end{tikzpicture}
%
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (A) at (0,0) {\includegraphics[scale=0.1]{./images/EiffelWide.jpg}};
\draw[red,ultra thick] (0.5\pgflinewidth,0.5\pgflinewidth) rectangle (\Size,\Size);
\fill [draw=none, fill=white, fill opacity=0.4]
(\pgflinewidth,\Size) --
(A.north west) -- (A.north east) -- (A.south east) --
(\Size,\pgflinewidth) -- (\Size,\Size) -- cycle;
\end{tikzpicture}
\end{document}
Best Answer
(This answer was migrated from the original question)
If I understood correctly the question, the following code may help to devise an appropiate solution:
Macro
\rowofmen{x}
produces a row of x men, allowing for fractional values of x (the trick is to draw one more man and clipping the resulting figure). Superimposing several of these rows with different colors and lenghts (as in the\rlap
example), you can simulate half-shaded men. This is the output:Note that each man was resized to 2mm x 3mm. You can alter this by changing the parameters
x=2mm,y=3mm
of thetikzpicture
and those of\resizebox
. The remaining can be left unchanged.