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