From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/95579 Path: news.gmane.org!not-for-mail From: Fabrice Couvreur Newsgroups: gmane.comp.tex.context Subject: Re: Optimize code to create a environnementt with Metafun ? Date: Tue, 26 Jul 2016 22:58:05 +0200 Message-ID: References: <86038346-3d77-2cb6-e45b-aa7f4f29e381@wxs.nl> <5797BEC9.7060009@gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0224740846449183838==" X-Trace: ger.gmane.org 1469566736 13910 80.91.229.3 (26 Jul 2016 20:58:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Jul 2016 20:58:56 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Jul 26 22:58:46 2016 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bS9R4-0001dg-FA for gctc-ntg-context-518@m.gmane.org; Tue, 26 Jul 2016 22:58:42 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id DF8E313081; Tue, 26 Jul 2016 22:58:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e1fJk2b6X5xY; Tue, 26 Jul 2016 22:58:21 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id 2B99B13082; Tue, 26 Jul 2016 22:58:21 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 90F3813082 for ; Tue, 26 Jul 2016 22:58:19 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0ohsU-NO4nF1 for ; Tue, 26 Jul 2016 22:58:18 +0200 (CEST) Original-Received: from mail-io0-f173.google.com (mail-io0-f173.google.com [209.85.223.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 4961613081 for ; Tue, 26 Jul 2016 22:58:08 +0200 (CEST) Original-Received: by mail-io0-f173.google.com with SMTP id m101so42656552ioi.2 for ; Tue, 26 Jul 2016 13:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=dH0z/5eKuJUIuz7ESJVlkDNoKTp7ceFVI5/ro5b4fbs=; b=J9cs53OQYlfz95Kv3T3mJjtAbbKdsA2HDv91YpHdAHMDmUvrvwIU60rhgLTTzF+zNS h3KaZBjta4O8U7p+BiG+DsOkN4P0IgnBAYXHJrwJX9cernIiN3yzXMu3r9fu+3wi5aJe lzEy6yhhgOdFaUMCt94IGMDRjGI2bl2Cke/h5GYzsbhZz8f47/UUpJciTJIyjMGBGz74 Z1UWOupSudYRLiGiIFsDDW8eY4eOBlGoShRHnt7OZ8zb0vbrMcrOETsa70RJ+vFGtbCu 3W9kOQmQDB+TWUrY0vcT7P8OzjmL2XZcOdtIxNeaNnaDi0n59OKxM7Unk4HrJDrCfmDd gPzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=dH0z/5eKuJUIuz7ESJVlkDNoKTp7ceFVI5/ro5b4fbs=; b=QIdOinOme7Gbi7wfQFaxQB0BWyWwM3rMDEihC3fNy0DkkgjRxdSPg9azhB1YJyCFuY YuK3MobkkAE6wtnP8nzSxreBTgfGruPjtwAsegAjb6BKQbh5/ClHMo+KWHhg0Ew825BX 7/CLeboSyE6McLwBYHrmIqxD5xILB8dVhDy9mbSbh9D+VsfQHy0Md3WqsSD87sGqhT+3 2cPykQaOfFLM4zPcMw2as7/7WTMJoL9ySMNWjwlerhJg83N/Bo7ZKVp+zA4CLnteC0IA PeykpVvDy67vVjcZRJvcmyWK4NY2seDA/6i0laBCCdmw92qAh79Nvug/Gjw8Vncqp/gr PYUA== X-Gm-Message-State: AEkoouujEbRNI2tqBSptmUdyGzF2n6xceOhMkVXMzMx2YyEI3evJlRf0Sw87cUb+RIXjzY0z8RB5MPYvFtR9DA== X-Received: by 10.107.168.229 with SMTP id e98mr27552988ioj.61.1469566686312; Tue, 26 Jul 2016 13:58:06 -0700 (PDT) Original-Received: by 10.64.212.204 with HTTP; Tue, 26 Jul 2016 13:58:05 -0700 (PDT) In-Reply-To: <5797BEC9.7060009@gmail.com> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:95579 Archived-At: --===============0224740846449183838== Content-Type: multipart/alternative; boundary=001a11426a364fbfa80538902820 --001a11426a364fbfa80538902820 Content-Type: text/plain; charset=UTF-8 Hi Wolfgang Thanks once again ! \startMyFrame[Title=Thanks ] \input knuth \stopMyFrame \startMyFrame[Title=once again !] \input knuth \stopMyFrame Fabrice 2016-07-26 21:49 GMT+02:00 Wolfgang Schuster : > Fabrice Couvreur > 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 > > > ___________________________________________________________________________________ > 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 > > ___________________________________________________________________________________ > --001a11426a364fbfa80538902820 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Wolfgang
Thanks once again !

