[NTG-context] Define color with calculations

Henri Menke henrimenke at gmail.com
Mon Feb 18 22:38:05 CET 2019


On 19/02/19 10:33 AM, Wolfgang Schuster wrote:
> Mohammad Hossein Bateni schrieb am 18.02.19 um 04:37:
>> Hi,
>>
>> When I use definecolor, (how) can I use computations in setting the
>> value of a component?  Something like the following...
>>
>> \definecolor[mycolor][r=0.5*0.7]
> 
> \starttext
> 
> \colored[r=\cldcontext{0.5*0.7}]{\cldcontext{0.5*0.7}}
> 
> \colored[r=\cldcontext{"\letterpercent
> .3f",0.5*0.7}]{\cldcontext{"\letterpercent .3f",0.5*0.7}}
> 
> \stoptext
> 

Better use \luaexpr.  From the manual:

The \luaexpr command can also better deal with for instance conditions,
 where it returns true or false , while \cldcontext would interpret the
 boolean value as a special signal.

Although I think my solution is superior because you can just type

   \eval{1.0*sin(pi)}

instead of

   \eval{1.0*math.sin(math.pi)}

> Wolfgang
> 
> ___________________________________________________________________________________
> 
> If your question is of interest to others as well, please add an entry
> to the Wiki!
> 
> maillist : ntg-context at 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
> ___________________________________________________________________________________
> 



More information about the ntg-context mailing list