[metapost] String as macro parameter

Oliver Heck oliver.heck at oksol.de
Fri Mar 2 16:04:10 CET 2007


Hi there, I'm quite new to MetaPost, so sorry, if this is easy, but I 
couldn't find it in the manual:

I wrote a macro that should draw a rectangle with dimensions <breit> and 
<hoch>, filled with color <farbe> and there should be a text <whatever> 
in the lower right corner of it. Unfortunately I could not figure out 
how to pass the text inside that macro. Is it possible?

%============================================
def rechteck(expr hoch, breit, farbe, whatever) =
p0 := (0,0)--(0,hoch)--(breit,hoch)--(breit,0)--cycle ;
fill p0 withcolor farbe ; draw p0;
label.ulft(btex \scriptsize\textsf{whatever} etex,(breit,0u)) withcolor 
white ;
enddef ;

rechteck(1u,2u,red,total) ;
%============================================

Thank you,
Oliver


More information about the metapost mailing list