From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/114802 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Fabrice L via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Problem with a defined colour in MetaFun Date: Thu, 28 Apr 2022 08:41:52 -0400 Message-ID: <01C4152B-29B6-4CCE-BA43-57D2BCA19868@gmail.com> References: <3fc7c602-d9de-6b68-e771-240eebee4cb8@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Content-Type: multipart/mixed; boundary="===============5633543419831196241==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11103"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Fabrice L , Keith McKay To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Apr 28 14:42:34 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 1nk3Te-0002c3-1N for gctc-ntg-context-518@m.gmane-mx.org; Thu, 28 Apr 2022 14:42:34 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 87F492A383B; Thu, 28 Apr 2022 14:42:01 +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 ISwXVPUKX-fW; Thu, 28 Apr 2022 14:41:59 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7922F2A3851; Thu, 28 Apr 2022 14:41:59 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0D7C92A3832 for ; Thu, 28 Apr 2022 14:41:58 +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 QmY17-2xREjn for ; Thu, 28 Apr 2022 14:41:56 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.222.180; helo=mail-qk1-f180.google.com; envelope-from=fabrice.alpha@gmail.com; receiver= Original-Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 6BAFA2A381F for ; Thu, 28 Apr 2022 14:41:56 +0200 (CEST) Original-Received: by mail-qk1-f180.google.com with SMTP id y6so1302544qke.10 for ; Thu, 28 Apr 2022 05:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=fWipgodM/+7xEFUTrDsCFNxrHVOjCD8PVs/Q+yjgsUQ=; b=h9BWe57FWHCmOrncj5h+0nCuaXBhxzBaGFd5YvdVkkrJoGSzx2MELhw7UZsYFcEhS9 OPympJvh3MoN3zM44QdOTFK8s2FTaR5KrLt+LBhafc6SR9ggPxRfsWW1xMpjFO6hiNAT qhnP6bz1d5HwY0Lwl6cdkACl81B2MRMeq8NgU/xquwM+AJMGI/ySqLd/xQAA0m6lxzTv H7esITSG+2NNWZu7sHhk3Ku8QQ/Di0WHgT+1Tlsc8ob25Fc8rhxwUlsKFAXgZbTq1rR+ MwBspRSGGHb17yOmarXw/WAR3cGhQaud1k9KXX2vtND4/BDmIRu06X63xYH5bmfw5b4w eTdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=fWipgodM/+7xEFUTrDsCFNxrHVOjCD8PVs/Q+yjgsUQ=; b=FkTEqltM+/qR1CR8RASRnCzaEMDKNd8fQfdvQ6sN8GsDqXGrVGfzqlP9Hnw6xy0Uf0 e7A9bE7jtFJu9JVgNxWCPASgiOQX1/0jAm3g4LG/fOKiWYNmgNfn3fkGIH9ZdbGXfSm+ 7so8PFDCeRFpbmYV8iYb/IUOO3TW2cXBM4MwSraoES49NbkFTCPe1HxW+/AUP5iV/K63 t9i/CxGG3Z5GN6XAP+3Wx+1s2L9vkcC4oLhHZSDSk0PkBwFvvr/YFERKw+4RvtoaJtma y1QIBzCzcTH0+wyQUPtFjm0eXFVRYx7MKWybWHbmGGlE2lnZw7UhUMfqW3NgiuuE4DUw q6qw== X-Gm-Message-State: AOAM530nh3jwR6AspTSKbd+5zvDqNlIyoyUDNbVu9NQC3H+/onEEtwOT qAeqxDvzkgXM5BQm2vjy87njnQohzE0= X-Google-Smtp-Source: ABdhPJz0hfTI0R1zaXapg/opHQLtnDIA9JOD0mSkF4DmzEzQy1E8pPs21mXRHHgZXanE7vXOZ2HU6Q== X-Received: by 2002:a05:620a:25cf:b0:699:bbc6:9e58 with SMTP id y15-20020a05620a25cf00b00699bbc69e58mr19703982qko.64.1651149714345; Thu, 28 Apr 2022 05:41:54 -0700 (PDT) Original-Received: from smtpclient.apple ([132.208.146.109]) by smtp.gmail.com with ESMTPSA id c20-20020a05622a059400b002e1d59e68f3sm11925936qtb.48.2022.04.28.05.41.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Apr 2022 05:41:53 -0700 (PDT) In-Reply-To: <3fc7c602-d9de-6b68-e771-240eebee4cb8@gmail.com> X-Mailer: Apple Mail (2.3696.80.82.1.1) 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:114802 Archived-At: --===============5633543419831196241== Content-Type: multipart/alternative; boundary="Apple-Mail=_503E492B-78CD-4F53-BE26-82853832E7D6" --Apple-Mail=_503E492B-78CD-4F53-BE26-82853832E7D6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi Keith, > Le 28 avr. 2022 =C3=A0 06:05, Keith McKay via ntg-context = a =C3=A9crit : >=20 > Hi, >=20 > 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. >=20 > Best Wishes >=20 > Keith McKay >=20 > %%%%%%%%%%%%%%%%%%%%MWE%%%%%%%%%%%%% > \setuppapersize[A4,portrait] > \usecolors[crayola] > \starttext > \dorecurse{10}{ > \startMPpage > StartPage; > \definecolor[name=3D"myColor1", r =3D uniformdeviate(1), g =3D = uniformdeviate(1), b =3D uniformdeviate(1) ] ; > fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor = "myColor1"; > for i =3D2 step 2 until 10: > r :=3D 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 > } >=20 > \stoptext > %%%%%%%%%%%%%%%%%%%%%%%%%%%end MWE%%%%%%%%%%% >=20 Here is a solution, with works here, defining in another way the color = =C2=AB myColor =C2=BB: \setuppapersize[A4,portrait] \usecolors[crayola] \starttext \dorecurse{2}{ \startMPpage StartPage; color myColor ; myColor :=3D (uniformdeviate(1),uniformdeviate(1),uniformdeviate(1)); fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor = myColor; for i =3D2 step 2 until 10: r :=3D 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. >=20 > =20 > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ --Apple-Mail=_503E492B-78CD-4F53-BE26-82853832E7D6 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hi = Keith,

Le 28 avr. 2022 =C3=A0 06:05, Keith McKay via = ntg-context <ntg-context@ntg.nl> a =C3=A9crit :

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=3D"myColor1", r =3D = uniformdeviate(1), g =3D uniformdeviate(1), b =3D uniformdeviate(1) ] = ;
fill unitsquare xscaled PaperWidth yscaled PaperHeight = withcolor "myColor1";
for i =3D2 step 2 until 10:
r :=3D 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 =C2=AB  myColor = =C2=BB:

\setuppapersize[A4,portrait]
\usecolo= rs[crayola]
\starttext
\dorecurse{2}{
\start= MPpage
StartPage;
color myColor ;
myColor = :=3D = (uniformdeviate(1),uniformdeviate(1),uniformdeviate(1));
fill = unitsquare xscaled PaperWidth yscaled PaperHeight withcolor = myColor;
for i =3D2 step 2 until 10:
r :=3D = 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 / 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
_______________________________________________________________= ____________________

= --Apple-Mail=_503E492B-78CD-4F53-BE26-82853832E7D6-- --===============5633543419831196241== 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== --===============5633543419831196241==--