MetaFun - Pragma ADE
MetaFun - Pragma ADE MetaFun - Pragma ADE
176 paragraph, being the graphic. The line correction is needed to get the spacing around the rule (graphic) right. We pass a blank skip identifier that is mapped to a convenient medium skip. Why is this called an English line? \startnarrower \EnglishRule Is it because they cannot draw a straight one? This could be true after a few strong beers, but then, how do Germans draw a line? \EnglishRule \stopnarrower As expected, the rule adapts itself to the current width of the text. The height of the rule in the middle matches the height of a character with no ascenders and descenders. Why is this called an English line? Is it because they cannot draw a straight one? This could be true after a few strong beers, but then, how do Germans draw a line? 7.2 Random graphics Given enough time and paper, we can probably give you some reasons why METAPOST is fun. To mention a few: you can enhance the layout with graphic ornaments, you can tune your graphics at runtime, and simple high quality graphics can be very effective. The previous graphics draws exactly 1001 lines in a scratch--numbers--in--a--wall fashion. In 1998, the NTG did a survey among its members, and in the report, we used this fuzzy counter to enhance the rather dull tables. system % # users Atari 10.4 MSDOS 49.1 OS/2 9.4 MacOS 5.7 UNIX 51.9 WINDOWS 64.2 Table 7.1 Operating system (n=106). Shapes, symbols and buttons Random graphics
Table 7.1 demonstrates how scratch numbers can be used. An interesting side effect is that when you look long enough to these kind of graphics, it looks like the lines are no longer horizontal. This table is defined as follows: \starttabulate[|l|c|l|] \HL \NC system \NC \% \NC \# users \NC\NR \HL \NC Atari \NC 10.4 \NC \useMPgraphic{fuzzycount}{n=11} \NC\NR \NC MSDOS \NC 49.1 \NC \useMPgraphic{fuzzycount}{n=52} \NC\NR \NC OS/2 \NC ~9.4 \NC \useMPgraphic{fuzzycount}{n=10} \NC\NR \NC MacOS \NC ~5.7 \NC \useMPgraphic{fuzzycount}{n= 6} \NC\NR \NC UNIX \NC 51.9 \NC \useMPgraphic{fuzzycount}{n=55} \NC\NR \NC WINDOWS \NC 64.2 \NC \useMPgraphic{fuzzycount}{n=68} \NC\NR \HL \stoptabulate You will notice that we pass a variable to the graphic using a second argument. We can access this variable with \MPvar. The graphic is defined as usable graphic, because we want to generate a unique random one each time. \startuseMPgraphic{fuzzycount} begingroup save height, span, drift, d, cp ; height := 3/ 5 * \baselinedistance ; span := 1/ 3 * height ; drift := 1/10 * height ; pickup pencircle scaled (1/12 * height) ; def d = (uniformdeviate drift) enddef ; for i := 1 upto \MPvar{n} : draw if (i mod 5)=0 : ((-d-4.5span,d)--(+d-0.5span,height-d)) else : ((-d,+d)--(+d,height-d)) fi shifted (span*i,d-drift) ; endfor; picture cp ; cp := currentpicture ; % for readability setbounds currentpicture to (llcorner cp shifted (0,-ypart llcorner cp) -lrcorner cp shifted (0,-ypart lrcorner cp) -urcorner cp -- ulcorner cp -- cycle) ; endgroup ; \stopuseMPgraphic The core of the macro is the for loop. Within this loop, we draw groups of four plus one lines. The draw path's look a bit complicated, but this has to do with the fact that a mod returns 0 − 4 while we like to deal with 1 − 5. The height adapts itself to the height of the line. The bounding box correction at the end ensures that the baseline is consistent and that the random vertical offsets fall below the baseline. Random graphics Shapes, symbols and buttons 177
- Page 129 and 130: When we convert color to gray, we u
- Page 131 and 132: 4 Enhancing the layout One of the m
- Page 133 and 134: 4.2 Overlay variables [offset=3pt,f
- Page 135 and 136: This background demonstrates that a
- Page 137 and 138: As you may know, TEX's ambassador i
- Page 139 and 140: This works as expected: \RotatedTex
- Page 141 and 142: We will now apply this knowledge of
- Page 143 and 144: p := p shifted (2o,OverlayHeight-yp
- Page 145 and 146: We demonstrated that when defining
- Page 147 and 148: 5 Positional graphics In this chapt
- Page 149 and 150: 5.2 Anchors and layers In a previou
- Page 151 and 152: pab := pab cutafter (pab intersecti
- Page 153 and 154: fill p withcolor \MPcolor{lightgray
- Page 155 and 156: The previous example also demonstra
- Page 157 and 158: \setMPlayer [test] [somepos-1] [loc
- Page 159 and 160: 6 Page backgrounds Especially in in
- Page 161 and 162: As soon as you want to make an elec
- Page 163 and 164: do_it (1,4,false) ; do_it (5,4,fals
- Page 165 and 166: gigigi Watch how the bounding boxes
- Page 167 and 168: You can test this concept yourself
- Page 169 and 170: StartPage ; fill Area[Text][Text] s
- Page 171 and 172: fi ; Main := Main enlarged 6pt ; pi
- Page 173 and 174: ulcorner Field[Text] [Text] -urcorn
- Page 175 and 176: The left picture demonstrates what
- Page 177 and 178: There are two more operators: inner
- Page 179: 7 Shapes, symbols and buttons One c
- Page 183 and 184: for i := 1 upto \MPvar{n} : xpos :=
- Page 185 and 186: This table is defined as: \bTABLE[f
- Page 187 and 188: Since we have collected some nice b
- Page 189 and 190: 8 Special effects Sometimes we want
- Page 191 and 192: Because of this implementation, sha
- Page 193 and 194: test_shade(origin shifted (.25cm,0)
- Page 195 and 196: fill p shifted (3cm,0) withcolor .5
- Page 197 and 198: \definecolor [tred] [r=1,t=.5,a=exc
- Page 199 and 200: Figure 8.4 Another clipped cow. \pl
- Page 201 and 202: withpen pencircle scaled 4mm withco
- Page 203 and 204: Because this graphic is the result
- Page 205 and 206: The resulting PDF file can be inclu
- Page 207 and 208: Including another METAPOST graphic,
- Page 209 and 210: After these examples your are proba
- Page 211 and 212: In this graphic, we have two text f
- Page 213 and 214: } {}} Here we feed some MATHML int
- Page 215 and 216: 9 Functions METAPOST provides a wid
- Page 217 and 218: 9.2 Grids Some day you may want to
- Page 219 and 220: 13 13 13 13 Figure 9.1 Quick and di
- Page 221 and 222: 2 − ×10 1 − 1 0×100 Figure 9.
- Page 223 and 224: Figure 9.3 By using transparent col
- Page 225 and 226: There are enough applications out t
- Page 227 and 228: Of course we could extend this LUA
- Page 229 and 230: 10 Typesetting in METAPOST It is sa
176<br />
paragraph, being the graphic. The line correction is needed to get the spacing around the rule<br />
(graphic) right. We pass a blank skip identifier that is mapped to a convenient medium skip.<br />
Why is this called an English line?<br />
\startnarrower<br />
\EnglishRule<br />
Is it because they cannot draw a straight one? This<br />
could be true after a few strong beers, but then, how<br />
do Germans draw a line?<br />
\EnglishRule<br />
\stopnarrower<br />
As expected, the rule adapts itself to the current width of the text. The height of the rule in the<br />
middle matches the height of a character with no ascenders and descenders.<br />
Why is this called an English line?<br />
Is it because they cannot draw a straight one? This could be true after a few strong beers,<br />
but then, how do Germans draw a line?<br />
7.2 Random graphics<br />
Given enough time and paper, we can probably give you some<br />
reasons why METAPOST is fun. To mention a few: you can enhance the layout with graphic ornaments,<br />
you can tune your graphics at runtime, and simple high quality graphics can be very<br />
effective.<br />
The previous graphics draws exactly 1001 lines in a scratch--numbers--in--a--wall fashion. In 1998,<br />
the NTG did a survey among its members, and in the report, we used this fuzzy counter to enhance<br />
the rather dull tables.<br />
system % # users<br />
Atari 10.4<br />
MSDOS 49.1<br />
OS/2 9.4<br />
MacOS 5.7<br />
UNIX 51.9<br />
WINDOWS 64.2<br />
Table 7.1 Operating system (n=106).<br />
Shapes, symbols and buttons Random graphics