-1

Can anyone help me create a microphone shape like the below figure using tikz?

enter image description here

I know some basics of creating shapes using \pic but I cannot figure out this. I want the white areas to be transparent (empty). Thanks

Yasi
  • 133

1 Answers1

18

If you would like to do it with TikZ:

\documentclass{article}
\usepackage{tikz}

\newcommand{\microphone}{%
    \tikz{
        \begin{scope}
            \clip (-.3em,-.4ex) rectangle (1.3em,1.5ex);
            \fill[black, rounded corners=1.5ex] (-.3em,-.4ex) rectangle (1.3em,5.5ex);
        \end{scope}
        \fill[white, rounded corners=1.3ex] (-.1em,0) rectangle (1.1em,5.1ex);
        \fill[black, rounded corners=1.1ex] (0,.2ex) rectangle (1em,5ex);
        \foreach \pos in {2.5ex, 2.9ex, 3.3ex, 3.7ex}
            \fill[white, rounded corners=.1ex] (.35em,\pos) rectangle +(.8em,.25ex);
        \fill[black] (.4em,-.4ex) rectangle (.6em,-1.5ex);
        \fill[black] (0,-1.5ex) rectangle (1em,-2ex);
    }%
}


\begin{document}
{\small This is small \microphone}

This is normal \microphone

{\large This is large \microphone}

{\Huge This is Huge \microphone}
\end{document}

enter image description here

Edit: As requested by the OP, the following is the version with the white regions transparent. I've created a pic which can be used both in a macro and in a tikzpicture.

\documentclass{article}
\usepackage{tikz}
\tikzset{
    pics/microph/.style={code={ 
        \draw[black, line width=.2em, rounded corners=1.7ex] 
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex) -- (.85em,4.5ex);
        \fill[black] 
            (-.6em,5ex) to[rounded corners=1.2ex]  
            (-.6em,2.5ex) to[rounded corners=1.2ex] (.6em,2.5ex)
            -- (.6em,5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)  
            -- (.6em,5.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            to[rounded corners=1.2ex]
            (.6em,8ex) to[rounded corners=1.2ex]
            (-.6em,8ex) to cycle; 
        \fill[black] (-.1em,1.8ex) rectangle (.1em,.5ex);
        \fill[black] (-.5em,.5ex) rectangle (.5em,0);
    }},
}

\newcommand{\microphone}{\tikz{\pic {microph};}}

\begin{document}
{\small This is small \microphone}
This is normal \microphone
{\large This is large \microphone}

{\Huge This is Huge \microphone}

And this is to show the transparency:
\begin{tikzpicture}
    \fill[red] (-.5,0) rectangle (.5,1.5);
    \pic {microph};
\end{tikzpicture}
\begin{tikzpicture}
    \fill[green] (-.5,0) rectangle (.5,1.5);
    \pic {microph};
\end{tikzpicture}
\begin{tikzpicture}
    \fill[cyan] (-.5,0) rectangle (.5,1.5);
    \pic {microph};
\end{tikzpicture}
\end{document}

enter image description here

CarLaTeX
  • 62,716