19

(April Fools' Day joke) How do we draw something like this? I enclose a picture and a detail of it.

Update: I enclose one more screenshot (with TeXs sitting at the crossroads) if somebody is actually trying to draw it. It's making things harder or it's a hint. It depends on your point of view and experience. Above all have fun!

A joke for April 1,...

First detail of the picture

Second detail of the picture

Actually I could provide the code, if somebody would be interested to look at this chaos. :-) This is one of my early experiments which should serve as the background to a book cover.

4
  • Are these all continuous lines?
    – T. Verron
    Commented Apr 1, 2015 at 8:32
  • @T.Verron It's just a joke, the lines could be of any sort. ;-)
    – Malipivo
    Commented Apr 1, 2015 at 8:35
  • 5
    +1 ♫ how many crossroads must a man walk down… ♫ :) Commented Apr 1, 2015 at 8:37
  • 2
    @Malipivo You would not find the joke funny if you had to drive on this road. ;)
    – T. Verron
    Commented Apr 1, 2015 at 8:40

3 Answers 3

30

I used directly \pdfliteral:

\def\circle{1 0 0 1 5 0 cm 5 0 m
5 2.76 2.76 5 0 5 c
-2.76 5 -5 2.76 -5 0 c
-5 -2.76 -2.76 -5 0 -5 c
2.76 -5 5 -2.76 5 0 c S  
}
\def\drawpath{q -3 3 m 23 3 l 23 -3 l -3 -3 l -3 3 l 0 3 l S
              \circle \circle \circle Q }

roads: \quad 
   \pdfliteral{q 
      \drawpath
      .8 w 1 G \drawpath
      .7 w 1 1 0 RG \drawpath
      .6 w .7 G \drawpath
      .2 w 1 G \drawpath
      .1 w .7 G \drawpath
   Q}

\bye

The result:

cesty

3
  • Nicely done, check out the update...
    – Malipivo
    Commented Apr 1, 2015 at 8:58
  • 2
    @Malipivo And animated cars moving on the roads. Do you want this?
    – wipet
    Commented Apr 1, 2015 at 9:10
  • 1
    Sure, why not? ;-) You know, it's rather question for fun for TeX beginners, I didn't expect answers from TeXperts of your magnitude. :-)
    – Malipivo
    Commented Apr 1, 2015 at 9:14
22

Similar result with TikZ, using preaction and postaction:

\documentclass[tikz]{standalone}

\tikzset{road/.style={yellow,double=gray!75,line width=1pt, double distance=16.5pt,
    preaction={draw, black, double=white,line width=1pt, double distance=20pt},
    postaction={draw, white, double,line width=1pt, double distance=2pt}}}
\begin{document}
\begin{tikzpicture}
    \draw[road] 
        (-12,-3) rectangle (12,3) 
        (0,0) circle (5) 
        (5,0) circle (5) 
        (-5,0) circle (5);
\end{tikzpicture}
\end{document}

result

And to draw something like in the question:

\begin{tikzpicture}
    \draw[clip] (-100,-100) rectangle (100,100);
    \draw[road] \foreach \x in {1,...,50} { (-110,100*rand) .. controls ++(100*rnd,20*rand) and ++(-100*rnd,20*rand) .. (110,100*rand) 
                        (100*rand,110) .. controls ++(100*rand,-100*rnd) and ++(100*rand,100*rnd).. (100*rand,-110) } 
    \foreach \x in {1,...,5} { let \n1={random(10,30)} in (100*rand,100*rand) circle[radius=\n1]};
\end{tikzpicture}

result

1
  • Nice job, indeed!
    – Malipivo
    Commented Apr 1, 2015 at 14:50
15

You can do this using Metapost's for p within picture feature that lets you loop through the contents of a picture created with image.

enter image description here

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

def polydraw(expr pict) = 
  for p within pict: if stroked p: draw p withpen pencircle scaled 10;                         fi endfor
  for p within pict: if stroked p: draw p withpen pencircle scaled  9 withcolor (red + green); fi endfor
  for p within pict: if stroked p: draw p withpen pencircle scaled  8 withcolor .7 white;      fi endfor
  for p within pict: if stroked p: draw p withpen pencircle scaled  2 withcolor white;         fi endfor
  for p within pict: if stroked p: draw p withpen pencircle scaled  1 withcolor .7 white;      fi endfor
  enddef;

beginfig(1);
  u := 1.4cm;
  picture base; 
  base = image(
    draw fullcircle scaled 4u shifted (-2u,0);
    draw fullcircle scaled 4u shifted ( 0,0);
    draw fullcircle scaled 4u shifted (+2u,0);
    draw unitsquare shifted (-1/2,-1/2) xscaled 9u yscaled 2.4u;
    );
  polydraw(base);
endfig;

end.
1
  • 1
    Really elegant!
    – Aditya
    Commented Apr 8, 2015 at 3:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .