* Problem with a defined colour in MetaFun
@ 2022-04-28 10:05 Keith McKay via ntg-context
2022-04-28 12:41 ` Fabrice L via ntg-context
2022-04-28 15:04 ` Wolfgang Schuster via ntg-context
0 siblings, 2 replies; 6+ messages in thread
From: Keith McKay via ntg-context @ 2022-04-28 10:05 UTC (permalink / raw)
To: ntg-context; +Cc: Keith McKay
[-- Attachment #1.1: Type: text/plain, Size: 1756 bytes --]
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%%%%%%%%%%%
I am running:
system >
system > ConTeXt ver: 2022.04.20 19:18 LMTX fmt: 2022.4.26 int:
english/english
system >
system > 'cont-new.mkxl' loaded
[-- Attachment #1.2: Type: text/html, Size: 5679 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] 6+ messages in thread
* Re: Problem with a defined colour in MetaFun
2022-04-28 10:05 Problem with a defined colour in MetaFun 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-28 15:04 ` Wolfgang Schuster via ntg-context
1 sibling, 1 reply; 6+ messages in thread
From: Fabrice L via ntg-context @ 2022-04-28 12:41 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Fabrice L, Keith McKay
[-- Attachment #1.1: Type: text/plain, Size: 3412 bytes --]
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
Fabrice.
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> / http://www.ntg.nl/mailman/listinfo/ntg-context <http://www.ntg.nl/mailman/listinfo/ntg-context>
> webpage : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / http://context.aanhet.net <http://context.aanhet.net/>
> archive : https://bitbucket.org/phg/context-mirror/commits/ <https://bitbucket.org/phg/context-mirror/commits/>
> wiki : http://contextgarden.net <http://contextgarden.net/>
> ___________________________________________________________________________________
[-- Attachment #1.2: Type: text/html, Size: 6910 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] 6+ messages in thread
* Re: Problem with a defined colour in MetaFun
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
0 siblings, 1 reply; 6+ messages in thread
From: Fabrice L via ntg-context @ 2022-04-28 12:45 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Fabrice L, Keith McKay
[-- Attachment #1.1: Type: text/plain, Size: 4528 bytes --]
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 <mailto: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 <mailto:ntg-context@ntg.nl> / http://www.ntg.nl/mailman/listinfo/ntg-context <http://www.ntg.nl/mailman/listinfo/ntg-context>
>> webpage : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / http://context.aanhet.net <http://context.aanhet.net/>
>> archive : https://bitbucket.org/phg/context-mirror/commits/ <https://bitbucket.org/phg/context-mirror/commits/>
>> wiki : http://contextgarden.net <http://contextgarden.net/>
>> ___________________________________________________________________________________
[-- Attachment #1.2: Type: text/html, Size: 10711 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] 6+ messages in thread
* Re: Problem with a defined colour in MetaFun
2022-04-28 10:05 Problem with a defined colour in MetaFun Keith McKay via ntg-context
2022-04-28 12:41 ` Fabrice L via ntg-context
@ 2022-04-28 15:04 ` Wolfgang Schuster via ntg-context
2022-04-29 13:19 ` Keith McKay via ntg-context
1 sibling, 1 reply; 6+ messages in thread
From: Wolfgang Schuster via ntg-context @ 2022-04-28 15:04 UTC (permalink / raw)
To: mailing list for ConTeXt users, Keith McKay via ntg-context
Cc: Wolfgang Schuster, Keith McKay
[-- Attachment #1.1: Type: text/plain, Size: 1147 bytes --]
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: 2568 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] 6+ messages in thread
* Re: Problem with a defined colour in MetaFun
2022-04-28 12:45 ` Fabrice L via ntg-context
@ 2022-04-29 13:19 ` Keith McKay via ntg-context
0 siblings, 0 replies; 6+ messages in thread
From: Keith McKay via ntg-context @ 2022-04-29 13:19 UTC (permalink / raw)
To: Fabrice L, mailing list for ConTeXt users; +Cc: Keith McKay
[-- Attachment #1.1: Type: text/plain, Size: 4639 bytes --]
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
>>> ___________________________________________________________________________________
>
[-- Attachment #1.2: Type: text/html, Size: 14333 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] 6+ messages in thread
* Re: Problem with a defined colour in MetaFun
2022-04-28 15:04 ` Wolfgang Schuster via ntg-context
@ 2022-04-29 13:19 ` Keith McKay via ntg-context
0 siblings, 0 replies; 6+ messages in thread
From: Keith McKay via ntg-context @ 2022-04-29 13:19 UTC (permalink / raw)
To: Wolfgang Schuster, mailing list for ConTeXt users; +Cc: Keith McKay
[-- 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-29 13:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 10:05 Problem with a defined colour in MetaFun 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 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).