7

I want to draw this with tikz,

enter image description here

I have been trying to do it with tikz for awhile but didnt get far, with suggestion I moved to PsTricks. This is what I have so far

\documentclass[pstricks,border=15pt]{standalone}
\usepackage{pstricks-add}

\definecolor{DarkOceanSky}{RGB}{133,163,229}
\definecolor{DarkNavyBlue}{RGB}{0,25,63}
\definecolor{Reu}{RGB}{102,173,76}
\definecolor{Crimson}{RGB}{220, 20, 60}

%second part
\def\block{%
        \foreach \x in {1,3,5,...,7}
        {
            \foreach \y in {1,3,5,...,7}
             {%
                \foreach \angle in {0,45,...,315}
                 {
                    \psrline{->}(\x,\y)(!0.10 Rand 1.4 mul add sqrt \angle\space PtoC)
                 }
             }
        }

        \foreach \counter in {0,2,4,6,...,8}
        {
            \psline{-, linecolor=DarkNavyBlue,linewidth=1.8pt}(\counter,0)(\counter,8)
            \psline{-, linecolor=DarkNavyBlue,linewidth=1.8pt}(0,\counter)(8,\counter)          
        }

        \pscircle*[linecolor=Crimson](4,4){0.2}
}



\begin{document}
\begin{pspicture}[showgrid](19.0,8)
        %\rput(12,0){\block}
        \rput(11.0,0){\block}

        \foreach \counter in {0,2,4,6,...,8}
        {
            \psline{-, linecolor=DarkNavyBlue,linewidth=1.8pt}(\counter,0)(\counter,8)
            \psline{-, linecolor=DarkNavyBlue,linewidth=1.8pt}(0,\counter)(8,\counter)          
        }

        \foreach \counter in {1,3,5,...,7}
        {
            \psline{-, linecolor=DarkNavyBlue,linewidth=1.0pt}(\counter,0)(\counter,8)
            \psline{-, linecolor=DarkNavyBlue,linewidth=1.0pt}(0, \counter)(8,\counter)
        }

        \foreach \counter in {0.5,1.5,2.5,3.5,4.5,5.5,6.5,...,7.5}
        {
            \psline{-, linecolor=DarkNavyBlue,linewidth=1.0pt}(\counter,0)(\counter,8)
            \psline{-, linecolor=DarkNavyBlue,linewidth=1.0pt}(0, \counter)(8, \counter)
        }


        \pscircle[linecolor=Reu](4,4){4.5}
        \pscircle*[linecolor=Crimson](4,4){0.2}


        %I need to draw those small arrows
        \psrline{->}(1.6, 0.1)(!0.10 Rand 0.3 mul add sqrt 45 PtoC) 
\end{pspicture}

\end{document}

enter image description here

What I need to do now is to create those small arrows on the left figure. They are tiny arrows. I am willing to settle for same size arrows. So basically, fixed-size arrows with different orientations. I think the way to do it is to draw an arrow horizontally and rotate it around the center with random degree. I dont know how to do this and not sure if it is the right way. Can you help me?

  • I cannot see clearly what kind of objects are in the little subsquares tot the left? Is there a single arrow on a subsquare? – Gonzalo Medina Jul 12 '13 at 0:17
  • @Gonzalo: Yes, they are tiny arrows – WangZhu Jul 12 '13 at 0:24
  • See my updated answer. I have included the complete solution for you. Don't forget to accept it by pressing the check button below the down vote button. Optionally you can up vote it as well. – kiss my armpit Jul 13 '13 at 6:11
3
\documentclass[pstricks,border=15pt]{standalone}
\usepackage{pstricks-add}

\definecolor{DarkOceanSky}{RGB}{133,163,229}
\definecolor{DarkNavyBlue}{RGB}{0,25,63}
\definecolor{Reu}{RGB}{102,173,76}
\definecolor{Crimson}{RGB}{220,20,60}

