summaryrefslogtreecommitdiff
path: root/info/drawing-with-metapost/src/arch-3-4-6-4.mp
blob: 0a7094be3b2d30d36067714a6652ddb47ce9c4d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\mplibsetformat{metafun}
\begin{mplibcode}
input colorbrewer-rgb
beginfig(1);
    numeric r; r = 5;
    path d; d = for i=1 upto 12:
        up scaled r
           shifted (r * (sqrt(3)+2), 0)
           rotated 30i -- 
       endfor cycle;

    color shade[]; 
    shade0 = Oranges 8 3; 
    shade1 = Blues 8 3; 
    shade2 = Greens 8 3;
    shade3 = Reds 8 3;
    
    vardef unit(expr n) = image(
        fill d withcolor transparent (2, .9, shade[n mod 4]);
        draw d; 
    ) enddef;
    pair u, v;
    u = point 0 of d - point 3 of d;
    v = u rotated 60;
    numeric n; n = 6;
    for i=-n upto n:
        for j=-n upto n:
            draw unit(i*j) shifted ((i - floor(j / 2)) * u + j * v);
        endfor
    endfor
    clip currentpicture to unitsquare shifted -(1/2, 1/2) scaled (n * 9 r);
    picture p; p = image(
        draw d; draw point 0 of d withpen pencircle scaled 2;
        drawoptions(withcolor 3/4[red, white]);
        draw d shifted u; draw point 0 of d shifted u withpen pencircle scaled 2;
        drawoptions(withcolor 3/4[blue, white]);
        draw d shifted v; draw point 0 of d shifted v withpen pencircle scaled 2;
        drawoptions();
        drawarrow origin -- u withcolor red;
        drawarrow origin -- v withcolor blue;
    );
    label.bot(p, point 1/2 of bbox currentpicture shifted 13 down);
    label.bot(btex \vbox{\hsize 3.4in\noindent
        The vectors are chosen so that the dodecagons overlap to make 
        the required triangles, squares, and hexagons.} etex,
        point 1/2 of bbox currentpicture shifted 13 down);
endfig;
\end{mplibcode}
\end{document}