MetaFun - Pragma ADE
MetaFun - Pragma ADE MetaFun - Pragma ADE
312 boolean trace_euro ; trace_euro := false ; vardef euro_symbol = image ( % begin_of_euro if unknown euro_radius : euro_radius := 2cm ; fi ; if unknown euro_width : euro_width := 3euro_radius/16 ; fi ; if unknown euro_r_offset : euro_r_offset := euro_width ; fi ; if unknown euro_l_offset : euro_l_offset := euro_radius/32 ; fi ; if unknown euro_l_shift : euro_l_shift := euro_r_offset ; fi ; if unknown euro_v_delta : euro_v_delta := euro_width/4 ; fi ; save outer_circle, inner_circle, hor_bar, right_line, right_slant, top_slant, bot_slant, euro_circle, euro_topbar, euro_botbar ; path outer_circle, inner_circle, hor_bar, right_line, right_slant, top_slant, bot_slant, euro_circle, euro_topbar, euro_botbar ; outer_circle := fullcircle scaled euro_radius ; inner_circle := fullcircle scaled (euro_radius-euro_width) ; if trace_euro : for i = outer_circle, inner_circle : draw i withpen pencircle scaled 1pt withcolor .5white ; endfor ; fi ; right_line := (lrcorner outer_circle -- urcorner outer_circle) shifted (-euro_r_offset,0) ; outer_circle := outer_circle cutbefore right_line ; right_slant := point 0 of outer_circle -- origin shifted (0,ypart lrcorner outer_circle) ; euro_circle := buildcycle(outer_circle, right_line, reverse inner_circle, reverse right_slant) ; hor_bar := (-euro_radius,0) -- (euro_radius,0) ; top_slant := right_slant shifted (-euro_radius+euro_r_offset-euro_l_offset,0) ; bot_slant := top_slant shifted (0,-euro_l_shift) ; if trace_euro : for i = right_line, right_slant, top_slant, bot_slant : A few applications The euro symbol
draw i withpen pencircle scaled 1pt withcolor .5white ; endfor ; fi ; euro_topbar := buildcycle (top_slant, hor_bar shifted (0, euro_v_delta), right_slant, hor_bar shifted (0, euro_v_delta+euro_width/2)) ; euro_botbar := buildcycle (bot_slant, hor_bar shifted (0,-euro_v_delta), right_slant, hor_bar shifted (0,-euro_v_delta-euro_width/2)) ; for i = euro_circle, euro_topbar, euro_botbar : draw i withpen pencircle scaled 0 ; endfor ; for i = euro_circle, euro_topbar, euro_botbar : fill i withpen pencircle scaled 0 ; endfor ; if trace_euro : drawpoints euro_circle withcolor red ; drawpoints euro_topbar withcolor green ; drawpoints euro_botbar withcolor blue ; fi ; ) enddef ; % end_of_euro We only set a parameter when it is not yet set. This has the advantage that we don't have to set them when we change one. This way of manipulating paths (cutting and building) does not always work well because of rounding errors, but here it does work. euro_radius := 4cm ; trace_euro := true ; draw euro_symbol ; For educational purposes, we have added a bit of tracing. When enabled, the euro shows up as: The euro symbol A few applications 313
- Page 265 and 266: 12 Defining styles Since the integr
- Page 267 and 268: color=gray, contrastcolor=gray, sty
- Page 269 and 270: def right_menu_button (expr nn, rr,
- Page 271 and 272: \Topic {Edward R. Tufte} \input tuf
- Page 273 and 274: A Few Nice Quotes A Simple Style De
- Page 275 and 276: 13 A few applications For those who
- Page 277 and 278: vardef spring (expr a, b, w, h, n)
- Page 279 and 280: There is a numeric constant labelof
- Page 281 and 282: text text text text text text text
- Page 283 and 284: p := fullcircle scaled (2*length(lo
- Page 285 and 286: These definitions of anglebetween a
- Page 287 and 288: Because in most cases we want the l
- Page 289 and 290: γ δ β ɛ α ζ δ γ β ɛ metho
- Page 291 and 292: There are for sure more (efficient)
- Page 293 and 294: The next circle that we draw shows
- Page 295 and 296: popcurrentpicture ; enddef ; Here,
- Page 297 and 298: draw (u,i) -- (2u,i) withcolor .5wh
- Page 299 and 300: Figure 13.4 Koffka's examples of ma
- Page 301 and 302: \startbuffer[a] def start_everythin
- Page 303 and 304: pointC := circleA intersectionpoint
- Page 305 and 306: draw_basics ; draw_circles ; draw_i
- Page 307 and 308: Figure 13.6 Bisecting a line segmen
- Page 309 and 310: z1 = (0, height/2) ; z2 = (width/2-
- Page 311 and 312: The clipping path is applied by say
- Page 313 and 314: 13.8 Music sheets The next example
- Page 315: The euro symbol A few applications
- Page 319 and 320: 16 draw b withpen pencircle scaled
- Page 321 and 322: \startMPcode \includeMPgraphic{gamb
- Page 323 and 324: 14 METAFUN macros CONTEXT comes wit
- Page 325 and 326: A METAPOST syntax In the METAFONT b
- Page 327 and 328: 〈number or fraction〉 → 〈num
- Page 329 and 330: 〈suffix〉 → 〈empty〉 | 〈s
- Page 331 and 332: 〈assignment〉 → 〈variable〉
- Page 333 and 334: 〈command〉 → clip 〈picture v
- Page 335 and 336: 〈if test〉 → if 〈boolean exp
- Page 337 and 338: B This document This document is pr
- Page 339 and 340: C Reference C.1 Paths In this chapt
- Page 341 and 342: tension atleast numeric (0,0)..(.75
- Page 343 and 344: angle origin--dir(angle(1,1)) metap
- Page 345 and 346: circle bcircle metafun variable lci
- Page 347 and 348: path randomized numeric/pair unitsq
- Page 349 and 350: path stretched numeric/pair (fullci
- Page 351 and 352: path zscaled pair fullcircle zscale
- Page 353 and 354: path llenlarged numeric fullcircle
- Page 355 and 356: path urmoved numeric fullcircle urm
- Page 357 and 358: everse path reverse fullcircle shif
- Page 359 and 360: oundingbox path boundingbox fullcir
- Page 361 and 362: C.3 Points top pair top center full
- Page 363 and 364: C.4 Attributes withcolor rgbcolor w
- Page 365 and 366: draw draw fullcircle metapost macro
312<br />
boolean trace_euro ; trace_euro := false ;<br />
vardef euro_symbol = image ( % begin_of_euro<br />
if unknown euro_radius : euro_radius := 2cm ; fi ;<br />
if unknown euro_width : euro_width := 3euro_radius/16 ; fi ;<br />
if unknown euro_r_offset : euro_r_offset := euro_width ; fi ;<br />
if unknown euro_l_offset : euro_l_offset := euro_radius/32 ; fi ;<br />
if unknown euro_l_shift : euro_l_shift := euro_r_offset ; fi ;<br />
if unknown euro_v_delta : euro_v_delta := euro_width/4 ; fi ;<br />
save<br />
outer_circle, inner_circle, hor_bar,<br />
right_line, right_slant, top_slant, bot_slant,<br />
euro_circle, euro_topbar, euro_botbar ;<br />
path<br />
outer_circle, inner_circle, hor_bar,<br />
right_line, right_slant, top_slant, bot_slant,<br />
euro_circle, euro_topbar, euro_botbar ;<br />
outer_circle := fullcircle scaled euro_radius ;<br />
inner_circle := fullcircle scaled (euro_radius-euro_width) ;<br />
if trace_euro : for i = outer_circle, inner_circle :<br />
draw i withpen pencircle scaled 1pt withcolor .5white ;<br />
endfor ; fi ;<br />
right_line :=<br />
(lrcorner outer_circle -- urcorner outer_circle)<br />
shifted (-euro_r_offset,0) ;<br />
outer_circle := outer_circle cutbefore right_line ;<br />
right_slant :=<br />
point 0 of outer_circle<br />
-- origin shifted (0,ypart lrcorner outer_circle) ;<br />
euro_circle := buildcycle(outer_circle, right_line,<br />
reverse inner_circle, reverse right_slant) ;<br />
hor_bar := (-euro_radius,0) -- (euro_radius,0) ;<br />
top_slant :=<br />
right_slant shifted (-euro_radius+euro_r_offset-euro_l_offset,0) ;<br />
bot_slant :=<br />
top_slant shifted (0,-euro_l_shift) ;<br />
if trace_euro : for i = right_line, right_slant, top_slant, bot_slant :<br />
A few applications The euro symbol