\pstVerb{realtime srand}

\def\Grid{%
    \foreach \counter in {0,2,...,8}{%
        \psset{linecolor=DarkNavyBlue,linewidth=2\pslinewidth,linecap=2}
        \psline(\counter,0)(\counter,8)
        \psline(0,\counter)(8,\counter)          
  }%
}

\def\SubGrid{%
    \foreach \counter in {0,.5,...,8}{%
        \psset{linecolor=DarkOceanSky,linewidth=.5\pslinewidth,linecap=2}
        \psline(\counter,0)(\counter,8)
        \psline(0,\counter)(8,\counter)          
  }%
}

\def\Left{%
    \SubGrid
    \Grid
    \foreach \x in {.25,.75,...,7.75}{%
        \foreach \y in {.25,.75,...,7.75}{%
            \rput{!rand 3601 mod 10 div}(\x,\y){\psline{->}(-4pt,0)(4pt,0)}
        }%
    }%
    \pscircle[linecolor=Reu,linewidth=2\pslinewidth](4,4){4.5}
    \pscircle*[linecolor=Crimson](4,4){0.2}
}

\def\Right{%
    \Grid
    \foreach \x in {1,3,5,...,7}{%
        \foreach \y in {1,3,5,...,7}{%
            \foreach \angle in {0,45,...,315}{%
                \psrline{->}(\x,\y)(!0.10 Rand 1.4 mul add sqrt \angle\space PtoC)
            }%
        }%
    }%
    \pscircle*[linecolor=Crimson](4,4){0.2}
}

\begin{document}
\begin{pspicture}[showgrid=false](18,9)
    \rput(.5,.5){\Left}
    \rput(10,.5){\Right}
\end{pspicture}
\end{document}

enter image description here

  • This looks good. I cant compile PSTricks with my Miktex yet, but I'll work it out. Could you pleas ehelp me with the first image, I cant create small arrows with tikz. – WangZhu Jul 12 '13 at 1:46
  • @WangZhu: Compile it with xelatex or latex-dvips-ps2pdf. – kiss my armpit Jul 12 '13 at 1:47
4

The placement of the tiny arrows should be optimized (as it is better to be dependent on the grid size and not TikZ’ coordinate system) but here is a two-nested-loops-randomized approach.

Code

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{arrows} 
\definecolor{DarkOceanSky}{RGB}{133,163,229}
\definecolor{DarkNavyBlue}{RGB}{0,25,63}
\definecolor{Reu}{RGB}{102,173,76}
\definecolor{Crimson}{RGB}{220, 20, 60}
\begin{document}
\begin{tikzpicture}[
  declare function={
    minorGridStep=.125cm;
    majorGridStep=.5cm;
  },
  major grid/.style={
    line width=+.018cm,
    draw=DarkNavyBlue,
    step=majorGridStep,
  },
  minor grid/.style={
    line width=+.008cm,
    draw=DarkNavyBlue,
    step=minorGridStep
  },
  green circle/.style={
    draw=Reu,
    radius=1.1,
    line width=+.008cm
  },
  red dot/.style={
    fill=Crimson,
    radius=.05
  }
]
  \begin{scope}
     \path[minor grid] (-1,-1) grid (1,1);
     \path[major grid] (-1,-1) grid (1,1);

     \path[green circle] circle [];
     \path[red dot] circle [];

     \foreach \cRight in {0,...,15}
       \foreach \cDown[
         evaluate={\length=max(rnd*.9*minorGridStep,1.5\pgflinewidth)},
         evaluate={\angle=rnd*360}
       ] in {0,...,15}
         \draw[triangle 90 cap reversed-triangle 90 cap] ([shift=(\angle:-\length/2 pt)] \cRight/16*2-1+.0625,\cDown/16*2-1+.0625) -- ++ (\angle:\length pt);
  \end{scope}
\end{tikzpicture} 
\end{document}

Output

enter image description here

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.