From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/114811 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Keith McKay via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Problem with a defined colour in MetaFun Date: Fri, 29 Apr 2022 14:19:15 +0100 Message-ID: References: <3fc7c602-d9de-6b68-e771-240eebee4cb8@gmail.com> <01C4152B-29B6-4CCE-BA43-57D2BCA19868@gmail.com> <30FAD77B-AB42-44C1-930F-9D2FE9D9D2CB@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3857135559259207585==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23896"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Cc: Keith McKay To: Fabrice L , mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Apr 29 15:21:10 2022 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nkQYY-0005o6-0j for gctc-ntg-context-518@m.gmane-mx.org; Fri, 29 Apr 2022 15:21:10 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 165EB2A37A1; Fri, 29 Apr 2022 15:19:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HB4VKToNpg4I; Fri, 29 Apr 2022 15:19:25 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id A33202A3890; Fri, 29 Apr 2022 15:19:25 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 00B302A3892 for ; Fri, 29 Apr 2022 15:19:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rHZR1TZgNm8E for ; Fri, 29 Apr 2022 15:19:20 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.128.49; helo=mail-wm1-f49.google.com; envelope-from=mckaymeister@gmail.com; receiver= Original-Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id ADFF52A2525 for ; Fri, 29 Apr 2022 15:19:20 +0200 (CEST) Original-Received: by mail-wm1-f49.google.com with SMTP id bi24-20020a05600c3d9800b00393ff664705so4740228wmb.4 for ; Fri, 29 Apr 2022 06:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=tdbH46QXYb1qatDvwZRbz4ev3DcjGf7sxcjaOKGJ5N0=; b=WsakQeuCmF9v34WjTp3a1H89CHRONQzXGAErJsQfJsAF3G+W5+xcIH26n1KDntM48Y pAFJW7CJP3dfip4HmZ5OhG8DoJnMSJnFKgyWYiKi4vyTS9+L47rnfSA8ygkGmMBLrlUS EXNIxhWCJaUSM/ZLeqhDLjd4L5gTmKV8vWQu8mls0Z8FMwmJOJRI1fj+dGCAMPDrdVwB c3693ugSTqhCV7aYcoxqnYLVkeHXqihTSvvELvUgdkoXU3RJSkvxEcZKeIRbRJOX3wh9 y8jwEWn5JfnV1G4st2+K9Nyakv6iVhNHlw1wRKh/4y/3DWjiyn7084FWjkI3K2rft1WT kCEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=tdbH46QXYb1qatDvwZRbz4ev3DcjGf7sxcjaOKGJ5N0=; b=sVUHNJv5OVDCDXvYR1+Vh6bcTj49Mvx7tvX5Fh9L7uUfmO4KcfSBCoyrl2w8FoJTQw t37/Lx4TMOTvbFO5appOUi9EGiHrT2L5obKXfO1mByYJ1Z8kZKVDK7IzyCHMV/gzFsVv uRXTQ/QQIpxbEt5XUNpseFLxxatAwXkGOK7BBwCkaJ5VNO2UWYGf8HOIrA9LEm+Aizsb uld6xTp3SbA9Byt9dELliAr0FH4mFAR9ZxDpNc3b4wFaH7ota86k6WSZ5wUKagXSUIqA w1dvojpOK48LzBUf+n0kgqcmHDUUNxhsLOqxNb0F+fuQgqjvjsgwb7DRxC1SWdSF6uNo OZHA== X-Gm-Message-State: AOAM530ste/HllBTqgDbstXw/Zb0ZnNNs1sVmgrk9EuLCIE0nUI/oJrH e5tTiA44XCHlSSm09VhOtD5rEQCGNahX/w== X-Google-Smtp-Source: ABdhPJy6pq9L1CNqLRB8PcTezFFBlywYiTNZMqxjN+QGisgoQfyRk9sVfovRGtHlglMhWpSwo3IBpA== X-Received: by 2002:a05:600c:3c99:b0:392:b49c:7b79 with SMTP id bg25-20020a05600c3c9900b00392b49c7b79mr3177318wmb.199.1651238360112; Fri, 29 Apr 2022 06:19:20 -0700 (PDT) Original-Received: from [192.168.0.33] (cpc100594-uddi29-2-0-cust51.20-3.cable.virginm.net. [82.42.107.52]) by smtp.gmail.com with ESMTPSA id q3-20020adfab03000000b0020ad57b8ddesm2463052wrc.101.2022.04.29.06.19.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Apr 2022 06:19:19 -0700 (PDT) Content-Language: en-GB In-Reply-To: <30FAD77B-AB42-44C1-930F-9D2FE9D9D2CB@gmail.com> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:114811 Archived-At: This is a multi-part message in MIME format. --===============3857135559259207585== Content-Type: multipart/alternative; boundary="------------KAmqvivOCCqddtZlyVRFVrG5" Content-Language: en-GB This is a multi-part message in MIME format. --------------KAmqvivOCCqddtZlyVRFVrG5 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Fabrice Thank you for your reply. It works the way I wanted. Wolfgang also replied and this has lead me to an alternative method. See my reply to him in this mailing list. Best Wishes Keith On 28/04/2022 13:45, Fabrice L wrote: > Sorry, I was a little too enthusiastic, here here is the code : > >> Le 28 avr. 2022 à 08:41, Fabrice L a écrit : >> >> Hi Keith, >> >>> Le 28 avr. 2022 à 06:05, Keith McKay via ntg-context >>> a écrit : >>> >>> 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) ] ; >>> fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor >>> "myColor1"; >>> for i =2 step 2 until 10: >>> r := i/10; >>> fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) >>> withcolor(r[\MPcolor{BurntSienna},white]); >>> fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) >>> withcolor(r[\MPcolor{myColor1}, white]); >>> fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) >>> withcolor(r[\MPcolor{"myColor1"}, white]); >>> %fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) >>> withcolor(r[myColor1 , white]); This line causes an error. >>> endfor; >>> StopPage; >>> \stopMPpage >>> } >>> >>> \stoptext >>> %%%%%%%%%%%%%%%%%%%%%%%%%%%end MWE%%%%%%%%%%% >> >> Here is a solution, with works here, defining in another way the >> color «  myColor »: >> >> \setuppapersize[A4,portrait] >> \usecolors[crayola] >> \starttext >> \dorecurse{2}{ >> \startMPpage >> StartPage; >> color myColor ; >> myColor := (uniformdeviate(1),uniformdeviate(1),uniformdeviate(1)); >> fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor myColor; >> for i =2 step 2 until 10: >> r := i/10; >> fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) >> withcolor(r[\MPcolor{BurntSienna},white]); >> fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) >> withcolor(r[\MPcolor{myColor1}, white]); >> fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) >> withcolor(r[\MPcolor{"myColor1"}, white]); >> %fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) >> withcolor(r[myColor1 ,  white]); This line causes an error. >> endfor; >> StopPage; >> \stopMPpage >> } >> >> \stoptext > > I forgot to remove « myColor1 » from the others parts of the code. > \setuppapersize[A4,portrait] > \usecolors[crayola] > \starttext > \dorecurse{10}{ > \startMPpage > StartPage; > color myColor ; > myColor := (uniformdeviate(1),uniformdeviate(1),uniformdeviate(1)); > fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor myColor; > for i =2 step 2 until 10: > r := i/10; > fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) > withcolor(r[\MPcolor{BurntSienna},white]); > fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) > withcolor(r[myColor, white]); > fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) > withcolor(r[myColor, white]); > %fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) > withcolor(r[myColor1 ,  white]); This line causes an error. > endfor; > StopPage; > \stopMPpage > } > > \stoptext > > >> >> Fabrice. >>> ___________________________________________________________________________________ >>> 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 >>> ___________________________________________________________________________________ > --------------KAmqvivOCCqddtZlyVRFVrG5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi Fabrice

