Debian Codegraph @

texmf-dist/tex/generic/pstricks/pstricks-color.tex

raw
1 %% $Id: pstricks-color.tex 455 2022-03-01 10:42:02Z herbert $
2 %%
3 %% This is file `pstricks-color.tex',
4 %%
5 %% IMPORTANT NOTICE:
6 %%
7 %% Herbert Voss <[email protected]>
8 %%
9 %% This program can be redistributed and/or modified under the terms
10 %% of the LaTeX Project Public License Distributed from CTAN archives
11 %% in directory macros/latex/base/lppl.txt.
12 %%
13 %% DESCRIPTION:
14 %% `pstricks-color' base code for color settings
15 %%
16 %% fileversion and filedate see main file pstricks.tex
17 %%
18 \pstVerb{
19 /pssetRGBcolor /setrgbcolor load def
20 /pssetCMYKcolor /setcmykcolor load def
21 /pssetGraycolor /setgray load def
22 }
23 \def\@newcolor#1#2{%
24 \expandafter\edef\csname #1\endcsname{\noexpand\pst@color{#2}}%
25 %\expandafter\edef\csname color@#1\endcsname{#2}%
26 \expandafter\edef\csname\string\color@#1\endcsname{#2}% hv 1.14 2005-12-17
27 \ignorespaces}
28 %
29 \def\pst@color#1{\def\pst@currentcolor{#1}\pstVerb{#1}\aftergroup\pst@endcolor}%
30 \def\pst@endcolor{\pstVerb{\pst@currentcolor}}
31 \def\pst@currentcolor{0 setgray}
32 \def\altcolormode{%
33 \def\pst@color##1{%
34 \pstVerb{gsave ##1}\aftergroup\pst@endcolor}%
35 \def\pst@endcolor{\pstVerb{\pst@grestore}}}
36
37 \def\psgetRGBColorValues#1{\expandafter\psgetRGBColorvalues@i#1;}
38 \def\psgetRGBColorvalues@i#1#2#3#4#5;{\expandafter\psgetRGBColorvalues@ii#5,,,;}
39 \def\psgetRGBColorvalues@ii#1,#2,#3,#4;{%
40 \ifx\relax#2\relax
41 #1 % gray color model
42 \else
43 #1 #2 #3
44 \fi}
45
46 \def\psgetCMYKColorValues#1{\expandafter\psgetCMYKColorvalues@i#1;}
47 \def\psgetCMYKColorvalues@i#1#2#3#4#5;{\expandafter\psgetCMYKColorvalues@ii#5,,,,;}
48 \def\psgetCMYKColorvalues@ii#1,#2,#3,#4,#5;{%
49 \ifx\relax#2\relax
50 #1 % gray color model
51 \else
52 #1 #2 #3 #4
53 \fi}
54
55 \iffalse
56 \def\ps@RGB@model{rgb}
57 \def\psgetColorValues#1{\makeatletter\expandafter\psgetColorvalues@i#1;\makeatother}
58 \gdef\psgetColorvalues@i#1#2#3#4#5;{%
59 \scantokens{\def\pst@tempA{#4}}
60 \if\pst@tempA\ps@RGB@model
61 \expandafter\psgetRGBColorvalues@ii#5;
62 \else
63 \expandafter\psgetCMYKColorvalues@ii#5;
64 \fi
65 }
66 \fi
67
68 \def\pssetMonochrome{%
69 \pstVerb{
70 /setrgbcolor { add add 0 gt {0}{1} ifelse setgray } def
71 /setcmykcolor{ 4 dict begin
72 /k ED /y ED /m ED /c ED
73 1 1 k sub c mul k add sub 0.29 mul
74 1 1 k sub m mul k add sub 0.587 mul add
75 1 1 k sub y mul k add sub 0.114 mul add
76 end 0 gt {0}{1} ifelse setgray } def }}
77 \def\pssetGrayscale{%
78 \pstVerb{
79 /setrgbcolor { 0.07 mul exch 0.71 mul add exch 0.21 mul add setgray } def
80 /setcmykcolor{ 4 dict begin
81 /k ED /y ED /m ED /c ED
82 1 1 k sub c mul k add sub 0.29 mul
83 1 1 k sub m mul k add sub 0.587 mul add
84 1 1 k sub y mul k add sub 0.114 mul add
85 end setgray } def }}
86 \def\psresetColor{\pstVerb{
87 /setrgbcolor tx@Dict begin /pssetRGBcolor load end def
88 /setcmykcolor tx@Dict begin /pssetCMYKcolor load end def }}
89
90 %\def\pst@usecolor#1{\csname color@#1\endcsname\space}% hv 1.14 2005--12-17
91 \def\pst@usecolor#1{\csname\string\color@#1\endcsname\space}
92 %
93 \def\newgray#1#2{%
94 \pst@checknum{#2}\pst@tempg
95 \@newcolor{#1}{\pst@tempg setgray}}%
96 \def\newrgbcolor#1#2{%
97 \pst@expandafter\pst@getnumiii{#2} {} {} {} {}\@nil
98 \@newcolor{#1}{\pst@tempg \pst@temph \pst@tempi setrgbcolor}}
99 \def\newhsbcolor#1#2{%
100 \pst@expandafter\pst@getnumiii{#2} {} {} {} {}\@nil
101 \@newcolor{#1}{\pst@tempg \pst@temph \pst@tempi sethsbcolor}}
102 \def\newcmykcolor#1#2{%
103 \pst@expandafter\pst@getnumiv{#2} {} {} {} {} {}\@nil
104 \@newcolor{#1}{\pst@tempg \pst@temph \pst@tempi \pst@tempj setcmykcolor}}
105 \newgray{black}{0}
106 \newgray{darkgray}{.25}
107 \newgray{gray}{.5}
108 \newgray{lightgray}{.75}
109 \newgray{white}{1}
110 \newrgbcolor{red}{1 0 0}
111 \newrgbcolor{green}{0 1 0}
112 \newrgbcolor{blue}{0 0 1}
113 \newrgbcolor{yellow}{1 1 0}
114 \newrgbcolor{cyan}{0 1 1}
115 \newrgbcolor{magenta}{1 0 1}
116
117 \@ifundefined{xglobal}% do we have xcolor loaded?
118 {\@newcolor{randomgray}{tx@Dict begin Rand setgray end}%
119 \@newcolor{randomrgb}{tx@Dict begin Rand Rand Rand setrgbcolor end}%
120 \@newcolor{randomcmyk}{tx@Dict begin Rand Rand Rand Rand setcmykcolor end}%
121 \@newcolor{randomhsb}{tx@Dict begin Rand Rand Rand sethsbcolor end}%
122 }{%
123 \definecolor[ps]{randomgray}{gray}{tx@Dict begin Rand end}%
124 \definecolor[ps]{randomrgb}{rgb}{tx@Dict begin Rand Rand Rand end}%
125 \definecolor[ps]{randomcmyk}{cmyk}{tx@Dict begin Rand Rand Rand Rand end}%
126 \definecolor[ps]{randomhsb}{hsb}{tx@Dict begin Rand Rand Rand end}%
127 }
128 %
129 \def\pst@getcolor#1#2{%
130 % \@ifundefined{color@#1}% hv 1.14 2005-12-17
131 \@ifundefined{\string\color@#1}%
132 {\@pstrickserr{Color `#1' not defined}\@eha}%
133 {\edef#2{#1}}%
134 }
135 %
136 %% END: pstricks-color.tex
137 \endinput