* Why does this example from the MetaFun manual not work?
@ 2020-04-08 10:20 Gerben Wierda
2020-04-09 7:04 ` Gerben Wierda
0 siblings, 1 reply; 7+ messages in thread
From: Gerben Wierda @ 2020-04-08 10:20 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 3147 bytes --]
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
[-- Attachment #1.2: Type: text/html, Size: 11300 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does this example from the MetaFun manual not work?
2020-04-08 10:20 Why does this example from the MetaFun manual not work? Gerben Wierda
@ 2020-04-09 7:04 ` Gerben Wierda
2020-04-09 8:01 ` Taco Hoekwater
2020-04-09 10:05 ` Henri Menke
0 siblings, 2 replies; 7+ messages in thread
From: Gerben Wierda @ 2020-04-09 7:04 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 3867 bytes --]
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
> ___________________________________________________________________________________
[-- Attachment #1.2: Type: text/html, Size: 12746 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does this example from the MetaFun manual not work?
2020-04-09 7:04 ` Gerben Wierda
@ 2020-04-09 8:01 ` Taco Hoekwater
2020-04-09 8:40 ` Gerben Wierda
2020-04-09 10:05 ` Henri Menke
1 sibling, 1 reply; 7+ messages in thread
From: Taco Hoekwater @ 2020-04-09 8:01 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi Gerben,
Changing the macro header to this will work:
vardef SampleText (expr t)(text c) =
or you can use the answer from stackexchange, same approach.
BTW Hans would like people to use “withtransparency” instead as that is a
newer, more flexible approach (but that would also need the above change,
or a split into multiple parameters).
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’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
>> ___________________________________________________________________________________
>
> ___________________________________________________________________________________
> 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does this example from the MetaFun manual not work?
2020-04-09 8:01 ` Taco Hoekwater
@ 2020-04-09 8:40 ` Gerben Wierda
2020-04-09 9:01 ` Taco Hoekwater
0 siblings, 1 reply; 7+ messages in thread
From: Gerben Wierda @ 2020-04-09 8:40 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 6443 bytes --]
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) =
>
> or you can use the answer from stackexchange, same approach.
> BTW Hans would like people to use “withtransparency” 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) =
and the call is SampleText( t, somecolor withtransparency sometransparency)
So, use withtrapsparency in the call?
I tried
\starttext
\startMPpage[instance=doublefun]
vardef SampleText (expr t)(text c)(text d) =
save p ; picture p ;
p := 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
>
> 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’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
>>> ___________________________________________________________________________________
>>
>> ___________________________________________________________________________________
>> 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
> ___________________________________________________________________________________
[-- Attachment #1.2: Type: text/html, Size: 13883 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does this example from the MetaFun manual not work?
2020-04-09 8:40 ` Gerben Wierda
@ 2020-04-09 9:01 ` Taco Hoekwater
2020-04-09 9:41 ` Hans Hagen
0 siblings, 1 reply; 7+ messages in thread
From: Taco Hoekwater @ 2020-04-09 9:01 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi,
Using multiple (text <x>) arguments in macros doesn’t work, you would
need to convert all but the last argument into (expr <x>) somehow.
That means that you probably cannot do a call like the one below at all.
(I, at least, do not see how you could convert one of those transparent
colours into an expr <x> argument)
>
> SampleText ("Much Of This", transparent(1, .5, red ) , transparent(1, .5, green )) ;
The situation may get even trickier because withtransparency() and
transparent() both use a (text <x>) argument internally as well,
and I am not quite sure why.
At this point, I think you may need Hans for advice, sorry.
Taco
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does this example from the MetaFun manual not work?
2020-04-09 9:01 ` Taco Hoekwater
@ 2020-04-09 9:41 ` Hans Hagen
0 siblings, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2020-04-09 9:41 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 4/9/2020 11:01 AM, Taco Hoekwater wrote:
> Hi,
>
> Using multiple (text <x>) arguments in macros doesn’t work, you would
> need to convert all but the last argument into (expr <x>) somehow.
>
> That means that you probably cannot do a call like the one below at all.
> (I, at least, do not see how you could convert one of those transparent
> colours into an expr <x> argument)
>
>>
>> SampleText ("Much Of This", transparent(1, .5, red ) , transparent(1, .5, green )) ;
>
> The situation may get even trickier because withtransparency() and
> transparent() both use a (text <x>) argument internally as well,
> and I am not quite sure why.
>
> At this point, I think you may need Hans for advice, sorry.
Taco is right (of course). Indeed, one can end up in conflicts (mp has
no transparency so it's all implemented using trickery). Anyway, using
'infont' has no real benefits as it maps onto textext, so one can just
use that one (also because it supports the anchoring suffixes which
saves you the shift):
\starttext
\startMPpage[instance=doublefun]
draw textext("more recent" ) withcolor red withtransparency
(1, .5) ;
draw textext("functionality" ) withcolor green withtransparency
(1, .5) ;
draw textext("was written" ) withcolor blue withtransparency
(1, .5) ;
draw textext("while listening" ) withcolor magenta withtransparency
(1, .5) ;
draw textext("to superb covers by") withcolor cyan withtransparency
(1, .5) ;
draw textext("Alyona Yarushina" ) withcolor yellow withtransparency
(1, .5) ;
\stopMPpage
\stoptext
If something like "withcolor ... " is passed to a macro it has to be a
text argument, not an expression (the transparent macro actually passed
some abstraction); also, when making vardef's one need to omit the final
semi colon in order to apply more properties to the 'return value'.
At some point I will update the metafun manual which means: remove old
methods and exclusively use the new ones (currently the manual also
discusses mpii while in context mkiv/lmtx we use mpiv macros).
For instance, when using colors one can best use named colors as these
are consistent with the tex end, so often
withcolor "red"
is better than
withcolor red
etc etc etc etc
Hans
-----------------------------------------------------------------
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does this example from the MetaFun manual not work?
2020-04-09 7:04 ` Gerben Wierda
2020-04-09 8:01 ` Taco Hoekwater
@ 2020-04-09 10:05 ` Henri Menke
1 sibling, 0 replies; 7+ messages in thread
From: Henri Menke @ 2020-04-09 10:05 UTC (permalink / raw)
To: ntg-context
It would be really great if you'd stop wasting people's time by not
crossposting.
Cheers, Henri
On 09/04/20, 09:04, Gerben Wierda 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’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
> > ___________________________________________________________________________________
>
> ___________________________________________________________________________________
> 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-04-09 10:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-08 10:20 Why does this example from the MetaFun manual not work? Gerben Wierda
2020-04-09 7:04 ` Gerben Wierda
2020-04-09 8:01 ` Taco Hoekwater
2020-04-09 8:40 ` Gerben Wierda
2020-04-09 9:01 ` Taco Hoekwater
2020-04-09 9:41 ` Hans Hagen
2020-04-09 10:05 ` Henri Menke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).