From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106794 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context Subject: Why does this example from the MetaFun manual not work? Date: Wed, 8 Apr 2020 12:20:35 +0200 Message-ID: <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="===============8089747356714573941==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="123329"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Apr 08 12:21:28 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 1jM7po-000Vz2-BX for gctc-ntg-context-518@m.gmane-mx.org; Wed, 08 Apr 2020 12:21:28 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 3CB9E1831CE; Wed, 8 Apr 2020 12:20:42 +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 SvBSTdVDPqVb; Wed, 8 Apr 2020 12:20:40 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 614EC1831B5; Wed, 8 Apr 2020 12:20:40 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 668AF1831A3 for ; Wed, 8 Apr 2020 12:20:39 +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 7l-YK6Iqyr8i for ; Wed, 8 Apr 2020 12:20:38 +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 A3D9018313B for ; Wed, 8 Apr 2020 12:20:38 +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 09D9A3CFF35A; Wed, 8 Apr 2020 12:20:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1586341236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=jMA3f8nBLPGAnDhg/5xbxYCS4TlWx1vSA2khjVc05bk=; b=a5fZrx6TCcprooVIfS85xBlzyxGOl2z1R/1+zrpEnpoD6el5pqytBwcjbCdj7UhJ6P65VR NN1B2V7REwLpnlQvV04bh6+QNNdSOTlMwmQpmhMJm5ASw4mKiLIh7saYtXD5gUpNTbBPCH Wt6dKe/U8dIbhjifXMyuz0NbULCYwu3ZX4yZhCIDkM066YWuay0Y+Swu3KYpUEz4XZq/oa YGeyVKRTi8mcDuMJhbSTTVsNyvqaCRrIpjsBJiO7hFL+2HhL1ZDtnuy1JJivppKe5VbMm7 lI+J1102avOddvxoBkiJVVLXSbHlDuFznIDf8IhQfxHQtowr6ZX9DRNRJb9v7Q== 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:106794 Archived-At: --===============8089747356714573941== Content-Type: multipart/alternative; boundary="Apple-Mail=_4CFCC104-5BF6-4B23-BBD9-2D266E486515" --Apple-Mail=_4CFCC104-5BF6-4B23-BBD9-2D266E486515 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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): \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 >=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' 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= --Apple-Mail=_4CFCC104-5BF6-4B23-BBD9-2D266E486515 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
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
= --Apple-Mail=_4CFCC104-5BF6-4B23-BBD9-2D266E486515-- --===============8089747356714573941== 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== --===============8089747356714573941==--