我怎样才能绘制类似脉冲的装饰?

我怎样才能绘制类似脉冲的装饰?

我有一张 ppt 风格的旧图片,我想对它进行一些自定义。主要问题是我是 Tikz/PGF 的初学者,我真的不知道从哪里开始以及应该使用哪些环境。

如果有人能帮助我以一种好的方式开始。在此处输入图片描述

答案1

好吧,今天显然每个人都起错了,所以总得有人借此发泄一下坏心情。

但请注意,如果没有具体的例子,建议就不适合我们的问答网站,因为它太具体了,无法满足您的需求。如果您希望快速讨论,也可以使用聊天室。我们的问题倾向于对某些方面直奔主题,但评论较少。

无论如何,这里有一些初步要点,以便您可以开始装饰它们或更改颜色等。这取决于您拿起手册并开始进行操作 :)

\documentclass[tikz]{standalone}
\pgfdeclaredecoration{single pulse}{initial}{
\state{initial}[width=\pgfdecoratedinputsegmentlength]
{%
    \pgfpathlineto{\pgfpoint{0.2*\pgfdecoratedinputsegmentlength}{0mm}}%    
    \pgfpathsine{\pgfpoint{0.15\pgfdecorationsegmentlength}{\pgfdecorationsegmentamplitude}}%
    \pgfpathcosine{\pgfpoint{0.15\pgfdecorationsegmentlength}{-\pgfdecorationsegmentamplitude}}%
    \pgfpathsine{\pgfpoint{0.15\pgfdecorationsegmentlength}{-\pgfdecorationsegmentamplitude}}
    \pgfpathcosine{\pgfpoint{0.15\pgfdecorationsegmentlength}{\pgfdecorationsegmentamplitude}}%
    \pgfpathlineto{\pgfpointdecoratedinputsegmentlast}%
}
\state{final}{}%
}
\begin{document}
\begin{tikzpicture}[mydeco/.style={decoration={single pulse,amplitude=4mm,segment length=2mm},decorate}]
\foreach\x in{0,1,2}{
\draw[mydeco] (0,-\x) -- (1,-\x);
\draw[mydeco] (2+0.25*\x,-\x) -- (3+0.25*\x,-\x);
\draw[mydeco] (4+0.5*\x,-\x) -- (5+0.5*\x,-\x);
}
\draw[dashed,blue] \foreach \x in {0,2,4}{(\x,0) -- (\x,-2.2)};
\draw[red,dashed] \foreach \x in {2.25,4.5}{(\x,-1) -- (\x,-2.2)};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

你可能还想了解元帖子,这是 John Hobby 和 DE Knuth 设计的图形语言。这里有两个小函数,它们可以绘制脉冲形状和图片所需的下括号。其余的只是线条和标签,如手册

在此处输入图片描述

prologues := 3;
outputtemplate := "%j%c.eps";

vardef pulse(expr s) = 
    save x, y, pulse; path pulse; 
    z1 = left; z2 = z1/4; x3 = x2/2; y3 = 1;
    pulse = z1 .. subpath (0.2,0.6) of (z1--z2) .. controls z2 and z2
               .. subpath (0.2,0.6) of (z2--z3) .. controls z3 and z3 .. origin;
    (pulse .. reverse pulse rotated 180) scaled 1/2s
enddef;

vardef down_brace(expr s) = 
    save arm; path arm;
    arm = (-1,1/4) {down} .. {right} (-7/8,1/8) -- (-1/8,1/8) {right} .. {down} origin;
    (arm .. reverse arm reflectedabout(up,down)) scaled 1/2s
enddef;

beginfig(1);
  draw pulse(1cm)                       withcolor .78 blue; 
  draw down_brace(1cm) shifted (0,-7mm) withcolor .56 red;
endfig;
end.

由于函数返回 a path,因此您可以像这样将它们连接在一起:

