From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106805 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context Subject: Re: Why does this example from the MetaFun manual not work? Date: Thu, 9 Apr 2020 10:40:55 +0200 Message-ID: References: <142DE083-83F9-4F5C-84E3-DFE90DF08C27@rna.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="===============3234462489844441803==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="36944"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Apr 09 10:41:18 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMSkP-0009WP-GR for gctc-ntg-context-518@m.gmane-mx.org; Thu, 09 Apr 2020 10:41:17 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 8C8AD1831F4; Thu, 9 Apr 2020 10:41:02 +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 DxnGLtNV2Yv8; Thu, 9 Apr 2020 10:41:01 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 6B5791831BB; Thu, 9 Apr 2020 10:41:01 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 5A84C18300F for ; Thu, 9 Apr 2020 10:41:00 +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 RxG9TSaEKuGh for ; Thu, 9 Apr 2020 10:40:59 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=213.125.118.53; helo=mail.rna.nl; envelope-from=gerben.wierda@rna.nl; receiver= Original-Received: from mail.rna.nl (mail.rna.nl [213.125.118.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 317F6181EBB for ; Thu, 9 Apr 2020 10:40:58 +0200 (CEST) Original-Received: from hermione.rna.nl (hermione.rna.nl [192.168.2.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.rna.nl (Postfix) with ESMTPSA id 0572F3D092AF for ; Thu, 9 Apr 2020 10:40:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1586421656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PsEln4yRamLQWIvsW7fEARSngjV8N28yfqvcPmoSUPE=; b=EIRYiRrj19C2tozewa7Q2D40LmfiIWX8vTFtnBm0nLE2dSZiaxtYy+nvSH3x+PprRlRkm8 zSp7dhETcdJdnPLhM6teZbJD8xeJIz8x6943P7FESOWc9AaP8iIYStgqKDNH8sprxpV+gH jgzA3braeu+LPahaLc9QSmqamlCJFeWcqy3wbJj1LbQVJXleIxchGNwYfL9i4iFp+iOL7u I4sEr5wLa6sLSbUMGyj+4/TBqWxGZxqG7+BEWuTaS1FhAtNmB5OZte4JoGxhebZxcxygFL 9e2XvnjyMe5caGGEiWmW5GBf+b/3VLsuRU3KqbgA07fvbO/5ikuZ9PpX+XwVnA== In-Reply-To: X-Mailer: Apple Mail (2.3445.104.14) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 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.io gmane.comp.tex.context:106805 Archived-At: --===============3234462489844441803== Content-Type: multipart/alternative; boundary="Apple-Mail=_F75A8893-08DC-4C75-B0CD-7C9BFB2DF235" --Apple-Mail=_F75A8893-08DC-4C75-B0CD-7C9BFB2DF235 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Thank you. > On 9 Apr 2020, at 10:01, Taco Hoekwater wrote: >=20 > Hi Gerben, >=20 > Changing the macro header to this will work: >=20 > vardef SampleText (expr t)(text c) =3D >=20 > or you can use the answer from stackexchange, same approach. > BTW Hans would like people to use =E2=80=9Cwithtransparency=E2=80=9D = instead as that is a=20 > newer, more flexible approach (but that would also need the above = change, > or a split into multiple parameters). Oh, wait, I think I understand it. I would still do vardef SampleText (expr t)(text c) =3D and the call is SampleText( t, somecolor withtransparency = sometransparency) So, use withtrapsparency in the call? I tried \starttext \startMPpage[instance=3Ddoublefun] vardef SampleText (expr t)(text c)(text d) =3D save p ; picture p ; p :=3D image (draw t infont "\truefontname{Regular}") ; draw (p shifted (- xpart center p,0)) scaled 5 withcolor c; draw (p shifted (- ypart center p,0)) scaled 5 withcolor d; enddef; SampleText ("Much Of This", transparent(1, .5, red ) , transparent(1, = .5, green )) ; \stopMPpage \stoptext But that does not work. Mmm. Maybe I need another approach to pass 4 = values (r,g,b,t) as one parameter. G=20 >=20 > Taco >=20 >=20 >> On 9 Apr 2020, at 09:04, Gerben Wierda wrote: >>=20 >> Nobody? >>=20 >>> On 8 Apr 2020, at 12:20, Gerben Wierda wrote: >>>=20 >>> I would like to use the result of transparent() straight in my = macros, so I can pass the colors with transparency using a single = parameter. That should be possible if I understand the MetaFun manual = (where I=E2=80=99ve copy-pasted this example from): >>>=20 >>> \starttext >>> \startMPpage[instance=3Ddoublefun] >>>=20 >>> vardef SampleText (expr t, c) =3D >>> save p ; picture p ; >>> p :=3D image (draw t infont "\truefontname{Regular}") ; >>> draw (p shifted (- xpart center p,0)) scaled 5 withcolor c; >>> enddef ; >>> SampleText ("Much Of This" , transparent(1, .5, red )) ; >>> SampleText ("Functionality" , transparent(1, .5, green)) ; >>> SampleText ("Was Written" , transparent(1, .5, blue )) ; >>> SampleText ("While Listening", transparent(1, .5, cmyk(1,0,0,0))) ; >>> SampleText ("To the CD's Of" , transparent(1, .5, cmyk(0,1,0,0))) ; >>> SampleText ("Tori Amos" , transparent(1, .5, cmyk(0,0,1,0))) ; >>>=20 >>> \stopMPpage >>> \stoptext >>>=20 >>> But it results in: >>>=20 >>> system > files > jobname 'testcolor', input './testcolor', = result 'testcolor' >>> fonts > latin modern fonts are not preloaded >>> languages > language 'en' is active >>> open source > level 2, order 3, name './testcolor.tex' >>> fonts > preloading latin modern fonts (second stage) >>> fonts > 'fallback modern-designsize rm 12pt' is loaded >>> metapost > initializing instance 'doublefun:1' using format = 'metafun' and method 'double' >>> metapost > loading 'metafun' as = '/usr/local/context-osx-64/tex/texmf-context/metapost/context/base/mpiv/me= tafun.mpxl' using method 'double' >>> metapost > initializing number mode 'double' >>> metapost log >=20 >>> metapost log > loading metafun, including plain.mp version 1.004 = for metafun iv and xl >>> metapost log >=20 >>> metapost log > ! Missing ')' has been inserted. >>> metapost log > =20 >>> metapost log > withprescript >>> metapost log > transparent->(1)withprescript >>> metapost log > = "tr_alternative=3D"&decimal.transparency_alternat... >>> metapost log > <*> ... ("Much Of This" , transparent(1, .5, red ) >>> metapost log > = ) ; SampleText ("Functiona... >>> metapost log >=20 >>> backend > xmp > using file = '/usr/local/context-osx-64/tex/texmf-context/tex/context/base/mkiv/lpdf-pd= x.xml' >>> pages > flushing realpage 1, userpage 1, subpage 1 >>> close source > level 2, order 3, name './testcolor.tex' >>> close source > level 1, order 3, name 'cont-yes.mkiv' >>>=20 >>> For me, it is not about passing colour on to ConTeXt to typeset = text, these are colors that normally would be drawn with =E2=80=9Cwithcolo= r ca withtransparency (method,factor)=E2=80=9D but that requires the = passing of many more parameters and a lot more work in coding. >>>=20 >>> Does transparent() maybe produce a string that looks like =E2=80=9Cca = withtransparency (method,factor)=E2=80=9D so something only usable in = draw/fill/etc statements? But in that case how does that work without = scantokens to parse the string? >>>=20 >>> Is there a way I can do this without having twice the parameters = (and I have to pass multiple colours) in my macros everywhere? >>>=20 >>> Thanks, >>>=20 >>> G >>> = __________________________________________________________________________= _________ >>> If your question is of interest to others as well, please add an = entry to the Wiki! >>>=20 >>> maillist : ntg-context@ntg.nl / = http://www.ntg.nl/mailman/listinfo/ntg-context >>> webpage : http://www.pragma-ade.nl / http://context.aanhet.net >>> archive : https://bitbucket.org/phg/context-mirror/commits/ >>> wiki : http://contextgarden.net >>> = __________________________________________________________________________= _________ >>=20 >> = __________________________________________________________________________= _________ >> If your question is of interest to others as well, please add an = entry to the Wiki! >>=20 >> maillist : ntg-context@ntg.nl / = http://www.ntg.nl/mailman/listinfo/ntg-context >> webpage : http://www.pragma-ade.nl / http://context.aanhet.net >> archive : https://bitbucket.org/phg/context-mirror/commits/ >> wiki : http://contextgarden.net >> = __________________________________________________________________________= _________ >=20 > Taco Hoekwater > Elvenkind BV >=20 >=20 >=20 >=20 > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > maillist : ntg-context@ntg.nl / = http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > = __________________________________________________________________________= _________ --Apple-Mail=_F75A8893-08DC-4C75-B0CD-7C9BFB2DF235 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Thank= you.


