绘制飞机机身

绘制飞机机身

我有这张图片...

机身

我想在 LaTeX 中复制这个,但也要在一个窗口中显示尺寸。像这样...

绘画

我怎样才能使用 TiKZ 做到这一点,同时又能保持图像中实际飞机的感觉和形状,并添加尺寸?

“用 Tikz 画一架飞机”问题并没有回答这个问题。

答案1

画这些东西很容易,就是有点乏味。以后我恳请您提供一些代码,至少定义一下颜色、设置一下尺寸等等,这样其他人就不必从头开始。

\documentclass[tikz,border=3mm]{standalone}
\definecolor{wt}{RGB}{210,215,219} % frame top
\definecolor{wb}{RGB}{151,154,162} % frame bottom
\definecolor{w}{RGB}{49,66,89}     % window
\definecolor{pt}{RGB}{242,242,242} % plane top
\definecolor{pb}{RGB}{208,209,213} % plane bottom
\definecolor{wf}{RGB}{85,96,110}   % inner frame
\definecolor{blind}{RGB}{115,119,128}      % blind
\begin{document}
\begin{tikzpicture}[>=latex,pics/fuselage/.style={code={
        \tikzset{fuselage/.cd,#1}%
        \def\pv##1{\pgfkeysvalueof{/tikz/fuselage/##1}}%
        \fill[w,rounded corners=\pv{r}-\pv{d}]
            (-\pv{w}/2+\pv{d},-\pv{h}/2+\pv{d}) rectangle (\pv{w}/2-\pv{d},\pv{h}/2-\pv{d});
        \clip [rounded corners=\pv{r}]
            (-\pv{w}/2,-\pv{h}/2) rectangle (\pv{w}/2,\pv{h}/2);    
        \fill[blind] (-\pv{w}/2,\pv{h}/2-\pv{b}) rectangle (\pv{w}/2,\pv{h}/2);
        \fill[wf,xshift=1.3pt,yshift=-1.3pt,even odd rule]
            [rounded corners=\pv{r}]
            (-\pv{w}/2,-\pv{h}/2) rectangle (\pv{w}/2,\pv{h}/2)
            [rounded corners=\pv{r}-\pv{d}]
            (-\pv{w}/2+\pv{d},-\pv{h}/2+\pv{d}) rectangle (\pv{w}/2-\pv{d},\pv{h}/2-\pv{d});            
        \draw[top color=wt,bottom color=wb,even odd rule] 
            [rounded corners=\pv{r}]
            (-\pv{w}/2,-\pv{h}/2) rectangle (\pv{w}/2,\pv{h}/2)
            [rounded corners=\pv{r}-\pv{d}]
            (-\pv{w}/2+\pv{d},-\pv{h}/2+\pv{d}) rectangle (\pv{w}/2-\pv{d},\pv{h}/2-\pv{d});            
}},fuselage/.cd,h/.initial=1.4cm,w/.initial=1cm,
    d/.initial=0.7mm,r/.initial=4mm,b/.initial=2mm]
 \path[top color=pt,bottom color=pb] (-4,-3) rectangle (4,3);
 \path foreach \X in {0,...,3} {(-3+2*\X,0.5) pic{fuselage}};
 \draw[|<->|] (1-0.425,0.5) -- (1+0.425,0.5) node[pos=0.75,above]{$a$};
 \draw[|<->|] (1,0.5-0.625) -- (1,0.5+0.625) node[pos=0.75,left]{$b$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

附录:每请求一个带乘客的版本。(这些不一定是动物,在 TiZlings 那里有一个雪人和三个生物。)

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikzlings}
\definecolor{wt}{RGB}{210,215,219} % frame top
\definecolor{wb}{RGB}{151,154,162} % frame bottom
\definecolor{w}{RGB}{49,66,89}     % window
\definecolor{pt}{RGB}{242,242,242} % plane top
\definecolor{pb}{RGB}{208,209,213} % plane bottom
\definecolor{wf}{RGB}{85,96,110}   % inner frame
\definecolor{blind}{RGB}{115,119,128}      % blind
\begin{document}
\begin{tikzpicture}[>=latex,pics/fuselage/.style={code={
        \tikzset{fuselage/.cd,#1}%
        \def\pv##1{\pgfkeysvalueof{/tikz/fuselage/##1}}%
        \fill[w,rounded corners=\pv{r}-\pv{d}]
            (-\pv{w}/2+\pv{d},-\pv{h}/2+\pv{d}) rectangle (\pv{w}/2-\pv{d},\pv{h}/2-\pv{d});
        \clip [rounded corners=\pv{r}]
            (-\pv{w}/2,-\pv{h}/2) rectangle (\pv{w}/2,\pv{h}/2);    
        \fill[blind] (-\pv{w}/2,\pv{h}/2-\pv{b}) rectangle (\pv{w}/2,\pv{h}/2);
        \tikzling[scale=0.6,yshift=-2cm]    
        \fill[wf,xshift=1.3pt,yshift=-1.3pt,even odd rule]
            [rounded corners=\pv{r}]
            (-\pv{w}/2,-\pv{h}/2) rectangle (\pv{w}/2,\pv{h}/2)
            [rounded corners=\pv{r}-\pv{d}]
            (-\pv{w}/2+\pv{d},-\pv{h}/2+\pv{d}) rectangle (\pv{w}/2-\pv{d},\pv{h}/2-\pv{d});            
        \draw[top color=wt,bottom color=wb,even odd rule] 
            [rounded corners=\pv{r}]
            (-\pv{w}/2,-\pv{h}/2) rectangle (\pv{w}/2,\pv{h}/2)
            [rounded corners=\pv{r}-\pv{d}]
            (-\pv{w}/2+\pv{d},-\pv{h}/2+\pv{d}) rectangle (\pv{w}/2-\pv{d},\pv{h}/2-\pv{d});            
}},fuselage/.cd,h/.initial=1.4cm,w/.initial=1cm,
    d/.initial=0.7mm,r/.initial=4mm,b/.initial=3mm]
 \path[top color=pt,bottom color=pb] (-4,-3) rectangle (4,3);
 \path foreach \X in {0,...,3} {(-3+2*\X,0.5) pic{fuselage}};
\end{tikzpicture}
\end{document}

在此处输入图片描述

这些是随机选择的 TiZlings,每次编译时您都会得到一个随机集。如果您不喜欢这种随机性,请使用\pgfmathsetseed{<int>}整数int

相关内容