\def\filename{palette.tex}
\def\fileversion{0.91}
\def\filedate{92/09/02}
%
% Send comments to the author: Fred Knight (knight@ll.mit.edu)
%
% Purpose:
% Macros to get colors from a palette.
% For use with PSTricks version v0.91 and later.
% These macros allow the user to select colors from a palette derived
% from the Openwindows file rgbcolors.txt, which contains about 140
% distinct colors, not including different shades and gray levels.
% The user can also display the palette and add to it.
% Usage:
% \palette
% the list of colors and values, only an internal list of colors
% \addtopalette[type]{name}{values}
% add a color to \palette
% type---an integer denoting the type of values
% 1 = rgb, default, 3 numbers between 0 (low) and 1 (high)
% 2 = hsb, 3 numbers between 0 (low) and 1 (high)
% 3 = cmyk, 4 numbers between 0 (low) and 1 (high)
% 4 = gray, 1 number between 0 (low) and 1 (high)
% name---the color's name as stored in \palette,
% usually all lowercase
% values---numbers according to the type of color
% Examples:
% \addtopalette{mud}{0.6 0.4 0.2}
% \addtopalette[4]{mudgray}{0.4}
% \addrgb{name}{values}
% add an rgb color called name to the palette
% \addhsb{name}{values}
% add an hsb color called name to the palette
% \addcmyk{name}{values}
% add an cmyk color called name to the palette
% \addgray{name}{values}
% add an gray color called name to the palette
% \getcolor[altname]{name}
% analogous to \newrgbcolor but get values from
% \palette and define a macro \name or \altname, if present.
% Examples:
% \getcolor{thistle} {\thistle The color is slightly off purple.}
% \getcolor[goo]{brown} {\goo Its fragrance graced the table.}
% \showpalette
% macro to show all the colors in \palette
% Restrictions:
% Works only with PostScript and requires PSTricks.
% Acknowledgement:
% Thanks to Tim Van Zandt for many helpful comments.
%
%
% =====>> Preliminaries: Is PSTricks loaded? Change catcode of @.
%
\ifx\pstricksloaded\relax\else\input pstricks\fi
\typeout{`\filename' v\fileversion\space\space <\filedate> (Fred Knight)}
\edef\theatcode{\the\catcode`\@}
\ifnum\theatcode=13\let\theat @\fi
\catcode`\@=11\relax
%
% =====>> User macros for adding colors to \palette: 4 types
%
\def\addtopalette{\@ifnextchar [{\@addtopalette}{\@addtopalette[1]}}
\def\@addtopalette[#1]#2#3{\edef\palette{\palette(#2,#1,#3)}}
\def\addrgb{\addtopalette[1]}
\def\addhsb{\addtopalette[2]}
\def\addcmyk{\addtopalette[3]}
\def\addgray{\addtopalette[4]}
%
% =====>> User macro to define a new color name.
%
\def\getcolor{\@ifnextchar [{\@getcolor}{\@getcolor[\@nil]}}
\def\@getcolor[#1]#2{%
\ifx#1\@nil\def\altname{#2}\else\def\altname{#1}\fi
\def\pst@tempg##1(#2,##2,##3)##4\@nil{%
\ifcase##2\@pstrickserr{Color `#2' not found}\@eha
\or\newrgbcolor{\altname}{##3}%
\or\newhsbcolor{\altname}{##3}%
\or\newcmykcolor{\altname}{##3}%
\or\newgray{\altname}{##3}%
\fi}%
\expandafter\pst@tempg\palette(#2,0,)\@nil}
%
% =====>> \showpalette and its parts.
%
% Define 4 dimensions for \showpalette
\newdimen\PalBoxwd\PalBoxwd=\hsize
\newdimen\PalBoxht\PalBoxht=\baselineskip
\newdimen\savedparindent
\newdimen\savedparskip
% Each color gets a rule with text of two colors (black & white) in it.
\def\paletteBox{\vrule height\PalBoxht width\PalBoxwd depth1ex}
% Each color has 2 entries: one with black text, the other with white.
\def\paletteEntry#1#2#3{%
\hbox to 0.5\hsize{ #1\hss
\ifcase#2\or rgb\or hsb\or cmyk\or gray\fi:#3 }}
\def\showpalette{\edef\pst@tempa{\palette(NoMoreColors,0, 0)}%
\savedparskip=\parskip\parskip0pt
\savedparindent=\parindent\parindent0pt\par
\expandafter\thepalette\pst@tempa
\parindent=\savedparindent
\parskip=\savedparskip}
% \thepalette loops through the entries of \palette.
\def\thepalette(#1,#2,#3){%
\ifnum#2=0
\let\next\relax
\else
\leavevmode
\hbox{%
\pstVerb{#3 \ifcase#2\or setrgbcolor\or sethsbcolor\or
setcmykcolor\or setgray\fi}%
\paletteBox\hskip-\hsize
\pstVerb{0 setgray}\paletteEntry{#1}{#2}{#3}% black text
\pstVerb{1 setgray}\paletteEntry{#1}{#2}{#3}}% white text
\let\next\thepalette
\par\vskip1pt
\fi\next}
%
% =====>> The palette of colors; derived from OPENWINDOWS/rgbcolors.txt.
%
\def\palette{%
% format: (name,type, values)
% where
% name = name of the color
% type = 1 for rgb, 2 for hsb, 3 for cmyk, 4 for gray
% values = color values in the type specified
(snow,1,1.00 0.98 0.98)% The color snow has r=1.00, b=0.98, and g=0.98.
(ghostwhite,1,0.97 0.97 1.00)%
(whitesmoke,1,0.96 0.96 0.96)%
(gainsboro,1,0.86 0.86 0.86)%
(floralwhite,1,1.00 0.98 0.94)%
(oldlace,1,0.99 0.96 0.90)%
(linen,1,0.98 0.94 0.90)%
(antiquewhite,1,0.98 0.92 0.84)%
(papayawhip,1,1.00 0.94 0.84)%
(blanchedalmond,1,1.00 0.92 0.80)%
(bisque,1,1.00 0.89 0.77)%
(peachpuff,1,1.00 0.85 0.73)%
(navajowhite,1,1.00 0.87 0.68)%
(moccasin,1,1.00 0.89 0.71)%
(cornsilk,1,1.00 0.97 0.86)%
(ivory,1,1.00 1.00 0.94)%
(lemonchiffon,1,1.00 0.98 0.80)%
(seashell,1,1.00 0.96 0.93)%
(honeydew,1,0.94 1.00 0.94)%
(mintcream,1,0.96 1.00 0.98)%
(azure,1,0.94 1.00 1.00)%
(aliceblue,1,0.94 0.97 1.00)%
(lavender,1,0.90 0.90 0.98)%
(lavenderblush,1,1.00 0.94 0.96)%
(mistyrose,1,1.00 0.89 0.88)%
(white,1,1.00 1.00 1.00)%
(black,1,0.00 0.00 0.00)%
(midnightblue,1,0.10 0.10 0.44)%
(navy,1,0.00 0.00 0.50)%
(navyblue,1,0.00 0.00 0.50)%
(cornflowerblue,1,0.39 0.58 0.93)%
(darkslateblue,1,0.28 0.24 0.55)%
(slateblue,1,0.42 0.35 0.80)%
(mediumslateblue,1,0.48 0.41 0.93)%
(lightslateblue,1,0.52 0.44 1.00)%
(mediumblue,1,0.00 0.00 0.80)%
(royalblue,1,0.25 0.41 0.88)%
(blue,1,0.00 0.00 1.00)%
(dodgerblue,1,0.12 0.56 1.00)%
(deepskyblue,1,0.00 0.75 1.00)%
(skyblue,1,0.53 0.81 0.92)%
(lightskyblue,1,0.53 0.81 0.98)%
(steelblue,1,0.27 0.51 0.71)%
(lightsteelblue,1,0.69 0.77 0.87)%
(lightblue,1,0.68 0.85 0.90)%
(powderblue,1,0.69 0.88 0.90)%
(paleturquoise,1,0.69 0.93 0.93)%
(darkturquoise,1,0.00 0.81 0.82)%
(mediumturquoise,1,0.28 0.82 0.80)%
(turquoise,1,0.25 0.88 0.82)%
(cyan,1,0.00 1.00 1.00)%
(lightcyan,1,0.88 1.00 1.00)%
(cadetblue,1,0.37 0.62 0.63)%
(mediumaquamarine,1,0.40 0.80 0.67)%
(aquamarine,1,0.50 1.00 0.83)%
(darkgreen,1,0.00 0.39 0.00)%
(darkolivegreen,1,0.33 0.42 0.18)%
(darkseagreen,1,0.56 0.74 0.56)%
(seagreen,1,0.18 0.55 0.34)%
(mediumseagreen,1,0.24 0.70 0.44)%
(lightseagreen,1,0.13 0.70 0.67)%
(palegreen,1,0.60 0.98 0.60)%
(springgreen,1,0.00 1.00 0.50)%
(lawngreen,1,0.49 0.99 0.00)%
(green,1,0.00 1.00 0.00)%
(chartreuse,1,0.50 1.00 0.00)%
(mediumspringgreen,1,0.00 0.98 0.60)%
(greenyellow,1,0.68 1.00 0.18)%
(limegreen,1,0.20 0.80 0.20)%
(yellowgreen,1,0.60 0.80 0.20)%
(forestgreen,1,0.13 0.55 0.13)%
(olivedrab,1,0.42 0.56 0.14)%
(darkkhaki,1,0.74 0.72 0.42)%
(khaki,1,0.94 0.90 0.55)%
(palegoldenrod,1,0.93 0.91 0.67)%
(lightgoldenrodyellow,1,0.98 0.98 0.82)%
(lightyellow,1,1.00 1.00 0.88)%
(yellow,1,1.00 1.00 0.00)%
(gold,1,1.00 0.84 0.00)%
(lightgoldenrod,1,0.93 0.87 0.51)%
(goldenrod,1,0.85 0.65 0.13)%
(darkgoldenrod,1,0.72 0.53 0.04)%
(rosybrown,1,0.74 0.56 0.56)%
(indianred,1,0.80 0.36 0.36)%
(saddlebrown,1,0.55 0.27 0.07)%
(sienna,1,0.63 0.32 0.18)%
(peru,1,0.80 0.52 0.25)%
(burlywood,1,0.87 0.72 0.53)%
(beige,1,0.96 0.96 0.86)%
(wheat,1,0.96 0.87 0.70)%
(sandybrown,1,0.96 0.64 0.38)%
(tan,1,0.82 0.71 0.55)%
(chocolate,1,0.82 0.41 0.12)%
(firebrick,1,0.70 0.13 0.13)%
(brown,1,0.65 0.16 0.16)%
(darksalmon,1,0.91 0.59 0.48)%
(salmon,1,0.98 0.50 0.45)%
(lightsalmon,1,1.00 0.63 0.48)%
(orange,1,1.00 0.65 0.00)%
(darkorange,1,1.00 0.55 0.00)%
(coral,1,1.00 0.50 0.31)%
(lightcoral,1,0.94 0.50 0.50)%
(tomato,1,1.00 0.39 0.28)%
(orangered,1,1.00 0.27 0.00)%
(red,1,1.00 0.00 0.00)%
(hotpink,1,1.00 0.41 0.71)%
(deeppink,1,1.00 0.08 0.58)%
(pink,1,1.00 0.75 0.80)%
(lightpink,1,1.00 0.71 0.76)%
(palevioletred,1,0.86 0.44 0.58)%
(maroon,1,0.69 0.19 0.38)%
(mediumvioletred,1,0.78 0.08 0.52)%
(violetred,1,0.82 0.13 0.56)%
(magenta,1,1.00 0.00 1.00)%
(violet,1,0.93 0.51 0.93)%
(plum,1,0.87 0.63 0.87)%
(orchid,1,0.85 0.44 0.84)%
(mediumorchid,1,0.73 0.33 0.83)%
(darkorchid,1,0.60 0.20 0.80)%
(darkviolet,1,0.58 0.00 0.83)%
(blueviolet,1,0.54 0.17 0.89)%
(purple,1,0.63 0.13 0.94)%
(mediumpurple,1,0.58 0.44 0.86)%
(thistle,1,0.85 0.75 0.85)%
}
\expandafter\catcode`\@=\theatcode\relax
\ifnum\theatcode=13\let @\theat\fi
\endinput
|