From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/95574 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 15:12:15 +0200 Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0125524271618165763==" X-Trace: ger.gmane.org 1469538779 12416 80.91.229.3 (26 Jul 2016 13:12:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Jul 2016 13:12:59 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Jul 26 15:12:47 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 1bS2AB-0001a1-96 for gctc-ntg-context-518@m.gmane.org; Tue, 26 Jul 2016 15:12:47 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 56C3C12F9D; Tue, 26 Jul 2016 15:12:36 +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 Zfgtj1a7pAVn; Tue, 26 Jul 2016 15:12:32 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id DF20113009; Tue, 26 Jul 2016 15:12:32 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 183A912F9D for ; Tue, 26 Jul 2016 15:12:32 +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 oLAgU5sdmcZV for ; Tue, 26 Jul 2016 15:12:28 +0200 (CEST) Original-Received: from mail-it0-f49.google.com (mail-it0-f49.google.com [209.85.214.49]) (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 4C4CD129E0 for ; Tue, 26 Jul 2016 15:12:18 +0200 (CEST) Original-Received: by mail-it0-f49.google.com with SMTP id f6so110463320ith.1 for ; Tue, 26 Jul 2016 06:12:18 -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=PGbeZ0XpqIWqIbjJTLybne8PWVT5vcNK72zF1/k36b8=; b=ktlZo9zjbr6sRAHmpSY/BBi94/WEl8AZd5zvmmx53yoho+3IOtQA5kC53SsiZXhdg+ 4lYmk3QbfliPjJNMK7o26GoXN9pGlGQemFZHpGmTnbdNvZvpBxiDjhBVoarCKBj17se8 KwjzJ927IKkRvvX6GjG7kl8TwHzB5jBs8lIfMz5QL0n2ImYY2byMcfnlXh0yX4DU9/gB NHHd2zQL89n0KjQThjwAXNT9U6625M/oZmvuAfm01c8JIs3xytCfSQKKoms51/5k8twN poF0NTgmSjVKgEmHVHy+rOVvQfqM5ds8EjzKEYF7cRmGnodOuG0MsoM5DXpsLdBBAhti 6Bgg== 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=PGbeZ0XpqIWqIbjJTLybne8PWVT5vcNK72zF1/k36b8=; b=erFvu0p+8t0qk+T5H5FR0ldZhcBOozSi6gVd9xhO0sqnkIhwcCnDaqP1LLWfK3xDsG PSJnMUz1CfRnCVneiTi2hD4wfNL01fLfxV9BdiHQfNlSvTn6ODEEKxw2XnDXoJVDW4mB ajgEYvyVEFxH4oMhTe9eF2wSGuuW5bv7kA/reLHbYZEHoH6h16aN8YewsTgBuTpkBGNh yLxH8f/Z+YiTk5UovM5WIKbGR4Rnvm7fHL8Gq7D7KjQZVdag41MRgQDeePyal5sr0g77 yYVoSrFI42GF4ELUpsA7MylGNxWlbRdutIU84anxYc4ZirzrpOhoXTvvqq1Jr/tjSrAG /Q5g== X-Gm-Message-State: ALyK8tLPAD+M7n+05inf5ZlSE6H4uUPOVUvzxBAshrm+NZ1EQ+hbM8O+ks64OGZnrEYmMwl8Gbh7zBuFr92GYA== X-Received: by 10.36.36.86 with SMTP id f83mr64161467ita.43.1469538736547; Tue, 26 Jul 2016 06:12:16 -0700 (PDT) Original-Received: by 10.64.212.204 with HTTP; Tue, 26 Jul 2016 06:12:15 -0700 (PDT) In-Reply-To: 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:95574 Archived-At: --===============0125524271618165763== Content-Type: multipart/alternative; boundary=001a1146ea94602d2a053889a6e3 --001a1146ea94602d2a053889a6e3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Hans, How to pass the "SomeText" parameter ? \setupbodyfont[pagella,11pt] \setupcolors[state=3Dstart] \defineframedtext [SomeText] [before=3D{\blank}, after=3D{\blank}, frame=3Doff, background=3DMyFrame, width=3D\textwidth, height=3Dfit, style=3Ditalic] \startuseMPgraphic{MyFrame} path b; picture p; p :=3D textext.rt("\white SomeText"); p :=3D p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight); b :=3D 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 \startSomeText{SomeText1} \input knuth \stopSomeText \startSomeText{SomeText2} \input knuth \stopSomeText \stoptext Thanks Fabrice 2016-07-26 12:34 GMT+02:00 Hans Hagen : > On 7/26/2016 10:18 AM, Fabrice Couvreur wrote: > >> Hello, >> Hans and Wolfgang really helped me to create new environments with >> Metafun. >> I think Hans continuous development Metafun. So my question is simple: >> can we optimize this code? >> > > in what sense ... > > speed? not much to gain > > correctness? mayhe use "lightgray" and "darkred" for consistency > > typography? sure, but more a discussion topic at the ctx meeting > > Thanks, >> Fabrice >> >> \setupbodyfont[pagella,11pt] >> >> \setupcolors[state=3Dstart] >> >> \defineframedtext >> [MyDefinition] >> [before=3D{\blank}, >> after=3D{\blank}, >> frame=3Doff, >> background=3DMyFrame, >> width=3D\textwidth, >> height=3Dfit, >> style=3Ditalic] >> >> \definelabel >> [D=C3=A9finition] >> [headstyle=3D\bf\smallcaps] >> >> \startuseMPgraphic{MyFrame} >> path b; >> picture p; >> p :=3D textext.rt("\white\D=C3=A9finition"); >> p :=3D p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeigh= t); >> b :=3D boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth; >> fill OverlayBox withcolor \MPcolor{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 >> >> \showframe >> >> \startMyDefinition >> \input knuth >> \stopMyDefinition >> >> \stoptext >> >> >> >> >> ________________________________________________________________________= ___________ >> If your question is of interest to others as well, please add an entry t= o >> 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 >> >> ________________________________________________________________________= ___________ >> >> > > -- > > ----------------------------------------------------------------- > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl > ----------------------------------------------------------------- > > _________________________________________________________________________= __________ > 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 > > _________________________________________________________________________= __________ --001a1146ea94602d2a053889a6e3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Hans,
How to pass the "= ;SomeText" parameter ?

