summaryrefslogtreecommitdiff
path: root/info/drawing-with-metapost/src/closed-reuleaux-set.mp
blob: 4088ea8421631b3a426d10b9030214400362952c (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
\documentclass{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
\mplibtextextlabel{enable}
vardef reuleaux(expr n, r) =
    save a; numeric a; a = 90/n;
    for t = 0 step 4a until 359:
        (0, r) rotated t {left rotated (a + t)} .. {left rotated (3a + t)}
    endfor cycle
enddef;
vardef median(expr p) = origin for i=1 upto length p: + point i of p / length p endfor enddef;
input colorbrewer-rgb
beginfig(1);
    for n = 3 upto 7:
        path p; p = reuleaux(n, 42) shifted (90n, 0);
        pair m; m = point (n+1)/2 of p;
        fill p withcolor if odd n: Oranges else: Blues fi 8 2;
        fill subpath (0, 1) of p -- m -- cycle 
            withcolor if odd n: Oranges else: Blues fi 8 3;
        %draw fullcircle scaled 2 abs(point 0 of p - m) shifted m
        %    withpen pencircle scaled 2 withcolor 3/4;
        %draw tensepath(p) withcolor Blues 8 6;
        %draw p rotatedabout(median(p), 180/n) withcolor Blues 8 6;
        draw p;
    endfor

endfig;
\end{mplibcode}
\end{document}