多条十字路口如何画?

多条十字路口如何画?

(愚人节笑话)我们该如何画出这样的东西?我附上了一张图片和它的细节。

更新:如果有人真的想画它,我会附上一张截图(TeX 位于十字路口)。这会让事情变得更难,或者只是一种暗示。这取决于你的观点和经验。最重要的是玩得开心!

4 月 1 日的一个笑话......

图片的第一个细节

图片的第二个细节

实际上,如果有人有兴趣看看这种混乱,我可以提供代码。:-) 这是我早期的实验之一,应该作为书籍封面的背景。

答案1

我直接使用\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

结果:

塞斯蒂

答案2

与 TikZ 的结果类似,使用preactionpostaction

\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}

结果

并画出类似问题的内容:

\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}

结果

答案3

您可以使用 Metapost 的for p within picture功能来执行此操作,该功能可让您循环遍历使用 创建的图片的内容image

在此处输入图片描述

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.

相关内容