29.11.2012 Views

MetaFun - Pragma ADE

MetaFun - Pragma ADE

MetaFun - Pragma ADE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

294<br />

\startuseMPgraphic{third}<br />

\includeMPgraphic{first}<br />

fill fullsquare scaled size withcolor bottomshade ;<br />

fill fullsquare scaled delta withcolor centershade ;<br />

\stopuseMPgraphic<br />

Because both graphics share code, we have defined that code as a separate graphic, that we include.<br />

The only point of interest in this definition is the fact that we let METAPOST interpolate between the<br />

two colors using .5[ ].<br />

\startuseMPgraphic{first}<br />

numeric size, delta ;<br />

size := 2.5cm ; delta := size/3 ;<br />

color mainshade, topshade, bottomshade, centershade ;<br />

mainshade := \MPcolor{funcolor} ;<br />

topshade := .9mainshade ; bottomshade := .5mainshade ;<br />

centershade := .5[topshade,bottomshade] ;<br />

\stopuseMPgraphic<br />

The color funcolor is provided by CONTEXT, and since we want to use this graphic with different<br />

colors, this kind of mapping is quite convenient. The bunch of graphics is packaged in a combination<br />

with empty captions. Note how we set the color before we include the graphic.<br />

\startcombination[5*2]<br />

{\definecolor[funcolor][red] \useMPgraphic{second}} {}<br />

{\definecolor[funcolor][green] \useMPgraphic{second}} {}<br />

{\definecolor[funcolor][blue] \useMPgraphic{second}} {}<br />

{\definecolor[funcolor][yellow]\useMPgraphic{second}} {}<br />

{\definecolor[funcolor][white] \useMPgraphic{second}} {}<br />

{\definecolor[funcolor][red] \useMPgraphic{third}} {}<br />

{\definecolor[funcolor][green] \useMPgraphic{third}} {}<br />

{\definecolor[funcolor][blue] \useMPgraphic{third}} {}<br />

{\definecolor[funcolor][yellow]\useMPgraphic{third}} {}<br />

{\definecolor[funcolor][white] \useMPgraphic{third}} {}<br />

\stopcombination<br />

We use a similar arrangement for the following graphic, where we have replaced the definitions<br />

of first, second and third by new definitions.<br />

The definition of the first row of figure 13.4 is used in the second and third and therefore is the<br />

most complicated. We use quite some scratch variables to reach a high level of abstraction. The<br />

xyscaled operator is a METAFUN macro.<br />

\startuseMPgraphic{first}<br />

numeric height, width, radius, gap ; gap := 1mm ;<br />

height = 2.5cm ; width := height/2 ; radius := height/2.5 ;<br />

color mainshade, leftshade, rightshade, centershade ;<br />

mainshade := \MPcolor{funcolor} ;<br />

leftshade := .9mainshade ; rightshade := .5mainshade ;<br />

centershade := .5[leftshade,rightshade] ;<br />

fill unitsquare xyscaled ( width,height) withcolor leftshade ;<br />

A few applications Fool yourself

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!