Tikz 图像帮助(重新创建图像)

Tikz 图像帮助(重新创建图像)

我正在尝试在 Tikz 中创建所附图像。我不想包含靶心,因为我将使用填充来获得所需的结果。我在处理圆上方较小的多边形时遇到了麻烦。我在处理底部的最后一个矩形时也遇到了麻烦。

\documentclass{article}
\usepackage{tikz}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{tikzpicture}
    % draw the sets
    \filldraw[fill=gray!20, draw=blue!60] (0,0) circle (2cm);
\node at (0,-3)[anchor=south]{\Large{\textbf{Speed}}};
\filldraw[fill=gray!20, draw=blue!60] (0,-6) circle (2cm);
\node at (0,-9)[anchor=south]{\Large{\textbf{Feed}}};
\draw[dotted,thick] (-1,-11)--(1,-11);
\node at (0,-12)[anchor=south]{\Large{\textbf{Angle}}};
\node at (1,-10)[anchor= west]{$\circ$};
\filldraw[fill=gray!20,shift = {(-2, -13)}] rectangle (5,1);

\end{tikzpicture}
\end{document}

任何帮助都将不胜感激。我是 tikz 的初学者,所以我的代码可能不是最有效的在此处输入图片描述

答案1

在圆圈上方绘制多边形的最佳方法是使用\foreach在每次迭代中旋转轴的命令。

这是一个简单的例子。字体不一样,但我想你应该能明白。

\documentclass[border=2mm]{standalone}
\usepackage{newpxtext} % Palatino font (text)
\usepackage{newpxmath} % Palatino font (math)
\usepackage{siunitx}   % for \ang command
\usepackage{tikz}      % beautiful drawings

% sans serif font
\renewcommand\familydefault{\sfdefault}

% styles
\tikzset%
{%
  my gray/.style={fill=gray!20, draw=blue!60},
  my text/.style={black!70,scale=4}
}


\begin{document}
\begin{tikzpicture}[line join=round,line cap=round]
% circles and rectangles
\foreach\i in {0,-8}
{%
  \filldraw[my gray] (0,\i) circle (2cm);
  \foreach\j in {-33.5,-14.5,...,213.5}
  {%
    \begin{scope}[shift={(0,\i)},rotate=\j]
      \draw[my gray] (2.4,-0.2) -- (2.9,-0.25) -- (2.9,0.25) -- (2.4,0.2) -- cycle;
    \end{scope}
  }
}
\draw[my gray] (-3,   -18)  rectangle (3,-16);
\draw[thick]   ( 1.25,-12.75) circle  (0.1cm);
\draw[dotted,thick] (-1,-13.75) -- (1,-13.75);
% labels
\node at (0,-3)  [my text]          {\bfseries SPEED};
\node at (0,-11) [my text]          {\bfseries FEED};
\node at (0,-13) [blue!50,scale=5]  {\bfseries 15};
\node at (0,-15) [my text]          {\bfseries ANGLE};
\draw[thick] (-2,-17) node [left]   {\ang{0}} -- (2,-17) node [right] {\ang{40}};
\foreach\i in {-1,0,1}
{%
  \pgfmathtruncatemacro\j{10*\i+20} % displayed angle
  \node at (\i,-17) [above] {\ang{\j}};
}
% logo
\node at (0  ,5)  [my text,scale=1.5]{\bfseries Slinger};
\node at (3.7,6)                     {\textregistered};
\fill[white] (-2.7,4.71) rectangle (-0.5,4.957);
\fill[white]  (0.8,4.71) rectangle  (2  ,4.957);
\fill[white]  (2.7,4.71) rectangle  (4  ,4.957);
\fill[yellow!70!green] (3.5,4.83) circle (0.15cm);
\end{tikzpicture}
\end{document}

编辑:根据 OP 的评论,我添加了一个宏来绘制圆圈、圆圈周围的多边形及其标签。还提供了用不同颜色填充其中一个多边形的可能性。

\documentclass[border=2mm]{standalone}
\usepackage{newpxtext} % Palatino font
\usepackage{siunitx}   % for \ang command
\usepackage{tikz}      % beautiful drawings

% sans serif font
\renewcommand\familydefault{\sfdefault}

% styles
\tikzset%
{%
  my gray/.style={fill=gray!20, draw=blue!60},
  my  red/.style={fill=red!80,  draw=blue!60},
  my text/.style={black!70,scale=4}
}

\newcommand{\mycircle}[3]% position, label, red polygon position
{%
  \begin{scope}[shift={#1}]
    \draw[my gray] (0,0) circle (2cm);
    \foreach[count=\j]\i in {-33.5,-14.5,...,213.5}
    {%
      \begin{scope}[rotate=\i]
        \ifnum #3 = \j
          \draw[my red]  (2.4,-0.2) -- (2.9,-0.25) -- (2.9,0.25) -- (2.4,0.2) -- cycle;
        \else
          \draw[my gray] (2.4,-0.2) -- (2.9,-0.25) -- (2.9,0.25) -- (2.4,0.2) -- cycle;
        \fi
      \end{scope}
    }
    \node at (0,-3) [my text] {\bfseries #2};
  \end{scope}
}

\begin{document}
\begin{tikzpicture}[line join=round,line cap=round]
% circles and rectangle
\mycircle{(0, 0)}{SPEED}{3}
\mycircle{(0,-8)}{FEED} {4}
\draw[my gray] (-3,   -18)  rectangle (3,-16);
\draw[thick]   ( 1.25,-12.75) circle  (0.1cm);
\draw[dotted,thick] (-1,-13.75) -- (1,-13.75);
% labels
\node at (0,-13) [cyan!50,scale=5] {15};
\node at (0,-15) [my text]         {\bfseries ANGLE};
\draw[thick] (-2,-17) node [left,scale=1.5] {\ang{0}} -- (2,-17) node [right,scale=1.5] {\ang{40}};
\foreach\i in {-1,0,1}
{%
  \pgfmathtruncatemacro\j{10*\i+20} % displayed angle
  \node at (\i,-17) [above] {\ang{\j}};
}
% logo
\node at (0  ,5) [my text,scale=1.5] {\bfseries Slinger};
\node at (3.8,6)                     {\textregistered};
\def\minh{4.71}
\def\maxh{4.958}
\fill[white] (-2.7,\minh) rectangle (-0.5,\maxh);
\fill[white]  (0.8,\minh) rectangle  (2  ,\maxh);
\fill[white]  (2.7,\minh) rectangle  (4  ,\maxh);
\fill[yellow!70!green] (3.5,0.5*\minh+0.5*\maxh) circle (0.15cm);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容