\startMyFrame[Title= =3DThanks ]
\input knuth
\stopMyFrame

\startMyFrame[Title=3Donce again !]
\input knuth
\stopMyFrame

Fabrice

2016-07-26 21:49 GMT+02:00 Wolfgang Schuster <schuster.wolfgang@gmail.com>:
26.=20 Juli 2016 um 20:21
=
Hi Hans,
I think I was not very clear.



Title first=20 framed : Hans

Tit= le 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=20 graphic.

Thanks
Fabrice

\setupbodyfont[pagella,11pt]

\setupcolo= rs[state=3Dstart]

\defineframedtext
=C2=A0 [MyFrame]
=C2=A0 [before=3D{\blank},
=C2=A0=C2=A0 after=3D{\blank},<= br>=C2=A0=C2=A0 frame=3Doff,
=C2=A0=C2=A0 background=3DMyFrame,
=C2=A0=C2=A0 width=3D\textwidth,
width=3Dmax,
=C2=A0=C2=A0 height=3Dfit,
=C2=A0=C2=A0 style= =3Ditalic]

\setvariables
=C2=A0 [text]
=C2=A0 [text1=3DHans,
=C2=A0=C2=A0 text2=3DHagen,]
=C2=A0= =C2=A0

\startuseMPgraphic{MyFrame}
=C2=A0path b;
=C2=A0picture p;
=C2=A0p :=3D=20 textext.rt("\white\getvariable{text}{text1}");
=

=C2=A0p :=3D textext.rt("\white\framedtextparameter{Title}");

=C2=A0p :=3D p shifted=20 (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight);
=C2=A0b :=3D= =20 boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth;
=C2=A0fill= =20 OverlayBox withcolor lightgray;
=C2=A0fill b withcolor darkred;
=C2= =A0draw=20 bottomboundary OverlayBox withpen pencircle scaled 1pt=C2=A0 withcolor=20 darkred;
=C2=A0draw topboundary OverlayBox withpen pencircle scaled 1pt= =C2=A0=20 withcolor darkred;
=C2=A0draw p;
=C2=A0setbounds currentpicture to=20 boundingbox currentpicture enlarged 2mm;
\stopuseMPgraphic

\defin= eoverlay
=C2=A0 [MyFrame]
=C2=A0 [\useMPgraphic{MyFrame}]

\starttext


= \startMyFrame
\input knuth
\stopMyFrame

\startMyFrame
\input knuth
\stopMyFrame=


\startMyFrame[Title=3DHans]
\input knuth
\stopMyFrame

\startMyFrame[Title=3DHagen]
\input knuth
\stopMyFrame

Wolfgang

_______________________________________________________________________= ____________
If your question is of interest to others as well, please add an entry to t= he Wiki!

maillist : ntg-context@ntg.nl / <= a href=3D"http://www.ntg.nl/mailman/listinfo/ntg-context" rel=3D"noreferrer= " target=3D"_blank">http://www.ntg.nl/mailman/listinfo/ntg-context
webpage=C2=A0 : http://www.pragma-ade.nl / http://tex.aanhet.net
archive=C2=A0 : http://foundry.supelec.fr/projects/con= textrev/
wiki=C2=A0 =C2=A0 =C2=A0: http://contextgarden.net
___________________________________________________________________________= ________

--001a11426a364fbfa80538902820-- --===============0224740846449183838== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly90ZXguYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHA6Ly9mb3VuZHJ5LnN1cGVsZWMu ZnIvcHJvamVjdHMvY29udGV4dHJldi8Kd2lraSAgICAgOiBodHRwOi8vY29udGV4dGdhcmRlbi5u ZXQKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX18= --===============0224740846449183838==--