[Tex/LaTex] Hatched rectangle with color gradient


Is it possible in tikz to draw a hatched rectangle, in which the hatching color(NOT fill color) has a gradient (changes from red(say) from one side to the blue to the other side)?

\draw[pattern=crosshatch, pattern color=lightgray] (0,0) rectangle (10,5);

How do I add a gradient to hatch color?

Best Answer

Just an idea, declare an opposite pattern to the desired result and use it within a postaction over a gradient colored area.

Following code declares a mycheckerboard pattern (inspired in original checkerboard pattern). It fills little squares (2mmx2mm) leaving 1mm space between them. Used in a postaction simulates 1mm width crossing lines.



% Checkerboards

    {\pgfpointorigin}% lower left point
    {\pgfqpoint{6mm}{6mm}}% upper right point
    {\pgfqpoint{6mm}{6mm}}% tile size
    {% shape description


\fill[left color=red, right color=yellow, postaction={pattern=mycheckerboard, pattern color=white}] (0,0) rectangle (10,5);

\fill[postaction={pattern=mycheckerboard, pattern color=white}, top color=blue, bottom color=green] (0,0) circle (3cm);


enter image description here