16

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

Sebastiano
  • 54,118

2 Answers2

24

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

  • 1
    Thank you very much. But can I put one of the three speedometer instead of \faRocket? – Sebastiano Sep 12 '19 at 21:30
  • 3
    @Sebastiano Whether or not this will yield a useful symbol that has a size that is comparable to an ordinary character I do not know because of the texts that you embed. Once you scale it down, the texts will be pretty much unreadable. If you leave the texts "low" etc. out this may become useful symbols. I added a proposal. –  Sep 12 '19 at 21:31
  • This is very nice, many thanks! Do you know if it is possile to specify the colors in the example with shading? At the moment, the colors you specify with green!70!black/low,orange/medium,red/high do not have any effect. – Rastapopoulos May 16 '22 at 15:07
2

I have found on this link a very nice speedometer too. I made a few small changes to associate it with my initial question.

enter image description here

\documentclass[border=1cm]{standalone}
\usepackage{newtxtext}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}

\begin{tikzpicture}[font=\small]
% Static part
\draw[draw=white,fill=red,thick] (0:2) -- (0:3.5) arc(0:45:3.5) -- (45:2) arc(45:0:2) -- cycle ;
\draw[draw=white,fill=red!30,thick] (90:2cm)-- (90:3.5cm) arc (90:45:3.5) -- (45:2cm) arc (45:90:2);
\draw[draw=white,fill=orange!30,thick] (135:2cm)-- (135:3.5cm) arc (135:90:3.5) -- (90:2cm) arc (90:135:2);
\draw[draw=white,fill=yellow!20,thick] (135:2cm)-- (135:3.5cm) arc (135:180:3.5) -- (180:2cm) arc (180:135:2);


%Labels
\draw[decoration={text along path,
      text={LOW},text align={center},raise=0.2cm},decorate] (180:3.5cm) arc (180:135:3.5); 

\draw[decoration={text along path,
      text={MEDIUM},text align={center},raise=0.2cm},decorate] (135:3.5cm) arc (135:90:3.5);

\draw[decoration={text along path,
      text={HIGH},text align={center},raise=0.2cm},decorate] (90:3.5cm) arc (90:45:3.5);

\draw[decoration={text along path,
      text={CRITICAL},text align={center},raise=0.2cm},decorate] (45:3.5cm) arc (45:0:3.5);


% Speedometer needle
\fill[black!70,rotate=40] (0,0.2)--(0:2.75) -- (0,-0.2)--cycle;
\fill [black!70](0,0) circle (0.4cm);
\fill [white](0,0) circle (0.15cm);
\end{tikzpicture}
\end{document}
Sebastiano
  • 54,118