[NTG-context] Center a text (Metafun)

Hans Hagen j.hagen at xs4all.nl
Sat Mar 6 12:36:15 CET 2021


On 3/6/2021 11:17 AM, Fabrice Couvreur wrote:
> Hi Hans,
> Some time ago, you offered this code to respond to a specific request 
> from me. I used this code again and wanted to know if it was possible 
> for the title "Algorithm" to be automatically centered based on the content.
> Thank you

See Wolfgangs answer.

If your using lmtx ...

\startuseMPgraphic{MyFrame}
      picture p ;
      p := lmt_text [
         width  = OverlayWidth,
         height = OverlayHeight,
         text   = "\bfx\framedtextparameter{Title}",
         color  = "white",
         align  = "normal",
      ] ;
      p := anchored.ulft (p, ulcorner OverlayBox shifted (0,EmWidth)) ;
      fill OverlayBox withcolor "MyBlue" ;
      fill boundingbox p enlarged .5EmWidth withcolor "maincolor" ;
      draw p ;
      setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

watch how also maincolor is accessed as string.

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list