在 Tikz 中为 Cajón 吉他添加麦克风

在 Tikz 中为 Cajón 吉他添加麦克风

需要画一个如图所示的带麦克风的Cajón鼓,基本代码如下:

\documentclass{article}
\usepackage{tikz}
\usepackage{musixtex}

\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}

{\Huge \microphone}


\end{document}

当前的 期望的输出如下:

期望

答案1

稍微简化一下,使用perspective3dTiZ 库。第一个库设置视图(本例中为旋转的等距视图),第二个库有助于使用以下选项在与 xy、xz 或 yz 平面平行的平面上绘制

canvas is xy plane at z=0

例如。

我的建议是这样的:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{3d,perspective}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,
                    isometric view,rotate around z=185]
% Cajón
\draw[canvas is xy plane at z=0.05,rounded corners] (1,2) -| (2,1);
\draw[canvas is xz plane at y=0.05,rounded corners] (1,4) -| (2,1);
\draw[canvas is yz plane at x=0.05,rounded corners] (1,4) -| (2,1);
\draw[canvas is xy plane at z=4   ,rounded corners] (0.05,0.05) rectangle (1.95,1.95);
\draw[canvas is xz plane at y=2   ,rounded corners] (0.05,0.05) rectangle (1.95,3.95);
\draw[canvas is yz plane at x=2   ,rounded corners] (0.05,0.05) rectangle (1.95,3.95);
\draw[canvas is xz plane at y=2]                    (1,2.2) circle (0.4);
% Microphone
\begin{scope}[shift={(1,3.5,2.2)}]
\draw (0,0,0) circle (0.2cm); % sphere
\draw[canvas is xz plane at y=0] (-45:0.2) arc (-45:135:0.2); % equator
\draw[canvas is xz plane at y=0] (-45:0.2) arc (-45:135:0.2);
\pgfmathsetmacro\h{0.15}                % cylinder position
\pgfmathsetmacro\r{sqrt(0.2*0.2-\h*\h)} % cylinder radius
\foreach\i in {0,1}
{% some coordinates
   \begin{scope}[canvas is xz plane at y=\i+\h]
     \coordinate (A\i) at (-45:\r);
     \coordinate (B\i) at (135:\r);
   \end{scope}
}
% cylinder
\draw[canvas is xz plane at y=1+\h] (0,0) coordinate (P) circle (\r);
\draw[canvas is xz plane at y=\h,fill=white] (A0) arc (-45:135:\r) -- (B1) arc (135:-45:\r) -- cycle;
\draw[double] (P) to[out=-20,in=180] (0,2,-1); % wire
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容