On 2013–03–04 Roland Thiers wrote:
I'm learning a little bit of metapost language, using metafun manual. I made some background for a title (surely the code is awful, thanks for suggestions of improvement) but it's static, i'd like to adapt it to the widthof the text. I don't know if it is possible from my code and if it is i don't know how to do !
You can use the variable OverlayWidth to obtain the width of the overlay, which is determined by the provided text. You can use it as follows:
\setuplayout [backspace=6cm]
\startuniqueMPgraphic{essai} path p,p',q,q';
w:=2OverlayWidth;
p := (0,0.1cm) -- (w,0.3cm); q := (11cm,-0.7cm) -- (w,2.2cm); p':= (w,1.3cm) -- (-0.4cm,1.4cm); q':= (0.3cm,2.4cm) -- (0.2cm,-0.3cm);
pickup pencircle scaled 1mm; drawoptions(withcolor 0.3white);
draw p; draw p'; draw q; draw q';
pair A; A:=q'intersectionpoint p'; pair B; B:=q intersectionpoint p'; pair C; C:=p intersectionpoint q; pair D; D:=q'intersectionpoint p; path s; s:= A--B--C--D--cycle;
fill s withcolor .8white; \stopuniqueMPgraphic
\defineoverlay [encadrement] [\uniqueMPgraphic{essai}]
\defineframed [boxframed] [frame=off, foregroundstyle=bolditalic, foregroundcolor=darkred, background=encadrement]
\starttext \boxframed{Devoir de mathématiques} \blank [2cm] \boxframed{Devoir de mathématiques and some more text} \stoptext
Marco Great ! Thank you very much, Marco ! I saw the use of the numeric variable OverlayWidth and also all your improvements
Le 4 mars 13 à 12:37, Marco Patzer a écrit : like drawoptions, defineframed ... in preamble. Roland
___________________________________________________________________________________ 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 ___________________________________________________________________________________