[Tex/LaTex] Speedometer as a symbol into awesomebox

fontawesomepackagessymbolstikz-pgf

Actually I'm using awesomebox package to draw blocks around the text. Here there is an example.

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{awesomebox}
\usepackage{fontawesome5}
\usepackage{lipsum}

\begin{document}
\awesomebox[violet]{2pt}{\faRocket}{violet}{\lipsum[4]}
\end{document}

Into the guide there is written that: "The specific aim of this package is to use FontAwesome 5 icons to ease the illustration of these boxes."

Is there a font, a specific symbol that can to be inserted (instead of the fontawesome5 package symbols) to have three different types of speedometer without or with text like this image?

enter image description here

Best Answer

A simple pic with the "speed" as parameter may do.

\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[pics/speedometer/.style={code={
 \foreach \X/\Y [count=\Z] in {green!70!black/low,orange/medium,red/high}
  {\fill[fill=\X] (240-\Z*60:4) arc(240-\Z*60:180-\Z*60:4) -- 
    (180-\Z*60:3) arc(180-\Z*60:240-\Z*60:3) -- cycle;
   \path [decorate, decoration={text along path,
   text={|\color{white}\Huge\sffamily\bfseries|\Y}, text align=center}] 
    (240-\Z*60:3.2) arc(240-\Z*60:180-\Z*60:3.25);}
   \fill (180-#1+8:0.3) arc (180-#1+8:180-#1+344:0.3) -- (180-#1-0.5:3.25)
   -- (180-#1+0.5:3.25) --  cycle;
  }}]
  \path (0,0) pic{speedometer=45}
  (0,-5) pic{speedometer=80}
  (0,-10) pic{speedometer=160};
\end{tikzpicture}
\end{document}

enter image description here

An arguably more fancy version thereof is obtained when making the color transitions smooth. To this end we need to rotate and flip the color wheel that comes with the shadings library. This can be done using transform canvas, which has some side-effect, which is why the results get stored in a \savebox and then reused.

\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{decorations.text,shadings}
\newsavebox\ColorWheelRotated
\sbox\ColorWheelRotated{\begin{tikzpicture}
\clip (180:4) arc(180:0:4) -- (3,0) arc(0:180:3);
    \shade[shading=color wheel,transform canvas={
    rotate=-65,xscale=-1}] (0,0) circle [radius=4];
\end{tikzpicture}}
\begin{document}
\begin{tikzpicture}[pics/speedometer/.style={code={
 \path (0,0) node[above,inner sep=0pt] {\usebox\ColorWheelRotated};
 \foreach \X/\Y [count=\Z] in {green!70!black/low,orange/medium,red/high}
  {
   \path [decorate, decoration={text along path,
   text={|\color{white}\Huge\sffamily\bfseries|\Y}, text align=center}] 
    (240-\Z*60:3.2) arc(240-\Z*60:180-\Z*60:3.25);}
   \fill (180-#1+8:0.3) arc (180-#1+8:180-#1+344:0.3) -- (180-#1-0.5:3.25)
   -- (180-#1+0.5:3.25) --  cycle;
  }}]
  \path (0,0) pic{speedometer=45}
  (0,-5) pic{speedometer=80}
  (0,-10) pic{speedometer=160};
\end{tikzpicture}
\end{document}

enter image description here

In order to make this symbols you may want to kick out the texts.

\documentclass[a4paper,12pt]{article}
\usepackage{awesomebox}
\usepackage{lipsum}
\usepackage{tikz}
\tikzset{pics/speedometer/.style={code={
 \foreach \X/\Y [count=\Z] in {green!70!black/low,orange/medium,red/high}
  {\fill[fill=\X] (240-\Z*60:4) arc(240-\Z*60:180-\Z*60:4) -- 
    (180-\Z*60:3) arc(180-\Z*60:240-\Z*60:3) -- cycle;}
   \fill (180-#1+8:0.3) arc (180-#1+8:180-#1+344:0.3) -- (180-#1-0.5:3.25)
   -- (180-#1+0.5:3.25) --  cycle;
  }}}
\newsavebox\LowSpeed  
\newsavebox\MediumSpeed  
\newsavebox\HighSpeed  
\sbox\LowSpeed{\scalebox{0.1}{\tikz{\pic{speedometer=45};}}}
\sbox\MediumSpeed{\scalebox{0.1}{\tikz{\pic{speedometer=90};}}}
\sbox\HighSpeed{\scalebox{0.1}{\tikz{\pic{speedometer=135};}}}
\begin{document}
\awesomebox[violet]{2pt}{\usebox\LowSpeed}{violet}{\lipsum[4]}
\end{document}

enter image description here

Related Question