On 9 Apr = 2020, at 10:01, Taco Hoekwater <taco@elvenkind.com> wrote:

Hi = Gerben,

Changing the macro header to this = will work:

  vardef SampleText = (expr t)(text c) =3D

or you can use the = answer from stackexchange, same approach.

BTW Hans would = like people to use =E2=80=9Cwithtransparency=E2=80=9D instead as that is = a
newer, more flexible approach (but that would also need = the above change,
or a split into multiple parameters).

Oh, = wait, I think I understand it. I would still do

vardef SampleText (expr t)(text c) = =3D

and the call is SampleText( t, somecolor withtransparency = sometransparency)

So, use withtrapsparency in the call?

I tried

\starttext
\startMPpage[instance=3Ddoublefun]

vardef SampleText (expr t)(text c)(text = d) =3D
  save p ; picture p ;
  p :=3D image (draw t infont = "\truefontname{Regular}") ;
  draw (p shifted (- xpart center = p,0)) scaled 5 withcolor c;
  draw (p shifted (- ypart center = p,0)) scaled 5 withcolor d;
enddef;

SampleText ("Much Of This", = transparent(1, .5, red  ) , transparent(1, .5, green  )) = ;

\stopMPpage
\stoptext

But that does not = work. Mmm. Maybe I need another approach to pass 4 values (r,g,b,t) as = one parameter.



