ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Why does this example from the MetaFun manual not work?
Date: Thu, 9 Apr 2020 11:41:20 +0200	[thread overview]
Message-ID: <42a980b8-6976-d319-9fe6-abc6e0ab136b@xs4all.nl> (raw)
In-Reply-To: <4D6BB593-5CDD-4054-9E59-C0E1EEA03C25@elvenkind.com>

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
___________________________________________________________________________________

  reply	other threads:[~2020-04-09  9:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08 10:20 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 [this message]
2020-04-09 10:05   ` Henri Menke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42a980b8-6976-d319-9fe6-abc6e0ab136b@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).