[NTG-context] Optimize code to create a environnementt with Metafun ?

Wolfgang Schuster schuster.wolfgang at gmail.com
Tue Jul 26 21:49:29 CEST 2016


> Fabrice Couvreur <mailto:fabrice1.couvreur at gmail.com>
> 26. Juli 2016 um 20:21
> Hi Hans,
> I think I was not very clear.
>
>
>
> Title first framed : Hans
>
> Title second framed : Hagen

You can pass a title to the optional framedtext argument (use camel case 
to avoid
using existing key names) and access the value later in the metapost 
graphic.

> Thanks
> Fabrice
>
> \setupbodyfont[pagella,11pt]
>
> \setupcolors[state=start]
>
> \defineframedtext
>   [MyFrame]
>   [before={\blank},
>    after={\blank},
>    frame=off,
>    background=MyFrame,
>    width=\textwidth,
width=max,
>    height=fit,
>    style=italic]
>
> \setvariables
>   [text]
>   [text1=Hans,
>    text2=Hagen,]
>
>
> \startuseMPgraphic{MyFrame}
>  path b;
>  picture p;
>  p := textext.rt("\white\getvariable{text}{text1}");

  p := textext.rt("\white\framedtextparameter{Title}");

>  p := p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight);
>  b := boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth;
>  fill OverlayBox withcolor 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
>
>
> \startMyFrame
> \input knuth
> \stopMyFrame
>
> \startMyFrame
> \input knuth
> \stopMyFrame

\startMyFrame[Title=Hans]
\input knuth
\stopMyFrame

\startMyFrame[Title=Hagen]
\input knuth
\stopMyFrame

Wolfgang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20160726/8a34327f/attachment.html>


More information about the ntg-context mailing list