While trying to use a variable pattern in TikZ with varying pattern color, I found that it did not seem to work. Here's a minimal working example:
\documentclass[tikz]{standalone}
\usetikzlibrary{patterns}
%
%
\tikzset{slope/.store in=\slope}
%
\pgfdeclarepatternformonly[\slope]{slant lines}
{\pgfpoint{-.1mm/\slope}{-.1mm}}{\pgfpoint{1.1mm/\slope}{1.1mm}}
{\pgfpoint{1mm/\slope}{1mm}}
{
\pgfsetlinewidth{0.4pt}
\pgfpathmoveto{\pgfpoint{-.1mm/\slope}{-.1mm}}
\pgfpathlineto{\pgfpoint{1.1mm/\slope}{1.1mm}}
\pgfusepath{stroke}
}
%
%
\newcommand{\theslope}{0.7}
%
\pgfdeclarepatternformonly{diagonal lines}
{\pgfpoint{-.1mm/\theslope}{-.1mm}}{\pgfpoint{1.1mm/\theslope}{1.1mm}}
{\pgfpoint{1mm/\theslope}{1mm}}
{
\pgfsetlinewidth{0.4pt}
\pgfpathmoveto{\pgfpoint{-.1mm/\theslope}{-.1mm}}
\pgfpathlineto{\pgfpoint{1.1mm/\theslope}{1.1mm}}
\pgfusepath{stroke}
}
%
%
\begin{document}
\begin{tikzpicture}
\draw[pattern=diagonal lines,pattern color=blue] (0,0) rectangle (5,5);
\tikzset{every path/.append style={xshift=6cm}}
\draw[pattern=slant lines,pattern color=blue,slope=0.7] (0,0) rectangle (5,5);
\end{tikzpicture}
\end{document}
The output looks like this:

If I understand the system correctly, both squares should be filled with diagonal blue lines. But for the variable-slope pattern, the pattern color=blue option seems to have been ignored.
Am I doing something wrong, or is this an actual bug? In either case, is there a reasonable way for me to make it right?


five pointed starspattern doesn't react to\pattern colorneither. On this note: Using the example patternstarsfrom the PGF manual and adding an otherwise not even used macro to the optional list of variables, the stars will stay black. – Qrrbrbirlbel Nov 25 '12 at 2:14pattern color), and declaring a new pattern schema removes the dependence onpattern colorunless it is added back explicitly. If so, Qrrbrbirlbel's solution (below) may be the only viable one, in spite of its use of color commands inside a form-only declaration. – Charles Staats Nov 25 '12 at 2:57