Hello,
Hans and Wolfgang really helped me to create new environments with Metafun.
I think Hans continuous development Metafun. So my question is simple: can
we optimize this code ?
Thanks,
Fabrice

\setupbodyfont[pagella,11pt]

\setupcolors[state=start]

\defineframedtext
  [MyDefinition]
  [before={\blank},
   after={\blank},
   frame=off,
   background=MyFrame,
   width=\textwidth,
   height=fit,
   style=italic]

\definelabel
  [Définition]
  [headstyle=\bf\smallcaps]

\startuseMPgraphic{MyFrame}
 path b;
 picture p;
 p := textext.rt("\white\Définition");
 p := p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight);
 b := boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth;
 fill OverlayBox withcolor \MPcolor{lightgray};
 fill b withcolor darkred;
 draw bottomboundary OverlayBox withpen pencircle scaled 1pt  withcolor
darkred;
 draw topboundary OverlayBox withpen pencircle scaled 1pt  withcolor
darkred;
 draw p;
 setbounds currentpicture to boundingbox currentpicture enlarged 2mm;
\stopuseMPgraphic

\defineoverlay
  [MyFrame]
  [\useMPgraphic{MyFrame}]

\starttext

\showframe

\startMyDefinition
\input knuth
\stopMyDefinition

\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to