texmf-dist/doc/metapost/base/source-tutorial/circles.mp
raw| 1 | if scantokens(mpversion) > 1.005: |
| 2 | outputtemplate := |
| 3 | else: |
| 4 | filenametemplate |
| 5 | fi |
| 6 | "%j.mps"; |
| 7 | |
| 8 | beginfig(0); |
| 9 | % Use 8 circles |
| 10 | N:=8; |
| 11 | |
| 12 | % Compute the "correct" radius |
| 13 | r:=54*sind(180/N)/(1+sind(180/N)); |
| 14 | |
| 15 | % Define one of the cirlces |
| 16 | path p; |
| 17 | p:=fullcircle scaled (2*r); |
| 18 | |
| 19 | % Draw all 8 circles |
| 20 | for n=0 upto N-1: draw p shifted (r/sind(180/N),0) rotated (360/N*n); endfor; |
| 21 | endfig; |
| 22 | end |