车速表作为符号放入 awesomebox

车速表作为符号放入 awesomebox

其实我正在使用很棒的盒子包在文本周围绘制块。这里有一个例子。

在此处输入图片描述

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

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

指南中写道:“该包的具体目的是使用 FontAwesome 5 图标来简化这些框的说明。

是否有一种字体,一种可以插入的特定符号(而不是fontawesome5包装符号),以便有三种不同类型的速度表,没有或有这样的文字图像

在此处输入图片描述

答案1

一张以“速度”作为参数的简单图片就可以了。

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

在此处输入图片描述

更奇特的版本是使颜色过渡平滑时获得的。为此,我们需要旋转和翻转库附带的色轮shadings。这可以使用 来完成transform canvas,这会产生一些副作用,这就是为什么结果存储在 中\savebox然后重复使用的原因。

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

在此处输入图片描述

为了制作这个符号,您可能需要删除文本。

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

在此处输入图片描述

答案2

我发现关联速度计也很不错。我做了一些小改动,以便与我最初的问题联系起来。

在此处输入图片描述

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

相关内容