tikz 中的麦克风

tikz 中的麦克风

有人能帮我用 tikz 创建如下图所示的麦克风形状吗?

在此处输入图片描述

我知道使用 \pic 创建形状的一些基础知识,但我搞不懂这一点。我希望白色区域是透明的(空的)。谢谢

答案1

如果你想用 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}

在此处输入图片描述

编辑: 根据 OP 的要求,以下是白色区域透明的版本。我创建了一个pic既可以在宏中使用,也可以在 中使用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}

在此处输入图片描述

相关内容