* text overlayed
@ 2013-03-04 11:02 Roland Thiers
2013-03-04 11:37 ` Marco Patzer
0 siblings, 1 reply; 3+ messages in thread
From: Roland Thiers @ 2013-03-04 11:02 UTC (permalink / raw)
To: ntg-context
Hello all,
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 !
Thanks for any help,
best regards, Roland
My code :
\setuplayout[width=fit,height=fit,header=0cm,topspace=1.8cm,footer=1.2cm,%
bottomspace=1cm,backspace=6cm,leftmargin=1.5cm,
leftmargindistance=0.5cm,rightmargin=1cm,rightmargindistance=0.5cm,
location=singlesided]
\startuniqueMPgraphic{essai}
path p,p',q,q';
p:=(0,0.1cm)--(12cm,0.3cm);
q:=(11cm,-0.7cm)--(11.5cm,2.2cm);
p':=(11.7cm,1.3cm)--(-0.4cm,1.4cm);
q':=(0.3cm,2.4cm)--(0.2cm,-0.3cm);
draw p withpen pencircle scaled 1mm withcolor 0.3white;
draw p' withpen pencircle scaled 1mm withcolor 0.3white;
draw q withpen pencircle scaled 1mm withcolor 0.3white;
draw q' withpen pencircle scaled 1mm withcolor 0.3white;
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
\starttext
\defineoverlay[encadrement][\uniqueMPgraphic{essai}]
\framed[frame=off,background=encadrement]{\it\tfb\color[darkred]{Devoir de
mathématiques}}
\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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: text overlayed
2013-03-04 11:02 text overlayed Roland Thiers
@ 2013-03-04 11:37 ` Marco Patzer
2013-03-04 13:30 ` Roland Thiers
0 siblings, 1 reply; 3+ messages in thread
From: Marco Patzer @ 2013-03-04 11:37 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 1491 bytes --]
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
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: text overlayed
2013-03-04 11:37 ` Marco Patzer
@ 2013-03-04 13:30 ` Roland Thiers
0 siblings, 0 replies; 3+ messages in thread
From: Roland Thiers @ 2013-03-04 13:30 UTC (permalink / raw)
To: mailing list for ConTeXt users
Le 4 mars 13 à 12:37, Marco Patzer a écrit :
> 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
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
> ___________________________________________________________________________________
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-04 13:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-04 11:02 text overlayed Roland Thiers
2013-03-04 11:37 ` Marco Patzer
2013-03-04 13:30 ` Roland Thiers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).