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 -------------------------------
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
Am 29.01.2013 um 09:11 schrieb Devendra Ghate
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.
\definecolor[test-0][r=0.8,g=0.2,b=0.4] \definecolor[test-1][1.00(test-0)] \definecolor[test-2][0.75(test-0)] \definecolor[test-3][0.50(test-0)] \definecolor[test-4][0.25(test-0)] \starttext \startlines \color[test-1]{1.00} \color[test-2]{0.75} \color[test-3]{0.50} \color[test-4]{0.25} \stoplines \stoptext Wolfgang
participants (2)
-
Devendra Ghate
-
Wolfgang Schuster