2

I am trying to create the following picture. mixingzone.

I have only gotten so far.

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{tikz-feynman}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
    \begin{figure}[!ht]
        \centering
        \begin{tikzpicture}
        \draw (0,0) -- (2,0) -- (2,3);
        \draw (0,0) -- (0,3);
        \draw[decorate,decoration={snake,amplitude=.4mm,segment length=2mm,post length=0mm}] (0,2.5) -- (0.9,2.5);
        \draw[decorate,decoration={snake,amplitude=.4mm,segment length=2mm,post length=0mm}] (1.1,2.5) -- (2,2.5);
        \draw[dashed] (0.9,2.5) to[out=-180,in=180] (1,1.5);
        \draw[dashed] (1.1,2.5) to[out=0,in=0] (1,1.5);
        \draw[red] (0.9,3.2) -- +(0,-0.7);
        \draw[red] (1.1,3.2) -- +(0,-0.7);
        \begin{feynman}
        \vertex (a) at (0.9,2.5) {};
        \vertex (b) at (1,1.5);
        \diagram{(a) -- [gluon] (b) -- };
        \end{feynman}
        \end{tikzpicture}
     \end{figure}
\end{document}

The output is

tikzoutput.

I can handle the text part but I am having a hard time figuring out the lines in the mixing zone. Also, is there a way around the straight line portion of the snake line. I want to have a continuous squiggly line. Any help would be greatly appreciated.

Thanks in advance!

  • 2
    It's probably much easier and quicker to draw this in a vector drawing program like Inkscape, instead of using tikz. – Håkon Marthinsen Nov 20 '16 at 20:51
3

The mixing probably is best done in something like Inkscape. Unless you want something like the following, which looks a bit on the hellish side of demonic to me.

However, the main point of this answer is to demonstrate one way to prevent the snake straightening out. Another would be to ensure that the amplitude divides exactly into the path length. Clipping a longer path to size is, in my opinion, a lot easier.

Here, we define a pic to do the clipping, draw the path and limit the effects to a local scope. The pic named wiggle takes 2 arguments, the start point of the path and the end point. A longer path will be drawn and clipped to size to ensure that the straight bits are all in the clippings and not in the remaining fabric of the diagram.

I don't know how the gluon relates to the target image, so I left it out, especially since it appeared to want LuaTeX. Obviously, it can be replaced if and where required.

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{decorations.pathmorphing,decorations.pathreplacing,calc,fadings}
\begin{document}
\tikzset{%
  my snake/.style={decorate, decoration={snake, amplitude=.4mm, segment length=2mm, post length=0pt}},
  pics/wiggle/.style 2 args={%
    code={%
      \begin{scope}
        \clip ([yshift=.5mm]#1) rectangle  ([yshift=-.5mm]#2);
        \draw [my snake] ([xshift=-2mm]#1) --  ([xshift=2mm]#2);
      \end{scope}%
    },
  },
}
\begin{tikzpicture}
  \draw (0,0) -- (2,0) -- (2,3);
  \draw (0,0) -- (0,3);
  % because the \coordinate ... at ... fails
  \foreach \i [count=\j]  in {(0.9,2.5), (1.1,2.5), (1,1.5), (0,2.5), (2,2.5)} \path \i coordinate (p\j);
  \begin{scope}
    \clip (p1) [out=-180, in=180] to (p3) [out=0, in=0] to (p2) [out=-180, in=0] to cycle;
    \begin{scope}[shift=($($(p1)!1/2!(p2)$)!1/2!(p3)$), scale=.25]
      % p. 604
      \foreach \l/\i/\j\k/\m in {(0,0)/2mm/60/1mm/red!50!gray,(-.25,1)/1.9mm/-60/1.5mm/red!25!black,(.5,-1)/2mm/70/2mm/red!20!gray!90!black,(.3,.5)/2mm/60/2mm/red!30!black,(.4,1.15)/2.1mm/80/1mm/red,(-.1,-1)/1.85mm/40/2.5mm/black,(.1,-.7)/2mm/80/2mm/gray}
      {
        \path [opacity=.5, blend mode=overlay, \m, inner color=\m!50, outer color=\m, path fading=circle with fuzzy edge 15 percent, opacity=.6] \l circle (15mm) ;
        \path [decoration={waves, segment length=\i, angle=\j, radius=\k}, line width=.3mm, postaction={decorate, draw}, opacity=.35, blend mode=difference, \m] \l circle (5mm) ;
      }
    \end{scope}
  \end{scope}
  \pic {wiggle={p4}{p1}};
  \pic {wiggle={p2}{p5}};
  \draw[dashed] (p1)   to[out=-180,in=180]   (p3);
  \draw[dashed] (p2)  to[out=0,in=0] (p3);
  \draw[red] (0.9,3.2) -- +(0,-0.7);
  \draw[red] (1.1,3.2) -- +(0,-0.7);
\end{tikzpicture}
\end{document}

mixing

3

To "scribble" over a region you could choose a suitable path to fill the region and morph it using coil or random steps:

Coil:

\documentclass[tikz, border=5pt]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{
  mixing/.style={decorate, decoration={coil, amplitude=.125cm, segment length=.125cm, aspect=.75}},
  water/.style={decorate,decoration={snake,amplitude=.4mm,segment length=2mm,post length=0mm}}}
\begin{document}
\begin{tikzpicture}
  \draw (-1,1.25) -- +(0,-3) -- +(2,-3) -- +(2,0);
  \draw[water] (-1, .7) -- +(2,0);
  \draw[dashed] (0,0) circle (.5 and .75);
  \draw[double, double distance=.3cm, red] (0,1.5) -- (0,.6); % tube
  \draw [mixing] (0,.5) arc (450:70:.25 and .5);
  \draw [mixing, red] (0,.25) arc (90:540:.13 and .25);
\end{tikzpicture}
\end{document}

coil

Random steps:

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{
  mixing/.style={decorate, decoration={random steps, amplitude=.25cm, segment length=.2mm}, rounded corners=1mm},
  water/.style={decorate,decoration={snake,amplitude=.4mm,segment length=2mm,post length=0mm}}}
\begin{document}
\begin{tikzpicture}
  \draw (-1,1.25) -- +(0,-3) -- +(2,-3) -- +(2,0);
  \draw[water] (-1, .7) -- +(2,0);
  \draw[dashed] (0,0) circle (.5 and .75);
  \draw[double, double distance=.2cm, red] (0,1.5) -- (0,.6);
  \draw [mixing] (0,0) circle (.25 and .5);
  \draw [mixing, red] (0,0) circle (.2 and .4);
\end{tikzpicture}
\end{document}

random steps

The smooth path morphing doesn't work particularly consistently on paths that are already tightly curved, but if you just need a scribble then a few sharp corners probably don't hurt much.

You may of course like to fiddle with the morphing parameters. For some parameters the path morphing gives a Dimension too large. error, but it doesn't seem to have any noticeable ramifications.

Results with random steps may vary (randomly), so you might want to pick a seed which gives nice results (by using \pgfmathsetseed{<integer>}).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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