summaryrefslogtreecommitdiff
path: root/info/drawing-with-metapost/src/arch-3-4-3-4.mp
blob: 42b01cb7eb46ee9d1e9f2d4b302538dc1509c730 (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
55
56
57
58
59
60
61
62
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
input colorbrewer-rgb
vardef median(expr p) = origin for i=1 upto length p: + point i of p / length p endfor enddef;
beginfig(1);
    path s[], t[];
    s1 = unitsquare scaled 21 rotated 15; 
    s2 = s1 rotated 150;
    t1 = subpath (4, 3) of s1 -- point 1 of s2 -- cycle;
    t2 = t1 reflectedabout(point 1 of t1, point 2 of t1);
    t3 = t1 rotated 150;
    t4 = t1 rotated 210;

    picture color_unit, grid_unit;
    color_unit = image(
        fill s1 withcolor Oranges 8 1;
        fill s2 withcolor Oranges 8 2;
        fill t1 withcolor Blues 8 1;
        fill t2 withcolor Blues 8 2;
        fill t3 withcolor Blues 8 3;
        fill t4 withcolor Blues 8 4;
    );
    grid_unit = image(
        forsuffixes $=s1, s2, t1, t2, t3, t4:
            draw $; 
            % pair m; m = median($);
            % for i=1 upto length $: 
            %     draw m -- point i - 1/2 of $ 
            %         withpen pencircle scaled 1/4; 
            % endfor
        endfor
    );

    pair u, v;
    u = point 1 of s1 - point 1 of s2;
    v = u rotated 90;
    
    numeric n; n = 3;
    forsuffixes $=color_unit, grid_unit:
        for i=-n upto n:
            for j=-n upto n:
                draw $ shifted (i * u + j * v);
            endfor
        endfor
    endfor
    label.bot("The arrangement of polygons in the units was carefully",  point 1/2 of bbox currentpicture
            shifted 21 down);
    label.bot("chosen to give the tiling neat edges."            , point 1/2 of bbox currentpicture);

    path b; b = bbox currentpicture shifted 34 down;
    draw color_unit shifted point 1/4 of b;
    draw grid_unit  shifted point 3/4 of b;
    path b; b = bbox currentpicture shifted 13 down;
    label("\texttt{color\_unit}", point 1/4 of b);
    label("\texttt{grid\_unit}", point 3/4 of b);
endfig;
\end{mplibcode}
\end{document}