[Tex/LaTex] Removing part of a symbol or image

graphicstikz-pgf

Tidying up and posing a secondary question which was answered

I'm trying to put together a visual aid of people numbers in a particular area, so I imagine using something like. Answered elsewhere using the marvosym package with \Gentsroom as the symbol.

Man image

Is there an easy way to shade out half the image e.g. If I'm using each figure to represent four people and I want to indicate 2 by using half a figure?

Link to earlier question below
Question on human shape in tikz

Note: The title is terrible but all I can think of. Please feel free to edit it.

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:

\documentclass{article}
\usepackage{tikz}
\usepackage[margin=2mm]{geometry}
\usepackage{marvosym}
\usepackage{graphicx}
\def\rowofmen#1{%
\begin{tikzpicture}[x=2mm,y=3mm]
\path[clip] (0,0) rectangle (#1,1.1);
\pgfmathparse{ceil(#1)}
\foreach \i in {0,...,\pgfmathresult} {
\node[inner sep=0pt, above right] at (\i, 0) 
   {\resizebox{2mm}{3mm}{\Gentsroom}};
  }
\end{tikzpicture}
}

\begin{document}
\noindent%
\textcolor{gray}{\rowofmen{5}}\\
\textcolor{black!.3!blue}{\rowofmen{3.5}}\\
\rlap{\textcolor{red}{\rowofmen{5}}}%
\rlap{\textcolor{blue}{\rowofmen{3.7}}}%
\rlap{\textcolor{green}{\rowofmen{2.5}}}%
\\    
\end{document}

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:

Output

Note that each man was resized to 2mm x 3mm. You can alter this by changing the parameters x=2mm,y=3mm of the tikzpicture and those of \resizebox. The remaining can be left unchanged.