Debian Codegraph @

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

raw
1 % ledlogo.mp
2 % L. Nobre G.
3 % 2007
4
5 beginfig(1);
6 numeric u, penangle, peneccen, penminor, letterheig, letterwid, letterang;
7 u=2mm;
8 penangle=112;
9 peneccen=2.1;
10 penminor=2u;
11 letterheig=15u;
12 letterwid=12u;
13 letterang=-25;
14 numeric hdist, vdist, letterslantang, margindist, humanang, humanfactor;
15 hdist=7u;
16 vdist=7u;
17 letterslantang=20;
18 margindist=4.7u;
19 humanang=7;
20 humanfactor=0.2;
21 pen paintpen;
22 paintpen = pencircle scaled penminor xscaled peneccen rotated penangle;
23 pickup paintpen;
24 pair letterup, letterig, dirabove, dirbelow;
25 letterup=dir(90+letterang-letterslantang);
26 letterig=dir(letterang);
27 dirabove=dir(90+letterang-letterslantang+humanang);
28 dirbelow=dir(90+letterang-letterslantang-humanang);
29 z0=origin;
30 z1=z0-letterheig*letterup;
31 z2=z1+letterwid*letterig;
32 z3=z0+hdist*letterig+0.5*letterheig*letterup;
33 z4=z3-letterheig*letterup;
34 z5=z4+letterwid*letterig;
35 z6=z3+hdist*letterig+0.5*letterheig*letterup;
36 z7=z6-letterheig*letterup;
37 z8=z6-(letterheig-margindist)*letterup;
38 z9=z3+letterwid*letterig;
39 z10=z9+margindist*letterig;
40 z11=z0-(letterheig-humanfactor*margindist)*letterup;
41 z12=z1+humanfactor*margindist*letterig;
42 z13=z3-(letterheig-humanfactor*margindist)*letterup;
43 z14=z4+humanfactor*margindist*letterig;
44 z15=z7-2*humanfactor*hdist*letterig;
45 drawoptions( withcolor 0.876*red+0.7*green );
46 % draw z0--z1--z2;
47 % draw z9--z3--z4--z5;
48 % draw z8---z6{letterig}..{unitvector(z2-z5)}z10..z7;
49 draw z0{-dirabove}..z11...z12..{letterig}z2;
50 draw z9--z3{-dirabove}..z13...z14..{letterig}z5;
51 draw z8{dirbelow}..z6{letterig}..{unitvector(z2-z5)}z10..z15;
52 endfig;
53
54 verbatimtex
55 \documentclass{article}
56 \usepackage[T1]{fontenc}
57 \renewcommand*\rmdefault{cmdh}
58 \begin{document}
59 etex
60
61 beginfig(2);
62 picture led;
63 led = thelabel( btex led etex, origin );
64 pair ledshift;
65 ledshift = (0.3pt,-4.4pt);
66 numeric dc, db, da;
67 dc = 24pt;
68 db = 6.9pt;
69 da = 4.98pt;
70 fill fullcircle scaled dc withcolor red;
71 % fill fullcircle scaled db withcolor (red+green);
72 fill fullcircle scaled db withcolor 0.5green;
73 draw led shifted ledshift withcolor (red+green);
74 endfig;
75
76 prologues := 1;
77
78 beginfig(3);
79 numeric u, altur, diam, espessum, margem, distdisp, separ, frac;
80 color vermel, amarel;
81 vermel = 0.75red;
82 amarel = 0.876*red+0.7*green;
83 u = 5cm;
84 diam = 0.23u;
85 margem = 0.85diam;
86 altur = u-margem;
87 frac = 0.7;
88 numeric auxdist, lencirc, orientang, limitshift, i;
89 limitshift = 1.6u;
90 auxdist = (1u-2margem)*0.5;
91 distdisp = auxdist*sqrt(2) - diam;
92 3*separ+2*espessum = distdisp;
93 separ = frac*espessum;
94 lencirc = length fullcircle;
95 path uma, umb;
96 uma = (0.5separ,-0.5diam)--(0.5separ+espessum,-0.5diam)
97 --(0.5separ+espessum,0.5diam)--(0.5separ,0.5diam)--cycle;
98 umb = uma rotated 180;
99 fill uma withcolor amarel;
100 fill umb withcolor amarel;
101 picture parduns;
102 parduns = currentpicture;
103 currentpicture := nullpicture;
104 path botcirc, caminhescudo, circulbase;
105 circulbase = fullcircle scaled diam;
106 botcirc = subpath (0.5*lencirc,lencirc) of fullcircle scaled u;
107 caminhescudo = botcirc--(0.5u,altur)--(-0.5u,altur)--cycle;
108 fill caminhescudo withcolor vermel;
109 z1 = ( auxdist, altur-margem );
110 z2 = ( -auxdist, altur-margem );
111 z3 = ( auxdist, 0 );
112 z4 = ( -auxdist, 0 );
113 z5 = ( 0, auxdist );
114 fill circulbase shifted z1 withcolor amarel;
115 fill circulbase shifted z2 withcolor amarel;
116 fill circulbase shifted z3 withcolor amarel;
117 fill circulbase shifted z4 withcolor amarel;
118 fill circulbase shifted z5 withcolor amarel;
119 z6 = 0.5[z5,z1];
120 z7 = 0.5[z5,z2];
121 z8 = 0.5[z5,z3];
122 z9 = 0.5[z5,z4];
123 draw parduns rotated 45 shifted z6;
124 draw parduns rotated -45 shifted z7;
125 draw parduns rotated -45 shifted z8;
126 draw parduns rotated 45 shifted z9;
127 numeric actshift;
128 for orientang=45 step 90 until 360:
129 actshift := auxdist*sqrt(2) + 0.5diam + separ;
130 forever:
131 if uniformdeviate(1)<0.5:
132 actshift := actshift + espessum + 0.5separ;
133 draw parduns shifted (actshift,0) rotated orientang shifted z5;
134 exitif actshift>limitshift;
135 actshift := actshift + espessum + 0.5separ;
136 else:
137 actshift := actshift + 0.5diam;
138 fill circulbase shifted (actshift,0) rotated orientang shifted z5
139 withcolor amarel;
140 exitif actshift>limitshift;
141 actshift := actshift + 0.5diam;
142 fi;
143 actshift := actshift + separ;
144 endfor;
145 endfor;
146 endfig;
147
148 beginfig(4);
149 numeric u, hthick, vthick, lspace, espace, dspace, h, lbase, dbase;
150 numeric dinray, halfh, diffe;
151 u = 0.5mm;
152 hthick = 20u;
153 vthick = 10u;
154 lspace = 15u;
155 espace = 8u;
156 dspace = 8u;
157 h = 3*vthick+2*espace;
158 lbase = 38u;
159 dbase = 16u;
160 halfh = h/2;
161 dinray = halfh-vthick;
162 diffe = 2*vthick+espace-halfh;
163 path pathl, pathe, pathd, pathu;
164 z0 = (0,0);
165 z1 = (lbase,0);
166 z2 = (lbase,vthick);
167 z3 = (hthick,vthick);
168 z4 = (hthick,h);
169 z5 = (0,h);
170 pathl = z0--z1--z2--z3--z4--z5--cycle;
171 z6 = (lbase+lspace,0);
172 z7 = z6 + (h,0);
173 z8 = z7 + (0,vthick);
174 z9 = z6 + (vthick,vthick);
175 z10= z9 + (0,espace);
176 z11= z10+ (vthick,0);
177 z12= z11+ (-vthick,vthick);
178 z13= z6 + (-diffe,2*vthick+espace);
179 z14=z13+(diffe,-diffe);
180 pathe = z6--z7--z8--z9--z10--z11--z12--z13--z14--cycle;
181 z15= z7 + (dspace,0);
182 z16= z15+ (halfh,halfh);
183 z17= z15+ (0,h);
184 z18= z17- (halfh,0);
185 z19= z18+ (halfh,-halfh);
186 z20= z15+ (0,h-vthick);
187 z21= z20+ (dinray,-dinray);
188 z22= z15+ (0,vthick);
189 pathd = z15..z16..z17---z18--z19--z20..z21..z22--cycle;
190 z24= z6 + (-halfh,h);
191 z25= z24+ (h,0);
192 z26= z25+ (vthick,-vthick);
193 z27= z26- (h,0);
194 pathu = z24--z25--z26--z27--cycle;
195 fill pathl withcolor 0.78red;
196 fill pathe;
197 fill pathd;
198 fill pathu;
199 endfig;
200
201 end.
202