ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Keith McKay via ntg-context <ntg-context@ntg.nl>
To: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>,
	mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Keith McKay <mckaymeister@gmail.com>
Subject: Re: Problem with a defined colour in MetaFun
Date: Fri, 29 Apr 2022 14:19:28 +0100	[thread overview]
Message-ID: <95b5aaa8-298b-e52b-d2c9-d2a12d446ee9@gmail.com> (raw)
In-Reply-To: <53af5dbe-fabd-6dc8-8dc7-8b86e44d8ba5@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2125 bytes --]

Hi Wolfgang,

Thank you for your reply. I did as you suggested but it still never 
worked. However it did make me delve further into the Metafun, 
LuaMetaFun and the Colouring ConTeXt manuals where I found examples of 
the *resolvedcolor* helper which I used as follows:

definecolor [name = "myColor", r = uniformdeviate(1), g = 
uniformdeviate(1), b = uniformdeviate(1)];

for loop..

fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) 
withcolor(r[resolvedcolor("myColor"), white]);

endfor;

I also found the *namedcolor* helper and I could use it as follows:

fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,(2*i)*cm) 
withcolor namedcolor("myColor2") ;

However, for some reason it did not work in:

fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) 
withcolor(r[namedcolor("myColor"), white]);

//

Thanks again for your suggestion//

Best Wishes

Keith//

On 28/04/2022 16:04, Wolfgang Schuster wrote:
> Keith McKay via ntg-context schrieb am 28.04.2022 um 12:05:
>>
>> Hi,
>>
>> In the MWE below I define an rgb colour, myColor1, using random 
>> numbers for the r, g and b components. I then use it to fill a 
>> unitsquare the size of the page, which works as expected. In the loop 
>> that follows I then use the defined colour, myColor1, along with 
>> white and the variable r to create shades of myColor1 as in the MWE 
>> below. However, myColor1 is not recognised in the loop and seems to 
>> be replaced by black, although if I use a predefined colour, in this 
>> case BurntSienna from the crayola collection, it works as expected.  
>> I have tried a number of ways to get this to work as shown in the 
>> code but without success. I would be grateful for any suggestions.
>>
>> Best Wishes
>>
>> Keith McKay
>>
>> %%%%%%%%%%%%%%%%%%%%MWE%%%%%%%%%%%%%
>>
>> \setuppapersize[A4,portrait]
>>
>> \usecolors[crayola]
>>
>> \starttext
>>
>> \dorecurse{10}{
>>
>> \startMPpage
>>
>> StartPage;
>>
>> \definecolor[name="myColor1", r = uniformdeviate(1), g = 
>> uniformdeviate(1), b = uniformdeviate(1) ] ;
>>
>
> Remove the backslash in front of the definecolor command.
>
> Wolfgang
>

[-- Attachment #1.2: Type: text/html, Size: 6299 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
___________________________________________________________________________________

      reply	other threads:[~2022-04-29 13:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28 10:05 Keith McKay via ntg-context
2022-04-28 12:41 ` Fabrice L via ntg-context
2022-04-28 12:45   ` Fabrice L via ntg-context
2022-04-29 13:19     ` Keith McKay via ntg-context
2022-04-28 15:04 ` Wolfgang Schuster via ntg-context
2022-04-29 13:19   ` Keith McKay via ntg-context [this message]

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=95b5aaa8-298b-e52b-d2c9-d2a12d446ee9@gmail.com \
    --to=ntg-context@ntg.nl \
    --cc=mckaymeister@gmail.com \
    --cc=wolfgang.schuster.lists@gmail.com \
    /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).