使用 tikz 绘制 GPS 设备

使用 tikz 绘制 GPS 设备

有人有 tikz 示例代码吗,如何绘制形状和监视器(包括 GPS 按钮),例如像这样https://buy.garmin.com/en-US/US/p/63801

这是我根据 texample 中的各种示例得出的结论:

\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\begin{document}
\def\scl{0.6}%scaling factor of the picture

\begin{tikzpicture}[scale=\scl,
controlpanels/.style={lightgray!30!brown!20!,rounded corners,draw=black,thick}, screen/.style={ blue!50!black!60!,draw=black,thick},axes/.style={thick}]
%    outline of GPS
\draw [dotted, fill=gray] plot [cycle]
coordinates {(0,13) (11.5, 13) (11.5, -1) (5.75, -3.5)(0, -1) (0, 13)};
%     screen of GPS
\begin{scope}[xshift=5.7cm,yshift=8.5cm,samples=150]
\fill[black!60!,rounded corners,draw=black,thick](-5.3,-4.3)rectangle (5.3,4.3);
\fill[screen] (-5.0,-4.0) rectangle (5.0,4.0);
\draw[thin] (-5.0,-4.0) grid (5.0,4.0);
\draw[axes] (-5,0)--(5,0); % Time axis
\draw[axes] (0,-4)--(0,4);
\foreach \i in {-4.8,-4.6,...,4.8} \draw (\i,-0.1)--(\i,0.1);
\foreach \i in {-3.8,-3.6,...,3.8} \draw (-0.1,\i)--(0.1,\i);
\end{scope}

\begin{scope}  [xshift=0.5cm,yshift=-1.0cm]
\fill[controlpanels] (0,0) rectangle (10,5);

%  center button
\draw[thick] (5,2.5) circle (1.0);
\fill[blue!30!black!60!,draw=black,thick] (5,2.5) circle (0.8cm);

%spec button left
\fill[gray,draw=black,thick] (1,4) circle (0.5cm);
\fill[white,draw=black,thick] (1,4) circle (0.3cm);

\fill[gray,draw=black,thick] (1,2.5) circle (0.5cm);
\fill[white,draw=black,thick] (1,2.5) circle (0.3cm);

\fill[gray,draw=black,thick] (1.5,1) circle (0.5cm);
\fill[white,draw=black,thick] (1.5,1) circle (0.3cm);


%     %spec button right

\fill[gray,draw=black,thick] (9,4) circle (0.5cm);
\fill[white,draw=black,thick] (9,4) circle (0.3cm);


\fill[gray,draw=black,thick] (9,2.5) circle (0.5cm);
\fill[white,draw=black,thick] (9,2.5) circle (0.3cm);

\fill[gray,draw=black,thick] (8.5,1) circle (0.5cm);
\fill[white,draw=black,thick] (8.5,1) circle (0.3cm);

\end{scope}
\end{tikzpicture}
\end{document}

得到如下图表: 在此处输入图片描述

但在我看来,它还不像一个 GPS。我怀念

  • 光滑的轮廓
  • 也许是天线
  • 可能是屏幕上的一些内容

有什么想法或现有的代码可以使用吗?

谢谢

答案1

第 1 点和第 2 点比较容易实现。我只是plot [cycle]用正确的语法替换plot [smooth cycle,tension=0.2]并手工绘制了天线。第三点取决于你的想法。我只是遵循了@koleygr 的建议。

\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\begin{document}
\def\scl{0.6}%scaling factor of the picture

\begin{tikzpicture}[scale=\scl,
controlpanels/.style={lightgray!30!brown!20!,rounded corners,draw=black,thick}, screen/.style={ blue!50!black!60!,draw=black,thick},axes/.style={thick}]
\draw[fill=black] (10,13) -- (10,15) to[out=90,in=90] (10.5,15) -- (10.5,3);
%    outline of GPS
\draw [dotted, fill=gray] plot [smooth cycle,tension=0.2]
coordinates {(0,13) (11.5, 13) (11.5, -1) (5.75, -3.5)(0, -1)};
%     screen of GPS
\begin{scope}[xshift=5.7cm,yshift=8.5cm,samples=150]
\fill[black!60!,rounded corners,draw=black,thick](-5.3,-4.3)rectangle (5.3,4.3);
%\fill[screen] (-5.0,-4.0) rectangle (5.0,4.0);
\node at (0,0) {\includegraphics[width=6cm,height=5cm]{Bull_Run_Hydroelectric_Project.png}};
%https://en.wikipedia.org/wiki/Bull_Run_Hydroelectric_Project#/media/File:Bull_Run_Hydroelectric_Project.png
\draw[thin] (-5.0,-4.0) grid (5.0,4.0);
\draw[axes] (-5,0)--(5,0); % Time axis
\draw[axes] (0,-4)--(0,4);
\foreach \i in {-4.8,-4.6,...,4.8} \draw (\i,-0.1)--(\i,0.1);
\foreach \i in {-3.8,-3.6,...,3.8} \draw (-0.1,\i)--(0.1,\i);
\end{scope}

\begin{scope}  [xshift=0.5cm,yshift=-1.0cm]
\fill[controlpanels] (0,0) rectangle (10,5);

%  center button
\draw[thick] (5,2.5) circle (1.0);
\fill[blue!30!black!60!,draw=black,thick] (5,2.5) circle (0.8cm);

%spec button left
\fill[gray,draw=black,thick] (1,4) circle (0.5cm);
\fill[white,draw=black,thick] (1,4) circle (0.3cm);

\fill[gray,draw=black,thick] (1,2.5) circle (0.5cm);
\fill[white,draw=black,thick] (1,2.5) circle (0.3cm);

\fill[gray,draw=black,thick] (1.5,1) circle (0.5cm);
\fill[white,draw=black,thick] (1.5,1) circle (0.3cm);


%     %spec button right

\fill[gray,draw=black,thick] (9,4) circle (0.5cm);
\fill[white,draw=black,thick] (9,4) circle (0.3cm);


\fill[gray,draw=black,thick] (9,2.5) circle (0.5cm);
\fill[white,draw=black,thick] (9,2.5) circle (0.3cm);

\fill[gray,draw=black,thick] (8.5,1) circle (0.5cm);
\fill[white,draw=black,thick] (8.5,1) circle (0.3cm);

\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容