| 1 |
% Copyright 2018 by Till Tantau |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
\ProvidesFileRCS{pgfcoregraphicstate.code.tex} |
| 11 |
|
| 12 |
% Globals |
| 13 |
|
| 14 |
\newdimen\pgflinewidth |
| 15 |
|
| 16 |
|
| 17 |
% Set the line width to #1. |
| 18 |
% |
| 19 |
% #1 = new line width. |
| 20 |
% |
| 21 |
% Example: |
| 22 |
% |
| 23 |
% \pgfsetlinewidth{3pt} |
| 24 |
|
| 25 |
\def\pgfsetlinewidth#1{% |
| 26 |
\pgfmathsetlength\pgflinewidth{#1}% |
| 27 |
\global\pgflinewidth=\pgflinewidth% |
| 28 |
\pgfsys@setlinewidth{\the\pgflinewidth}% |
| 29 |
\ignorespaces} |
| 30 |
|
| 31 |
|
| 32 |
% Set the inner line width to #1. |
| 33 |
% |
| 34 |
% #1 = new inner line width. |
| 35 |
% |
| 36 |
% Description: |
| 37 |
% |
| 38 |
% The inner line width is the width of a second line that is drawn on |
| 39 |
% top of the main stroked line. If the inner line width is 0pt, no |
| 40 |
% inner line is drawn. The main use of inner lines is for creating |
| 41 |
% "double" lines. |
| 42 |
% |
| 43 |
% Inner lines are not drawn when a path is used for clipping. |
| 44 |
% |
| 45 |
% The inner line width is local to the current TeX group, it is not |
| 46 |
% part of the graphic state. |
| 47 |
% |
| 48 |
% Example: |
| 49 |
% |
| 50 |
% \pgfsetinnerlinewidth{1pt} |
| 51 |
|
| 52 |
\def\pgfsetinnerlinewidth#1{% |
| 53 |
\pgfmathsetlength\pgf@x{#1}% |
| 54 |
\edef\pgfinnerlinewidth{\the\pgf@x}% |
| 55 |
} |
| 56 |
\def\pgfinnerlinewidth{0pt} |
| 57 |
|
| 58 |
|
| 59 |
% Set the inner line color to #1. |
| 60 |
% |
| 61 |
% #1 = color for the inner line |
| 62 |
% |
| 63 |
% Example: |
| 64 |
% |
| 65 |
% \pgfsetinnerlinecolor{green} % yikes! |
| 66 |
|
| 67 |
\def\pgfsetinnerstrokecolor#1{\def\pgfinnerstrokecolor{#1}} |
| 68 |
\def\pgfinnerstrokecolor{white} |
| 69 |
|
| 70 |
|
| 71 |
% Set the miter limit to #1. |
| 72 |
% |
| 73 |
% #1 = new miter limit factor. |
| 74 |
% |
| 75 |
% Example: |
| 76 |
% |
| 77 |
% \pgfsetmiterlimit{3} |
| 78 |
|
| 79 |
\def\pgfsetmiterlimit#1{% |
| 80 |
\ifdim#1pt<1pt\pgferror{miter limit cannot be less than 1}\fi% |
| 81 |
\pgfsys@setmiterlimit{#1}% |
| 82 |
\ignorespaces} |
| 83 |
|
| 84 |
|
| 85 |
% Set the dash pattern to #1 with phase #2/ |
| 86 |
% |
| 87 |
% #1 = a row of numbers of length of ``on'' and ``off'' points. |
| 88 |
% #2 = a phase |
| 89 |
% |
| 90 |
% Example: |
| 91 |
% |
| 92 |
% \pgfsetdash{} {0pt} % solid line |
| 93 |
% \pgfsetdash{{.1cm}} {0pt} % long dashes |
| 94 |
% \pgfsetdash{{1pt}{1ex}}{0pt} % dotted |
| 95 |
|
| 96 |
\def\pgfsetdash#1#2{% |
| 97 |
\def\pgf@temp{}% |
| 98 |
\def\pgf@next{\pgf@strip}% |
| 99 |
\pgf@strip#1{pgf@stop}% |
| 100 |
\pgfmathsetlength\pgf@x{#2}% |
| 101 |
\pgfsys@setdash{\pgf@temp}{\the\pgf@x}% |
| 102 |
\ignorespaces} |
| 103 |
|
| 104 |
\def\pgf@strip#1{% |
| 105 |
\def\pgf@@temp{#1}% |
| 106 |
\ifx\pgf@@temp\pgf@stop% |
| 107 |
\let\pgf@next=\relax% |
| 108 |
\else% |
| 109 |
\pgfmathsetlength\pgf@x{#1}% |
| 110 |
\ifx\pgf@temp\pgfutil@empty% |
| 111 |
\edef\pgf@temp{\the\pgf@x}% |
| 112 |
\else% |
| 113 |
\edef\pgf@temp{\pgf@temp,\the\pgf@x}% |
| 114 |
\fi% |
| 115 |
\fi\pgf@next} |
| 116 |
|
| 117 |
\def\pgf@stop{pgf@stop} |
| 118 |
|
| 119 |
|
| 120 |
% Set color of strokes. This will overrule the normal color. |
| 121 |
% |
| 122 |
% Example: |
| 123 |
% |
| 124 |
% \pgfsetstrokecolor{red} |
| 125 |
|
| 126 |
\def\pgfsetstrokecolor#1{% |
| 127 |
\pgfutil@colorlet{pgfstrokecolor}{#1}% |
| 128 |
\pgfutil@ifundefined{applycolormixins}{}{\applycolormixins{pgfstrokecolor}}% |
| 129 |
\expandafter\let\expandafter\pgf@temp\csname\string\color@pgfstrokecolor\endcsname |
| 130 |
% for arrow tips: |
| 131 |
\global\let\pgf@strokecolor@global=\pgf@temp |
| 132 |
\expandafter\pgf@setstrokecolor\pgf@temp% |
| 133 |
} |
| 134 |
\def\pgf@setstrokecolor#1#2#3#4#5{% |
| 135 |
\expandafter\ifx\csname pgfsys@color@#4@stroke\endcsname\relax% |
| 136 |
\pgferror{Unsupported color model `#4'. Sorry}% |
| 137 |
\else% |
| 138 |
\edef\pgf@colmarshal{\expandafter\noexpand\csname pgfsys@color@#4@stroke\endcsname}% |
| 139 |
\pgf@uncomma#5,,% |
| 140 |
\pgf@colmarshal% |
| 141 |
\fi} |
| 142 |
|
| 143 |
\def\pgf@uncomma#1,{% |
| 144 |
\def\pgf@coltest{#1}% |
| 145 |
\ifx\pgf@coltest\pgfutil@empty% |
| 146 |
\let\pgf@colnext=\relax% |
| 147 |
\else% |
| 148 |
\expandafter\def\expandafter\pgf@colmarshal\expandafter{\pgf@colmarshal{#1}}% |
| 149 |
\let\pgf@colnext=\pgf@uncomma% |
| 150 |
\fi% |
| 151 |
\pgf@colnext% |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
% Set color of fills. This will overrule the normal color. |
| 156 |
% |
| 157 |
% Example: |
| 158 |
% |
| 159 |
% \pgfsetfillcolor{gray} |
| 160 |
|
| 161 |
\def\pgfsetfillcolor#1{% |
| 162 |
\pgfutil@colorlet{pgffillcolor}{#1}% |
| 163 |
\pgfutil@ifundefined{applycolormixins}{}{\applycolormixins{pgffillcolor}}% |
| 164 |
\expandafter\let\expandafter\pgf@temp\csname\string\color@pgffillcolor\endcsname |
| 165 |
% for arrow tips: |
| 166 |
\global\let\pgf@fillcolor@global=\pgf@temp |
| 167 |
\expandafter\pgf@setfillcolor\pgf@temp |
| 168 |
} |
| 169 |
\def\pgf@setfillcolor#1#2#3#4#5{% |
| 170 |
\expandafter\ifx\csname pgfsys@color@#4@fill\endcsname\relax% |
| 171 |
\pgferror{Unsupported color model `#4'. Sorry}% |
| 172 |
\else% |
| 173 |
\edef\pgf@colmarshal{\expandafter\noexpand\csname pgfsys@color@#4@fill\endcsname}% |
| 174 |
\pgf@uncomma#5,,% |
| 175 |
\pgf@colmarshal% |
| 176 |
\fi} |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
% Sets both the stroke and fill color. |
| 181 |
% |
| 182 |
% Example: |
| 183 |
% |
| 184 |
% \pgfsetcolor{blue} |
| 185 |
|
| 186 |
\def\pgfsetcolor#1{% |
| 187 |
\pgfutil@colorlet{pgfstrokecolor}{#1}% |
| 188 |
\pgfutil@ifundefined{applycolormixins}{}{\applycolormixins{pgfstrokecolor}}% |
| 189 |
\expandafter\let\expandafter\pgf@temp\csname\string\color@pgfstrokecolor\endcsname |
| 190 |
% for arrow tips: |
| 191 |
\global\let\pgf@strokecolor@global=\pgf@temp |
| 192 |
\global\let\pgf@fillcolor@global=\pgf@temp |
| 193 |
\expandafter\pgf@setcolor\pgf@temp% |
| 194 |
} |
| 195 |
\def\pgf@setcolor#1#2#3#4#5{% |
| 196 |
\expandafter\ifx\csname pgfsys@color@#4\endcsname\relax% |
| 197 |
\pgferror{Unsupported color model `#4'. Sorry}% |
| 198 |
\else% |
| 199 |
\edef\pgf@colmarshal{\expandafter\noexpand\csname pgfsys@color@#4\endcsname}% |
| 200 |
\pgf@uncomma#5,,% |
| 201 |
\pgf@colmarshal% |
| 202 |
\fi} |
| 203 |
|
| 204 |
% Code for ensuring the stroke/fill colors are correctly reset. |
| 205 |
\def\XC@bcolor{\pgfsys@color@reset} |
| 206 |
|
| 207 |
% Set a butt line cap. |
| 208 |
% |
| 209 |
% Example: |
| 210 |
% |
| 211 |
% \pgfsetbuttcap |
| 212 |
|
| 213 |
\def\pgfsetbuttcap{\pgfsys@buttcap\ignorespaces} |
| 214 |
|
| 215 |
|
| 216 |
% Set a round line cap. |
| 217 |
% |
| 218 |
% Example: |
| 219 |
% |
| 220 |
% \pgfsetroundcap |
| 221 |
|
| 222 |
\def\pgfsetroundcap{\pgfsys@roundcap\ignorespaces} |
| 223 |
|
| 224 |
|
| 225 |
% Set a rectangular line cap. |
| 226 |
% |
| 227 |
% Example: |
| 228 |
% |
| 229 |
% \pgfsetrectcap |
| 230 |
|
| 231 |
\def\pgfsetrectcap{\pgfsys@rectcap\ignorespaces} |
| 232 |
|
| 233 |
|
| 234 |
% Set a miter line join. |
| 235 |
% |
| 236 |
% Example: |
| 237 |
% |
| 238 |
% \pgfsetmiterjoin |
| 239 |
|
| 240 |
\def\pgfsetmiterjoin{\pgfsys@miterjoin\ignorespaces} |
| 241 |
|
| 242 |
|
| 243 |
% Set a bevel line join. |
| 244 |
% |
| 245 |
% Example: |
| 246 |
% |
| 247 |
% \pgfsetbeveljoin |
| 248 |
|
| 249 |
\def\pgfsetbeveljoin{\pgfsys@beveljoin\ignorespaces} |
| 250 |
|
| 251 |
|
| 252 |
% Set a round line join. |
| 253 |
% |
| 254 |
% Example: |
| 255 |
% |
| 256 |
% \pgfsetroundjoin |
| 257 |
|
| 258 |
\def\pgfsetroundjoin{\pgfsys@roundjoin\ignorespaces} |
| 259 |
|
| 260 |
|
| 261 |
% Sets the even-odd rule for filling and clipping. |
| 262 |
% |
| 263 |
% Example: |
| 264 |
% |
| 265 |
% \pgfseteorule |
| 266 |
|
| 267 |
\def\pgfseteorule{\pgfsys@eoruletrue\ignorespaces} |
| 268 |
|
| 269 |
|
| 270 |
% Sets the non-zero winding number rule for filling and clipping. |
| 271 |
% |
| 272 |
% Example: |
| 273 |
% |
| 274 |
% \pgfsetnonzerorule |
| 275 |
|
| 276 |
\def\pgfsetnonzerorule{\pgfsys@eorulefalse\ignorespaces} |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
\endinput |