Thank you for your reply. It works the way I wanted. Wolfgang also replied and this has lead me to an alternative method. See my reply to him in this mailing list.

Best Wishes

Keith

On 28/04/2022 13:45, Fabrice L wrote:
Sorry, I was a little too enthusiastic, here here is the code :

Le 28 avr. 2022 à 08:41, Fabrice L <fabrice.alpha@gmail.com> a écrit :

Hi Keith,

Le 28 avr. 2022 à 06:05, Keith McKay via ntg-context <ntg-context@ntg.nl> a écrit :

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) ] ;
fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor "myColor1";
for i =2 step 2 until 10:
r := i/10;
fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) withcolor(r[\MPcolor{BurntSienna},white]);
fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) withcolor(r[\MPcolor{myColor1}, white]);
fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) withcolor(r[\MPcolor{"myColor1"}, white]);
%fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) withcolor(r[myColor1 , white]); This line causes an error.
endfor;
StopPage;
\stopMPpage
}

\stoptext
%%%%%%%%%%%%%%%%%%%%%%%%%%%end MWE%%%%%%%%%%%

Here is a solution, with works here, defining in another way the color «  myColor »:

\setuppapersize[A4,portrait]
\usecolors[crayola]
\starttext
\dorecurse{2}{
\startMPpage
StartPage;
color myColor ;
myColor := (uniformdeviate(1),uniformdeviate(1),uniformdeviate(1));
fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor myColor;
for i =2 step 2 until 10:
r := i/10;
fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) withcolor(r[\MPcolor{BurntSienna},white]);
fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) withcolor(r[\MPcolor{myColor1}, white]);
fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) withcolor(r[\MPcolor{"myColor1"}, white]);
%fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) withcolor(r[myColor1 ,  white]); This line causes an error.
endfor;
StopPage;
\stopMPpage
}

\stoptext

I forgot to remove « myColor1 » from the others parts of the code. 
\setuppapersize[A4,portrait]
\usecolors[crayola]
\starttext
\dorecurse{10}{
\startMPpage
StartPage;
color myColor ;
myColor := (uniformdeviate(1),uniformdeviate(1),uniformdeviate(1));
fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor myColor;
for i =2 step 2 until 10:
r := i/10;
fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) withcolor(r[\MPcolor{BurntSienna},white]);
fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) withcolor(r[myColor, white]);
fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) withcolor(r[myColor, white]);
%fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) withcolor(r[myColor1 ,  white]); This line causes an error.
endfor;
StopPage;
\stopMPpage
}

\stoptext



Fabrice.
___________________________________________________________________________________
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
___________________________________________________________________________________

--------------KAmqvivOCCqddtZlyVRFVrG5-- --===============3857135559259207585== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============3857135559259207585==--