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’ve copy-pasted this example from):

\starttext
\startMPpage[instance=doublefun]

vardef SampleText (expr t, c) =
  save p ; picture p ;
  p := 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/metafun.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="&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-pdx.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 “withcolor ca withtransparency (method,factor)” 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 “ca withtransparency (method,factor)” 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
___________________________________________________________________________________