Debian Codegraph @

texmf-dist/doc/metapost/featpost/example/durgayantra.mp

raw
1 % durgayantra.mp
2 % L. Nobre G.
3 % 2010
4
5 prologues := 1;
6
7 numeric u, numthings, bang, tang, hei, rb, rt, ro;
8 numthings = 8;
9 bang = 75;
10 tang = 75;
11 rb = u+hei;
12 rt = rb+hei;
13 ro = rt+2.5mm;
14 numeric adang, reflen, marlen, sqrlen;
15 adang = 19.896;
16 reflen = 0.4*ro;
17 marlen = ro*sqrt(2)*(sind(45+adang)-0.5*sqrt(2));
18 hei = marlen/6;
19 ro+marlen+hei = 18mm; % defines u and hei
20 color fundo, risco;
21 fundo = (15*16+15,14*16+11,12*16+13)/255;
22 risco = (11*16-15,3*16-14,15*16-15)/255;
23
24 vardef makedurgayantra =
25 path outercircle, firstcircle, seconcircle;
26 draw fullcircle scaled (2*u);
27 draw fullcircle scaled (2*rb);
28 draw fullcircle scaled (2*rt);
29 path pthingb, pthingbr;
30 pthingb = (rt,0){dir(90-bang)}..
31 {dir(180/numthings+90-tang)}(ro*dir(180/numthings));
32 pthingbr = pthingb yscaled (-1);
33 numeric i;
34 for i=1 upto numthings:
35 draw (reverse pthingbr) rotated ((i+0.5)*360/numthings);
36 draw pthingb rotated ((i+0.5)*360/numthings);
37 endfor;
38 z200 = (ro+marlen,0);
39 z201 = (ro+marlen,1.5*reflen);
40 z202 = (ro+0.5*marlen,1.5*reflen);
41 z203 = (ro+0.5*marlen,0.5*reflen);
42 z204 = (ro,0.5*reflen);
43 z205 = (ro,ro);
44 z100 = z200-(hei,0);
45 z101 = z201-(hei,hei);
46 z102 = z202+(hei,-hei);
47 z103 = z203+(hei,-hei);
48 z104 = z204-(hei,hei);
49 z105 = z205-(hei,hei);
50 z300 = z200+(hei,0);
51 z301 = z201+(hei,hei);
52 z302 = z202-(hei,-hei);
53 z303 = z203-(hei,-hei);
54 z304 = z204+(hei,hei);
55 z305 = z205+(hei,hei);
56 path octp[], octpr[];
57 numeric j;
58 octp[1] = z200--z201--z202--z203--z204--z205;
59 octp[0] = z100--z101--z102--z103--z104--z105;
60 octp[2] = z300--z301--z302--z303--z304--z305;
61 for j=0 upto 2:
62 octpr[j] = (reverse octp[j]) yscaled (-1) ;
63 for i=1 upto 4:
64 draw octpr[j] rotated (i*90);
65 draw octp[j] rotated (i*90);
66 endfor;
67 endfor;
68 z1 = (0,-u);
69 z2 = u*0.5*(sqrt(3),1);
70 z3 = u*0.5*(-sqrt(3),1);
71 draw z1--z2--z3--cycle;
72 numeric refang, xr, dr;
73 xr = sqrt(15);
74 dr = (xr-sqrt(3))*u*0.25;
75 refang = angle(xr,1); show refang;
76 z11 = u*0.25*(xr,-1);
77 z12 = 0.5[z2,z3]+dr*dir(60);
78 z13 = 0.5[z2,z3]+dr*dir(120);
79 z14 = u*0.25*(-xr,-1);
80 z15 = 0.5[z1,z3]+dr*dir(-120);
81 z16 = 0.5[z2,z1]+dr*dir(-60);
82 % z11 = u*dir(-refang);
83 % z12 = u*dir(90-refang);
84 % z13 = u*dir(90+refang);
85 % z14 = u*dir(refang-180);
86 % z15 = u*dir(3*refang-180);
87 % z16 = u*dir(-3*refang);
88 draw z11--z12--z15--z16--z13--z14--cycle;
89 enddef;
90
91 beginfig(1);
92 numeric hs, al, do, m, diamfur, mfur;
93 hs = 20mm;
94 al = 16cm;
95 % do = 3mm;
96 do = 0;
97 m = 3.8mm;
98 % diamfur = 3mm;
99 mfur = 6mm;
100 z21 = (hs,m-hs);
101 z22 = (hs,al-hs+do-m);
102 z23 = (hs-m,al-hs+do);
103 z24 = (m-hs,al-hs+do);
104 z25 = (-hs,al-hs+do-m);
105 z26 = (-hs,m-hs);
106 z27 = (m-hs,-hs);
107 z28 = (hs-m,-hs);
108 fill z21---z22...z23---z24...z25---z26...z27---z28...cycle withcolor fundo;
109 % draw (hs,al-hs)--(-hs,al-hs) dashed evenly;
110 % draw fullcircle scaled diamfur shifted (mfur-hs,al-hs-mfur);
111 % draw fullcircle scaled diamfur shifted (hs-mfur,al-hs-mfur);
112
113 drawoptions( withpen pencircle scaled 0.3mm withcolor risco );
114 makedurgayantra;
115 drawoptions( withpen pencircle scaled 0.1mm withcolor risco );
116 numeric lettersiz, lr, ls, lh;
117 lettersiz = 1.1mm;
118 lr = 1+0.5*sqrt(2);
119 ls = 0.9mm;
120 lh = lettersiz*lr;
121 path lepa[];
122 pair av, auxa, lc, auxd;
123 numeric lph[], auxb, auxc;
124 auxc = 0.5*lettersiz;
125 lc = (hs-m,0.5*al-hs);
126 av = (auxc,lh);
127 lepa0 = origin--av--(lettersiz,0);
128 lph0 = 0;
129 auxa = (lh-lettersiz)*unitvector(av);
130 lepa7 = auxa--(lettersiz-xpart auxa, ypart auxa);
131 lph7 = 0;
132 lepa1 = origin--(0,lh)---av...(auxc,lh-lettersiz)---(0,lh-lettersiz);
133 lph1 := lettersiz+ls;
134 lepa2 = origin--(0,lh)--(auxc,lh-auxc)--(lettersiz,lh)--(lettersiz,0);
135 lph2 = 2*(lettersiz+ls);
136 auxb = 0.25*lettersiz*sqrt(2);
137 lepa3 = (auxc-auxb,0.5*lh+auxb)--(auxc+auxb,0.5*lh-auxb);
138 lepa13 = (auxc-auxb,0.5*lh-auxb)--(auxc+auxb,0.5*lh+auxb);
139 lph3 = 3*(lettersiz+ls);
140 lph13 = lph3;
141 lepa4 = (0,lh)--origin--(lettersiz,0);
142 lph4 = 4*(lettersiz+ls);
143 lepa5 = origin--(0,lh)--(lettersiz,0)--(lettersiz,lh);
144 lph5 = 5*(lettersiz+ls);
145 lepa6 = (lettersiz,lh-auxc){up}...av...(0,lh-auxc)---(0,auxc)...(auxc,0)...(lettersiz,auxc)--(auxc,auxc);
146 lph6 = 6*(lettersiz+ls);
147 lepa8 = (lettersiz,auxc)--(lettersiz,0);
148 lph8 = lph6;
149 auxd = sqrt(2)*auxc*(1,1);
150 lepa9 = (0,lh-auxc){up}...av...(lettersiz,lh-auxc)...auxd---origin--(lettersiz,0);
151 lph9 = 8*(lettersiz+ls);
152 lepa10 = (0,auxc)---(0,lh-auxc)...av...(lettersiz,lh-auxc)---(lettersiz,auxc)...(auxc,0)...cycle;
153 lph10 = lph9 + lettersiz + ls;
154 lepa11 = (0,lh-ypart auxd)--(xpart auxd,lh)--(xpart auxd,0);
155 lph11 = lph10 + lettersiz + ls;
156 lepa12 = lepa10;
157 lph12 = lph11 + ls + xpart auxd;
158 numeric i;
159 for i=0 upto 13:
160 draw lepa[i] rotated 90 shifted (lc+(0,lph[i]));
161 endfor;
162 picture finalpicture;
163 finalpicture = currentpicture;
164 currentpicture := nullpicture;
165 drawoptions();
166 draw finalpicture rotated (-45);
167 endfig;
168
169 beginfig(2);
170 % drawoptions( withcolor risco );
171 makedurgayantra;
172 endfig;
173
174 end.