使用 TikZ 绘制大小可变的汽车

使用 TikZ 绘制大小可变的汽车

我发现这辆漂亮的车这里

    \documentclass{article}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}
    \shade[top color=red, bottom color=white, shading angle={135}]
        [draw=black,fill=red!20,rounded corners=1.2ex,very thick] (1.5,.5) -- ++(0,1) -- ++(1,0.3) --  ++(3,0) -- ++(1,0) -- ++(0,-1.3) -- (1.5,.5) -- cycle;
    \draw[very thick, rounded corners=0.5ex,fill=black!20!blue!20!white,thick]  (2.5,1.8) -- ++(1,0.7) -- ++(1.6,0) -- ++(0.6,-0.7) -- (2.5,1.8);
    \draw[thick]  (4.2,1.8) -- (4.2,2.5);
    \draw[draw=black,fill=gray!50,thick] (2.75,.5) circle (.5);
    \draw[draw=black,fill=gray!50,thick] (5.5,.5) circle (.5);
    \draw[draw=black,fill=gray!80,semithick] (2.75,.5) circle (.4);
    \draw[draw=black,fill=gray!80,semithick] (5.5,.5) circle (.4);

    \draw[->,semithick] (0,-.5) -- (0,3);
    \draw (0,3.5) node {$r[x(t)]$};
    \draw[->,semithick] (-.5,0) -- (8,0);
    \draw (8.5,0) node {$x(t)$};
\end{tikzpicture}
\end{document}

有什么办法可以让这辆车变小吗?我不明白这些数字是什么: (1.5,.5) -- ++(0,1) -- ++(1,0.3) -- ++(3,0) -- ++(1,0) -- ++(0,-1.3) -- (1.5,.5) -- cycle 和 (2.5,1.8) -- ++(1,0.7) -- ++(1.6,0) -- ++(0.6,-0.7) -- (2.5,1.8);

在此处输入图片描述

答案1

缩放图片某一部分的最简单方法是将其放入scope环境中。

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \shade[top color=red, bottom color=white, shading angle={135}]
  [draw=black,fill=red!20,rounded corners=1.2ex,very thick] (1.5,.5) -- ++(0,1) -- ++(1,0.3) --  ++(3,0) -- ++(1,0) -- ++(0,-1.3) -- (1.5,.5) -- cycle;
  \draw[very thick, rounded corners=0.5ex,fill=black!20!blue!20!white,thick]  (2.5,1.8) -- ++(1,0.7) -- ++(1.6,0) -- ++(0.6,-0.7) -- (2.5,1.8);
  \draw[thick]  (4.2,1.8) -- (4.2,2.5);
  \draw[draw=black,fill=gray!50,thick] (2.75,.5) circle (.5);
  \draw[draw=black,fill=gray!50,thick] (5.5,.5) circle (.5);
  \draw[draw=black,fill=gray!80,semithick] (2.75,.5) circle (.4);
  \draw[draw=black,fill=gray!80,semithick] (5.5,.5) circle (.4);

  \draw[->,semithick] (0,-.5) -- (0,3);
  \draw (0,3.5) node {$r[x(t)]$};
  \draw[->,semithick] (-.5,0) -- (8,0);
  \draw (8.5,0) node {$x(t)$};
\end{tikzpicture}

\begin{tikzpicture}
  \begin{scope}[scale=0.5]
    \shade[top color=red, bottom color=white, shading angle={135}]
    [draw=black,fill=red!20,rounded corners=1.2ex,very thick] (1.5,.5) -- ++(0,1) -- ++(1,0.3) --  ++(3,0) -- ++(1,0) -- ++(0,-1.3) -- (1.5,.5) -- cycle;
    \draw[very thick, rounded corners=0.5ex,fill=black!20!blue!20!white,thick]  (2.5,1.8) -- ++(1,0.7) -- ++(1.6,0) -- ++(0.6,-0.7) -- (2.5,1.8);
    \draw[thick]  (4.2,1.8) -- (4.2,2.5);
    \draw[draw=black,fill=gray!50,thick] (2.75,.5) circle (.5);
    \draw[draw=black,fill=gray!50,thick] (5.5,.5) circle (.5);
    \draw[draw=black,fill=gray!80,semithick] (2.75,.5) circle (.4);
    \draw[draw=black,fill=gray!80,semithick] (5.5,.5) circle (.4);
  \end{scope}

  \draw[->,semithick] (0,-.5) -- (0,3);
  \draw (0,3.5) node {$r[x(t)]$};
  \draw[->,semithick] (-.5,0) -- (8,0);
  \draw (8.5,0) node {$x(t)$};
\end{tikzpicture}

\begin{tikzpicture}
  \begin{scope}[xscale=0.5,yscale=1.2,xshift=5cm]
    \shade[top color=red, bottom color=white, shading angle={135}]
    [draw=black,fill=red!20,rounded corners=1.2ex,very thick] (1.5,.5) -- ++(0,1) -- ++(1,0.3) --  ++(3,0) -- ++(1,0) -- ++(0,-1.3) -- (1.5,.5) -- cycle;
    \draw[very thick, rounded corners=0.5ex,fill=black!20!blue!20!white,thick]  (2.5,1.8) -- ++(1,0.7) -- ++(1.6,0) -- ++(0.6,-0.7) -- (2.5,1.8);
    \draw[thick]  (4.2,1.8) -- (4.2,2.5);
    \draw[draw=black,fill=gray!50,thick] (2.75,.5) circle (.5);
    \draw[draw=black,fill=gray!50,thick] (5.5,.5) circle (.5);
    \draw[draw=black,fill=gray!80,semithick] (2.75,.5) circle (.4);
    \draw[draw=black,fill=gray!80,semithick] (5.5,.5) circle (.4);
  \end{scope}

  \draw[->,semithick] (0,-.5) -- (0,3);
  \draw (0,3.5) node {$r[x(t)]$};
  \draw[->,semithick] (-.5,0) -- (8,0);
  \draw (8.5,0) node {$x(t)$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容