Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am new to the TikZ package, and I need to make this image:

enter image description here

in TikZ.

For now I've done this, and I'm having trouble doing that kind of arrows of image above.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning,arrows,calc}
\begin{document}
\tikzset{
    big dot/.style={
            circle, inner sep=0pt, 
            minimum size=3mm, fill=gray
    },
    line/.style={
        draw, 
        line width=1.4pt
    },
        input/.style={
                draw,
                trapezium,
                trapezium left angle=60,
                trapezium right angle=120,
        line width=1.2pt,
        fill={rgb:black,1;white,2}
        },
    obstacle/.style={
                draw,
                trapezium,
                trapezium left angle=120,
                trapezium right angle=60,
        line width=1.2pt,
        fill={rgb:black,1;white,2}
        }
}

\begin{tikzpicture}
\node[input](goal1) at (0,0) {GOAL};
\node[input](goal2) at (4,0) {GOAL};
\node[obstacle](obstacle1) at (0,-1.5) {OBSTACLE};
\node[input](goal3) at (1.5,-3) {GOAL};
\node[input](goal4) at (4,-3) {GOAL};

\draw[line] (goal1.east) -- (goal2.west);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this question
    
The flash is best done with the decorations.markings library and drawn manually (there is no arrow that looks like that). The yellow circle is best done as a separate node. The other arrows are tricky because they are filled and relatively large. Are you by any chance using the CVS version of TikZ? –  Qrrbrbirlbel Nov 1 '13 at 17:58

1 Answer 1

up vote 6 down vote accepted

This is very easily done with the new arrows.meta library of the CVS version of TikZ (see How to install a current version of TikZ?).

Unfortunately, I cannot create a filled arrow tip of the stealth kind (which can be created with the markings library by first adding a big black tip and then drawing a smaller arrow tip that is colored in over the black one) and the | before it. For reference I used:

arrowS/.style={postaction=decorate,decoration={name=markings, arrow/.list={#1}}},
/pgf/decoration/arrow/.style args={#1:#2-#3}{mark=at position #1 with {\arrow[#2]{#3}}}

which can be used as

arrowS={+-0.01pt:scale=1.7-stealth, +-1.5pt:yellow-stealth}

which worked for my CVS version but the | did not show up. With the stable 2.10 release the | worked but the black stealth tip wasn’t scaled.

You will need to compromise here without using the arrows.meta library.

The flash is simply drawn by the markings library, you can adjust the values, of course.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric,arrows.meta,decorations.markings}
\tikzset{
  big dot/.style={circle, draw, inner sep=0pt, minimum size=3mm, fill=yellow},
  input/.style={draw, trapezium, trapezium left angle=60, trapezium right angle=120,
    line width=1.2pt, fill={rgb:black,1;white,2}},
  obstacle/.style={draw, trapezium, trapezium left angle=120, trapezium right angle=60,
    line width=1.2pt, fill={rgb:black,1;white,2}},
  flash/.style args={#1:#2}{postaction=decorate,decoration={name=markings,
    mark=at position #1 with {%
    \draw[fill=#2, line width=.75\pgflinewidth, line cap=round, line join=round]
         (+\pgflinewidth,+7\pgflinewidth)   -- ++ ( left:+2\pgflinewidth) 
      -- (+-4\pgflinewidth,+-\pgflinewidth) -- ++ (right:+5\pgflinewidth)
      -- (+-\pgflinewidth,+-7\pgflinewidth) -- ++ (right:+2\pgflinewidth)
      -- (+4\pgflinewidth,\pgflinewidth)    -- ++ (left:+5\pgflinewidth) -- cycle;}}}
}
\begin{document}
\begin{tikzpicture}[very thick,
  StealthFill/.tip={Stealth[line width=1pt, scale=1.5]}, arrows={[round]}]
\node[input]    (goal1)     at (0,0) {GOAL};
\node[input]    (goal2)     at (4,0) {GOAL};
\node[obstacle] (obstacle1) at (0,-1.5) {OBSTACLE};
\node[input]    (goal3)     at (1.5,-3) {GOAL};
\node[input]    (goal4)     at (4,-3) {GOAL};

\path (goal2) -- node[big dot] (bigdot) {} (goal4);
\path[line width=1.4pt, line cap=rect]
  (goal1) edge[flash=.5:red] (goal2)
  (bigdot) edge (goal3.north)
           edge (goal4)          
           edge[-{StealthFill[fill=yellow]}] (goal2)
  [bend left=10, StealthBar/.style={-{Bar[sep=2] StealthFill[fill=#1]}}]
    (goal2)     edge[StealthBar=green] (obstacle1)
    (obstacle1) edge[StealthBar=red]   (goal2);
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.