\= setupbodyfont[pagella,11pt]

\setupcolors[state=3Dstart]

\defi= neframedtext
=C2=A0 [SomeText]
=C2=A0 [before=3D{\blank},
=C2=A0= =C2=A0 after=3D{\blank},
=C2=A0=C2=A0 frame=3Doff,
=C2=A0=C2=A0 backg= round=3DMyFrame,
=C2=A0=C2=A0 width=3D\textwidth,
=C2=A0=C2=A0 height= =3Dfit,
=C2=A0=C2=A0 style=3Ditalic]

\startuseMPgraphic{MyFrame}<= br>=C2=A0path b;
=C2=A0picture p;
=C2=A0p :=3D textext.rt("\whit= e SomeText");
=C2=A0p :=3D p shifted (2BodyFontSize,OverlayHeight-= ypart center p+.25ExHeight);
=C2=A0b :=3D boundingbox p leftenlarged .5E= mWidth rightenlarged .5EmWidth;
=C2=A0fill OverlayBox withcolor lightgra= y;
=C2=A0fill b withcolor darkred;
=C2=A0draw bottomboundary OverlayB= ox withpen pencircle scaled 1pt=C2=A0 withcolor darkred;
=C2=A0draw topb= oundary OverlayBox withpen pencircle scaled 1pt=C2=A0 withcolor darkred;=C2=A0draw p;
=C2=A0setbounds currentpicture to boundingbox currentpict= ure enlarged 2mm;
\stopuseMPgraphic

\defineoverlay
=C2=A0 [MyF= rame]
=C2=A0 [\useMPgraphic{MyFrame}]

\starttext


\star= tSomeText{SomeText1}
\input knuth
\stopSomeText

\startSomeText= {SomeText2}
\input knuth
\stopSomeText

\stoptext

Thanks
Fabrice

2016-07-26 12:34 GM= T+02:00 Hans Hagen <pragma@wxs.nl>:
On 7/26/2016 10:18 AM, Fabrice Couvreur wrote:
Hello,
Hans and Wolfgang really helped me to create new environments with Metafun.=
I think Hans continuous development Metafun. So my question is simple:
can we optimize this code?

in what sense ...

speed? not much to gain

correctness? mayhe use "lightgray" and "darkred" for co= nsistency

typography? sure, but more a discussion topic at the ctx meeting

Thanks,
Fabrice

\setupbodyfont[pagella,11pt]

\setupcolors[state=3Dstart]

\defineframedtext
=C2=A0 [MyDefinition]
=C2=A0 [before=3D{\blank},
=C2=A0 =C2=A0after=3D{\blank},
=C2=A0 =C2=A0frame=3Doff,
=C2=A0 =C2=A0background=3DMyFrame,
=C2=A0 =C2=A0width=3D\textwidth,
=C2=A0 =C2=A0height=3Dfit,
=C2=A0 =C2=A0style=3Ditalic]

\definelabel
=C2=A0 [D=C3=A9finition]
=C2=A0 [headstyle=3D\bf\smallcaps]

\startuseMPgraphic{MyFrame}
=C2=A0path b;
=C2=A0picture p;
=C2=A0p :=3D textext.rt("\white\D=C3=A9finition");
=C2=A0p :=3D p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHei= ght);
=C2=A0b :=3D boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth;<= br> =C2=A0fill OverlayBox withcolor \MPcolor{lightgray};
=C2=A0fill b withcolor darkred;
=C2=A0draw bottomboundary OverlayBox withpen pencircle scaled 1pt=C2=A0 wit= hcolor
darkred;
=C2=A0draw topboundary OverlayBox withpen pencircle scaled 1pt=C2=A0 withco= lor
darkred;
=C2=A0draw p;
=C2=A0setbounds currentpicture to boundingbox currentpicture enlarged 2mm;<= br> \stopuseMPgraphic

\defineoverlay
=C2=A0 [MyFrame]
=C2=A0 [\useMPgraphic{MyFrame}]

\starttext

\showframe

\startMyDefinition
\input knuth
\stopMyDefinition

\stoptext



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

maillist : ntg-cont= ext@ntg.nl / http://www.ntg.nl/mailman/listinfo/nt= g-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
___________________________________________________________________________= ________



--

-----------------------------------------------------------------
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 H= ans Hagen | PRAGMA ADE
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Ridderstraat 27 | 8061 GH = Hasselt | The Netherlands
=C2=A0 =C2=A0 =C2=A0 =C2=A0tel: 038 477 53 69 | www.pragma-ade.nl | www.p= ragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________= ________
If your question is of interest to others as well, please add an entry to t= he Wiki!

maillist : ntg-cont= ext@ntg.nl / http://www.ntg.nl/mailman/listinfo/nt= g-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
___________________________________________________________________________= ________

--001a1146ea94602d2a053889a6e3-- --===============0125524271618165763== 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= --===============0125524271618165763==--