1 \startenvironment ma-cb-graphics
3 % We use \METAPOST\ to generate fancy shapes at run time. While
4 % typesetting this manual, \TEX\ therefore calls about
5 % 750||1000 times for \METAPOST. This kind of graphic inclusion
6 % is still under development, but at the moment already rather
7 % robust. Adding fancy shapes is a three step proces:
9 % \startopsomming[n,opelkaar]
10 % \som define a MP graphic
11 % \som call this graphic as overlay
12 % \som attach this overlay as background
15 % Some graphics are reused, but the random and deeply buried
16 % ones are generated any time they're needed.
18 % When producing the PDF version, we enable object handling,
19 % a feature that is not yet implemented in a higher level
20 % command. (is now automatic)
22 % \doifmode{screen}{\useMPboxtrue}
24 % We don't use MP graphics that use fonts, so here's a time
25 % saving switch, again not meant for common users.
27 \DontUseMetaPostGraphics
29 % Some bounding box hack.
35 % Here are the graphics themselves. The reusable ones are
36 % saved under names specifying their dimensions and some more
37 % etc. Those shapes evolved and probably can be defined more
38 % efficient. Let it be. In some occasions we fool around with
39 % the dimensions. This is on purpose!
41 % Will be reprogrammed to use parameters ! ! ! ! ! messy now
43 \def\MPclipOne#1#2#3#4#5%
44 {\startuseMPgraphic{clip:one
}
45 w :=
#1; width :=
100; wfactor := w/width;
46 h :=
#2; height :=
100; hfactor := h/height;
48 color lightred; lightred := (
.90,
.50,
.50);
49 color lightgray; lightgray := (
.95,
.95,
.95);
50 color gray; gray := (
.50,
.50,
.50);
52 def random_delta (expr d) =
61 z5 = (width+random_delta(
.2width),height+random_delta(
.2height));
62 z6 = (
.5width+random_delta(
.1width),height+random_delta(
.1height));
66 yscaled (
#3/(
2*hfactor))
69 draw z5..z1..z2..z3..z4..z6 withcolor
#4;
82 newwidth := (xpart (urcorner currentpicture)) -
83 (xpart (llcorner currentpicture));
84 newheight := (ypart (urcorner currentpicture)) -
85 (ypart (llcorner currentpicture));
87 currentpicture := currentpicture
88 xscaled (w/newwidth) yscaled (h/newheight);
90 \useMPgraphic{clip:one
}{}}
92 \def\MPclipTwo#1#2#3#4#5#6% \unexpanded goes wrong in etex!
97 color lightred; lightred := (
.90,
.50,
.50);
98 color lightgray; lightgray := (
.95,
.95,
.95);
99 color gray; gray := (
.50,
.50,
.50);
102 g :=
#4; ((g/
3) + (uniformdeviate (
2g/
3)))
110 x12=
.5[x1,x2
]; y12=y1+gamma;
111 y23=
.5[y2,y3
]; x23=x2-gamma;
112 x34=
.5[x3,x4
]; y34=y3-gamma;
113 y41=
.5[y4,y1
]; x41=x4+gamma;
126 draw p withcolor
#5;
}
128 \def\MPclipTwoA#1#2#3#4#5#6%
129 {\startreusableMPgraphic{clip:twoA:
#1#2#3}{}
130 \MPclipTwo{#1}{#2}{#3}{#4}{#5}{#6}%
131 \stopreusableMPgraphic
132 \reuseMPgraphic{clip:twoA:
#1#2#3}{}}
134 \def\MPclipTwoB#1#2#3#4#5#6%
135 {\startuseMPgraphic{clip:twoB
}{}
136 \MPclipTwo{#1}{#2}{#3}{#4}{#5}{#6}%
138 \useMPgraphic{clip:twoB
}{}}
140 \def\MPclipThree#1#2% no reuse here, due to pre-processing
141 {\startuseMPgraphic{clip:three
}{}
152 draw z1--z2 withcolor (
.5,
.5,
.5);
157 draw z1 withcolor green;
158 draw z2 withcolor green;
161 \useMPgraphic{clip:three
}{}}
163 \def\MPclipFourR#1#2#3%
164 {\startreusableMPgraphic{clip:fourR:
#1#2#3}{}
168 height := (
#2-delta)/
3;
172 z3 = (width,
1.5height);
181 draw z1--z2
{up
}..z3..
{up
}z4--z5 withcolor (
.5,
.5,
.5);
186 draw z1 withcolor red;
187 draw z2 withcolor red;
188 draw z3 withcolor red;
189 draw z4 withcolor red;
190 draw z5 withcolor red;
192 \stopreusableMPgraphic
193 \reuseMPgraphic{clip:fourR:
#1#2#3}{}}
195 \def\MPclipFourL#1#2#3%
196 {\startreusableMPgraphic{clip:fourL:
#1#2#3}{}
200 height := (
#2-delta)/
3;
204 z3 = (-width,
1.5height);
213 draw z1--z2
{up
}..z3..
{up
}z4--z5 withcolor (
.5,
.5,
.5);
218 draw z1 withcolor red;
219 draw z2 withcolor red;
220 draw z3 withcolor red;
221 draw z4 withcolor red;
222 draw z5 withcolor red;
224 \stopreusableMPgraphic
225 \reuseMPgraphic{clip:fourL:
#1#2#3}{}}
227 \def\MPclipFive#1#2#3#4%
228 {\startreusableMPgraphic{clip:five:
#1#2#3#4}{}
237 z3 = (
.5width,height);
238 z4 = (width-lines,
0);
246 draw z1--z2
{dir
135}...z3...
{dir -
135}z4--z5 withcolor (
.5,
.5,
.5);
251 draw z1 withcolor red;
252 draw z2 withcolor red;
253 draw z3 withcolor red;
254 draw z4 withcolor red;
255 draw z5 withcolor red;
257 \stopreusableMPgraphic
258 \reuseMPgraphic{clip:five:
#1#2#3#4}{}}
261 {\startreusableMPgraphic{clip:six:
#1#2}{}
266 color green; green := (
.1,
.8,
.1);
274 draw z1--z2 withcolor (
.5,
.5,
.5);
279 draw z1 withcolor green;
280 draw z2 withcolor green;
282 \stopreusableMPgraphic
283 \reuseMPgraphic{clip:six:
#1#2}{}}
285 \def\MPclipSeven#1#2#3%
286 {\startreusableMPgraphic{clip:seven:
#1#2}{}
292 color green; green := (
.1,
.8,
.1);
294 x1 = x4 =
0; x2 = x3 = width;
295 y1 = y2 =
0; y3 = y4 = height;
300 draw z1--z2--z3--z4--cycle withcolor (
.5,
.5,
.5);
305 draw z1 withcolor green;
306 draw z2 withcolor green;
307 draw z3 withcolor green;
308 draw z4 withcolor green;
310 \stopreusableMPgraphic
311 \reuseMPgraphic{clip:seven:
#1#2}{}}