From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/80524 Path: news.gmane.org!not-for-mail From: Devendra Ghate Newsgroups: gmane.comp.tex.context Subject: Re: Consistent Colors Date: Tue, 29 Jan 2013 21:32:32 +0530 Message-ID: <5107F298.1030609@gmail.com> References: <51078438.5080009@gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1359475373 32226 80.91.229.3 (29 Jan 2013 16:02:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 29 Jan 2013 16:02:53 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Jan 29 17:03:11 2013 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U0DeM-00036B-1D for gctc-ntg-context-518@m.gmane.org; Tue, 29 Jan 2013 17:03:06 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id EEEAA1020C; Tue, 29 Jan 2013 17:02:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id UJshXd1vJmCM; Tue, 29 Jan 2013 17:02:46 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 2D0D7101F7; Tue, 29 Jan 2013 17:02:46 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id C43CE101F7 for ; Tue, 29 Jan 2013 17:02:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id oqG8sksVGOYB for ; Tue, 29 Jan 2013 17:02:40 +0100 (CET) Original-Received: from filter2-ams.mf.surf.net (filter2-ams.mf.surf.net [192.87.102.70]) by balder.ntg.nl (Postfix) with ESMTP id 31E07101F5 for ; Tue, 29 Jan 2013 17:02:40 +0100 (CET) Original-Received: from mail-da0-f49.google.com (mail-da0-f49.google.com [209.85.210.49]) by filter2-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id r0TG2csi009964 for ; Tue, 29 Jan 2013 17:02:39 +0100 Original-Received: by mail-da0-f49.google.com with SMTP id v40so286392dad.8 for ; Tue, 29 Jan 2013 08:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=SB9trKAz7yFtH7gOMqIo8xOsYaQysME5/PyS3/7yT6s=; b=WBTzaph4rVdSi9AV03gdEenHq7D8BI+fgVx82Leu7+4F+RMX9PJSpYfRO79CzwuEFU 2js8vFgU/xIL1rgKAPCweAzz5zGup8o1/CBpJfxaQthvlg8FBzrQTVelrNfGWbEmv9S2 lzKUYpcuVa917PNSZ+huU2YRLwVga5LMc2pouTyB00C5gj+E8+ujRla+rDkUluuj4Ik8 WWShZofNzxyPf/AAIci2vNcraHECPPK0XX5mf9kZM9r1n6YLytjApSY6rxI9Gjqp3Dxk G7KJwy62EKZvR0COp+EklaDiTzol0B3NX585HMG8uFhoE7fa8/pQ5jdtfigsEkAXSxHc pxJg== X-Received: by 10.69.1.73 with SMTP id be9mr3698175pbd.116.1359475357777; Tue, 29 Jan 2013 08:02:37 -0800 (PST) Original-Received: from [61.11.102.153] ([61.11.102.153]) by mx.google.com with ESMTPS id o6sm9146128paw.37.2013.01.29.08.02.34 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Jan 2013 08:02:36 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 In-Reply-To: <51078438.5080009@gmail.com> X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.210.49; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0QIRQ2Dnz - 71d1aef1a438 - 20130129 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.70 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 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-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:80524 Archived-At: On 01/29/2013 01:41 PM, Devendra Ghate wrote: > I have been going through the concepts underlying pallet. > > I would like to define three basic colors in RGB. Then use various shades > and tints of these basic three colors through out the document. > > Now the algorithm for getting various shades for RGB scheme is: > > Darker shades: > Multiply each component by 1/4, 1/2, 3/4, etc. > of its previous value, depending on how dark the > color should be. > > Lighter tints: > Calculate (1 - previous value), multiply that by > 1/4, 1/2, 3/4, etc. and add that to the previous value. > > What I would like is a macro that is fed a color name > and should define 3 shades above and below it. > > I have following problems: > > 1. How to get RGB values of an already defined color? If this is too > involved then > I can pass the RGB values to the macro as well. > > 2. How to create a loop and carry out the above arithmatic to > create RGB values for various shades? > > Essentially the problem boils down to doing arithmetic calculations > and creating loops in ConTeXt. > > Regards, > Devendra > > MWE: > -------------------------- > \setupcolor[rgb] > \definecolor[maroon][r=0.8, g=0.2, b=0.4] > > %\definecolorgroup > %[maroon][rgb] > %[0.9:0.6:0.7, > %0.8:0.2:0.4, > %0.4:0.1:0.2, > %0.2:0.05:0.1] > > % A macro that generates three shades above and below the given color. > % It is assumed here that the RGB values are also passed along with > % the color name. > \define[4]\generateColorGroup{ > \definecolorgroup > [#1] > [#2:#3:#4] > %\dimexpr#2/4:#3/4:#4/4] > }% > \generateColorGroup{maroon}{0.8}{0.2}{0.4} > \starttext > \showcolor > \stoptext > ------------------------------- I see now that this is a trivial question. Though I was not able to use a loop, I used \ctxlua{context(math expr.)} for floating point arithmetic. Devendra ___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________