Taco


On 9 Apr 2020, at 09:04, Gerben Wierda <Gerben.Wierda@rna.nl> wrote:

Nobody?

On 8 Apr 2020, at 12:20, Gerben Wierda <gerben.wierda@rna.nl> wrote:

I would like to use the result of transparent() straight in = my macros, so I can pass the colors with transparency using a single = parameter. That should be possible if I understand the MetaFun manual = (where I=E2=80=99ve copy-pasted this example from):

\starttext
\startMPpage[instance=3Ddoublefun]

vardef SampleText (expr t, c) =3D
=  save p ; picture p ;
 p :=3D image (draw t = infont "\truefontname{Regular}") ;
 draw (p shifted = (- xpart center p,0)) scaled 5 withcolor c;
enddef ;
SampleText ("Much Of This"   , transparent(1, .5, = red  )) ;
SampleText ("Functionality"  , = transparent(1, .5, green)) ;
SampleText ("Was Written" =    , transparent(1, .5, blue )) ;
SampleText = ("While Listening", transparent(1, .5, cmyk(1,0,0,0))) ;
SampleText ("To the CD's Of" , transparent(1, .5, = cmyk(0,1,0,0))) ;
SampleText ("Tori Amos" =      , transparent(1, .5, cmyk(0,0,1,0))) ;

\stopMPpage
\stoptext

But it results in:

system =          > files > = jobname 'testcolor', input './testcolor', result 'testcolor'
fonts =           > latin = modern fonts are not preloaded
languages =       > language 'en' is active
open source     > level 2, order 3, = name './testcolor.tex'
fonts =           > = preloading latin modern fonts (second stage)
fonts =           > = 'fallback modern-designsize rm 12pt' is loaded
metapost =        > initializing instance = 'doublefun:1' using format 'metafun' and method 'double'
metapost        > = loading 'metafun' as = '/usr/local/context-osx-64/tex/texmf-context/metapost/context/base/mpiv/me= tafun.mpxl' using method 'double'
metapost =        > initializing number mode = 'double'
metapost log    >
metapost log    > loading metafun, = including plain.mp version 1.004 for metafun iv and xl
metapost log    >
metapost = log    > ! Missing ')' has been inserted.
metapost log    > <to be read again> =
metapost log    > =             &n= bsp;      withprescript
metapost log    > = transparent->(1)withprescript
metapost log =    > =             &n= bsp;           &nbs= p;    "tr_alternative=3D"&decimal.transparency_alt= ernat...
metapost log    > <*> ... = ("Much Of This" , transparent(1, .5, red )
metapost log =    > =             &n= bsp;           &nbs= p;            =             &n= bsp;) ; SampleText ("Functiona...
metapost log =    >
backend =         > xmp > using file = '/usr/local/context-osx-64/tex/texmf-context/tex/context/base/mkiv/lpdf-pd= x.xml'
pages =           > = flushing realpage 1, userpage 1, subpage 1
close source =    > level 2, order 3, name './testcolor.tex'
close source    > level 1, order 3, name = 'cont-yes.mkiv'

For me, it is not about = passing colour on to ConTeXt to typeset text, these are colors that = normally would be drawn with =E2=80=9Cwithcolor ca withtransparency = (method,factor)=E2=80=9D but that requires the passing of many more = parameters and a lot more work in coding.

Does transparent() maybe produce a string that looks like = =E2=80=9Cca withtransparency (method,factor)=E2=80=9D so something only = usable in draw/fill/etc statements? But in that case how does that work = without scantokens to parse the string?

Is = there a way I can do this without having twice the parameters (and I = have to pass multiple colours)  in my macros everywhere?

Thanks,

G
_______________________________________________________________= ____________________
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://context.aanhet.net
archive  : = https://bitbucket.org/phg/context-mirror/commits/
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://context.aanhet.net
archive  : = https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
_______________________________________________________________= ____________________

Taco = Hoekwater
Elvenkind BV




_______________________________________________________________= ____________________
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://context.aanhet.net
archive  : = https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
_______________________________________________________________= ____________________

= --Apple-Mail=_F75A8893-08DC-4C75-B0CD-7C9BFB2DF235-- --===============3234462489844441803== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============3234462489844441803==--