Graphics, Figures & TablesHow to Fill/Shade Image (ForEach, Tikz)

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

How to Fill/Shade Image (ForEach, Tikz)

Post by coachbennett1981 »

Good Evening,

Someone was kind enough to help me create the image that is attached. It is beyond anything I could probably do on my own. I have been looking all over Google trying to figure out if I can fill the individual polygons above the SPEED and FEED Circles. For example let's say I wanted to fill in (red) the fourth polygon above the speed and third polygon above the feed. Is this possible?

Code: Select all

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

You can see the bulls-eye, but I don't want that. I think it is cleaner just filling in a small portion. Any help would be appreciated. I am also trying to create this in Adobe Illustrator as well.

Many thanks,

Nicholas
Attachments
Screen Shot 2021-06-12 at 4.02.34 PM.png
Screen Shot 2021-06-12 at 4.02.34 PM.png (40.88 KiB) Viewed 4712 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

How to Fill/Shade Image (ForEach, Tikz)

Post by Bartman »

I hope I have understood you correctly and that my proposed solution is not too complicated.

Code: Select all

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

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

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

\newcommand{\cond}[1]{(\cj==15-#1 ? "my red" : "my gray")}

\begin{document}
\begin{tikzpicture}[
  line join=round,
  line cap=round,
  conditional color/.code 2 args={% key handler with two arguments added
    \pgfmathparse{\i==0 ? \cond{#1} : \cond{#2}}
    \pgfkeysalso{\pgfmathresult}
  }
]
% circles and rectangles
\foreach\i in {0,-8}
{
  \filldraw[my gray] (0,\i) circle (2cm);
  \foreach\j [count=\cj] in {-33.5,-14.5,...,213.5}
  {
    % use key handler
    \draw [conditional color={4}{3},shift={(0,\i)},rotate=\j]
      (2.4,-0.2) -- (2.9,-0.25) -- (2.9,0.25) -- (2.4,0.2) -- cycle
    ;
  }
}
\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
\begin{scope}[font=\bfseries]
\node at (0,-3)  [my text]          {SPEED};
\node at (0,-11) [my text]          {FEED};
\node at (0,-13) [blue!50,scale=5]  {15};
\node at (0,-15) [my text]          {ANGLE};
\end{scope}

\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,font=\bfseries]{Slinger};
\node at (3.7,6)                                    {\textregistered};
\fill[white] 
    (-2.7,4.71) rectangle (-0.5,4.957)
    (0.8,4.71) rectangle  (2  ,4.957)
    (2.7,4.71) rectangle  (3.5  ,4.957)
;
\fill[yellow!70!green] (3.5,4.83) circle (0.15cm);
\end{tikzpicture}
\end{document}
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

How to Fill/Shade Image (ForEach, Tikz)

Post by coachbennett1981 »

Looks amazing. Thank you for taking time to answer this
Post Reply