From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106803 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 09:04:03 +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="===============4047267584745131304==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="25021"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Apr 09 09:04:42 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 1jMREw-0006NT-3d for gctc-ntg-context-518@m.gmane-mx.org; Thu, 09 Apr 2020 09:04:42 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id A34EE1831CC; Thu, 9 Apr 2020 09:04:09 +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 WixUuzTJ0rPK; Thu, 9 Apr 2020 09:04:07 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id CDBE71831BB; Thu, 9 Apr 2020 09:04:07 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id AD15F182FD3 for ; Thu, 9 Apr 2020 09:04:06 +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 6kD0-HRx0VhB for ; Thu, 9 Apr 2020 09:04:05 +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 A17CA1809A9 for ; Thu, 9 Apr 2020 09:04:05 +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 8AA613D0867B for ; Thu, 9 Apr 2020 09:04:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1586415843; 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=w0JsurzNU9X6+3xwAlMzLlrMuijtqc8upKDnTnpKeHY=; b=NVJ5SSb+uYjcVfmCuS+thcAo4frshUFZUHNzMgFd0aAAj9chotArZ9oGZ1drDz+edzCtO3 I7l4wmTYWgQKrW0OdKPQ9CJD+gJHJePx3XpccQhJIdBQrBXse+t01p4OifmWFKXLGf+7eM d1ayogcOr5z7SEYIXlVQGFPJT87dmoDqZlJ7MjcZe1U52IZZCTZXRCuZh8z+busZPWZZ/e I9ZXaXpIXHXN+WWoDA6LODTL0ytl1JMPLnpnFBfrtl2IXoZNxaY+KCLc/x5iVDGdVkLkxG jAUx5xU1R94WVIRbehynZkyB0kW2jr+fWpt87YPWZXMMTZhpxoBBdzEqh889uQ== In-Reply-To: <142DE083-83F9-4F5C-84E3-DFE90DF08C27@rna.nl> 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:106803 Archived-At: --===============4047267584745131304== Content-Type: multipart/alternative; boundary="Apple-Mail=_8204D0B2-0CEC-40ED-976E-39D50B11E26A" --Apple-Mail=_8204D0B2-0CEC-40ED-976E-39D50B11E26A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Nobody? > 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=99= ve 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=9Cwithcolor 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 > = __________________________________________________________________________= _________ --Apple-Mail=_8204D0B2-0CEC-40ED-976E-39D50B11E26A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 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    >    =                 = 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    = > 
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
_______________________________________________________________= ____________________

= --Apple-Mail=_8204D0B2-0CEC-40ED-976E-39D50B11E26A-- --===============4047267584745131304== 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== --===============4047267584745131304==--