draw pulse(1cm) -- pulse(1cm) shifted (2cm,0) -- pulse(1cm) shifted (4cm,0) withcolor .7 white;

来生产这个。

在此处输入图片描述

for如果愿意,您也可以使用 MP 的“内联”循环之一来执行此操作:

draw pulse(1cm) for i=1,2: -- pulse(1cm) shifted (i*2cm,0) endfor withcolor .7 white;

答案3

所以,这就是我目前所做的:

\begin{tikzpicture}[mydeco/.style={decoration={single pulse,amplitude=7mm,segment     length=3mm},decorate}]
\foreach\x in{0,2,4}{
\draw[mydeco] (0,-\x) -- (0.6,-\x);
\draw[mydeco] (2+0.15*\x,-\x) -- (2.6+0.15*\x,-\x);
\draw[mydeco] (4+0.30*\x,-\x) -- (4.6+0.30*\x,-\x);
}
\draw[dotted,gray] \foreach \x in {0,2,4}{(0, -\x) -- (5+0.3*4, -\x)};  
\draw[dashed,blue] \foreach \x in {2,4}{(\x,0) -- (\x,-1.1)};
\draw[dashed,red] \foreach \x in {2.3,4.6}{(\x,-2) -- (\x,-3.1)};
\draw[dashed,green] \foreach \x in {2.6,5.2}{(\x,-4) -- (\x,-5.1)};
\draw[dashed,black,thick] (0,1) node[above] {$t_0$} -- (0,-5.2) ;

\draw[blue,<->,thick] (0.05,-0.8) -- (2-0.05,-0.8) node [below,align=center,midway]    {$T$};
\draw[blue,<->,thick] (2+0.05,-0.8) -- (4-0.05,-0.8) node [below,align=center,midway] {$T$};
\draw[red,<->,thick] (0.05,-2.8) -- (2.3-0.05,-2.8) node [below,align=center,midway] {$T+t_1$};
\draw[red,<->,thick] (2.3+0.05,-2.8) -- (4.6-0.05,-2.8) node [below,align=center,midway] {$T+t_1$};
\draw[green,<->,thick] (0.05,-4.8) -- (2.6-0.05,-4.8) node [below,align=center,midway] {$T+2*t_1$};
\draw[green,<->,thick] (2.6+0.05,-4.8) -- (5.2-0.05,-4.8) node [below,align=center,midway] {$T+2*t_1$};

\draw [fill=blue!20,draw=blue,thick] (-0.3,0) -- (-1.0,0.5) arc (90:270:.20) -- (-0.3,0) -- (-1,-0.04) arc (90:270:.20) -- cycle node[above,inner sep=22pt, midway] {\tiny{Antenna 1}};
\draw [fill=red!20,draw=red,thick] (-0.3,-2) -- (-1.0,-2+0.5) arc (90:270:.20) -- (-0.3,-2) -- (-1,-0.04-2) arc (90:270:.20) -- cycle node[above,inner sep=22pt, midway] {\tiny{Antenna 2}};
\draw [fill=green!20,draw=green,thick] (-0.3,-4) -- (-1.0,-4+0.5) arc (90:270:.20) -- (-0.3,-4) -- (-1,-0.04-4) arc (90:270:.20) -- cycle node[above,inner sep=22pt, midway] {\tiny{Antenna 3}};

\draw[decorate,decoration={brace,mirror},thick] (0,-5.3) -- (0.6,-5.3)    node[below,midway] {{\tiny Tir dans l'axe}};
\draw[decorate,decoration={brace,mirror},thick] (2.2,-5.3) -- (2.6+0.6,-5.3) node[below,midway] {{\tiny Dépointage $\Theta_A$}};
\draw[decorate,decoration={brace,mirror},thick] (4.4,-5.3) -- (5.2+0.6,-5.3) node[below,midway] {{\tiny Dépointage $\Theta_B$}};

\end{tikzpicture}

在此处输入图片描述

相关内容