# How to have a filled pattern

I have the following rectangle:

\documentclass[tikz,11pt]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{shapes,fit,chains,positioning,patterns}
\usepackage{xcolor}
\usepackage{graphicx}

\begin{document}
\begin{tikzpicture}
\fill[blue!8!white] (0.3,1.1) -- (0.3,0.68) -- (1.2,0.68) -- (1.2,1.1);
\filldraw[pattern = north east lines,rounded corners=8pt, blue!8!white,draw=black] (0.3,1.1) -- (0.3,3.45) -- (1.2,3.45) -- (1.2,1.1);
\draw[dashed] (0.3,1.1) -- (0.3,0.68);
\draw[dashed] (1.2,1.1) -- (1.2,0.68);
\filldraw[rounded corners=8pt, blue!8!white,draw=black] (0.3,0.68) -- (0.3,-0.3) -- (1.2,-0.3) -- (1.2,0.68);
\node[draw=none,fill=none] at (0.75,1.575) {\footnotesize{\text{Q/C}}};
\end{tikzpicture}
\end{document}


rather than a continuous fill, how can I have a striped fill? Additionally I want the pattern shading to leave a rounded white rectangle about the text node in the centre.

You can use postaction for the pattern. I also cleaned up a bit.

\documentclass[tikz,11pt]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\path[postaction={pattern = north east lines},rounded corners=8pt,
fill=blue!8!white] (0.3,-0.3) rectangle (1.2,3.45)
node[midway,font=\footnotesize,fill=white,rounded corners=2pt,inner sep=1.5pt]  {Q/C};
\draw[dashed] (0.3,1.1) -- (0.3,0.68) (1.2,1.1) -- (1.2,0.68);
\draw[rounded corners=8pt] (0.3,1.1) |- (0.75,3.45)
(1.2,1.1) |- (0.75,3.45)
(0.3,0.68) |- (0.75,-0.3)
(1.2,0.68)|- (0.75,-0.3);
\end{tikzpicture}
\end{document}


This is a style Sid grid which allows you to have a fully customizable pattern. It uses a path picture, which takes a few milliseconds more to compile, but is way more flexible, and can be transformed and so on.

\documentclass[tikz,11pt]{standalone}
\usetikzlibrary{patterns,calc}
\pgfkeys{/Sid/.cd,
grid/.style={draw=black,double=blue!8!white,line width=0.4pt,double distance=2pt},
distance/.initial=6pt,
}
\tikzset{Sid grid/.style={/utils/exec=\pgfkeys{/Sid/.cd,#1},
path picture={
\path[/Sid/grid] let \p1=($(path picture bounding box.north east)-(path picture bounding box.south west)$),\n1={int((\x1+\y1)/\pgfkeysvalueof{/Sid/distance})} in
\pgfextra{\pgfmathsetmacro\mynmax{\n1}}
foreach \XX in {1,...,\mynmax}
{
([xshift={-\y1-2pt+\XX*\pgfkeysvalueof{/Sid/distance}},yshift=-2pt]path picture bounding box.south west)
--
([xshift=\XX*\pgfkeysvalueof{/Sid/distance}+2pt,yshift=2pt]path picture bounding box.north west)
};
}}}

\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\mh}{6/sqrt(2)}
\path[rounded corners=8pt,Sid grid] (0.3,-0.3) rectangle (1.2,3.45)
node[midway,font=\footnotesize,fill=white,rounded corners=2pt,inner sep=1.5pt]  {Q/C};
\draw[dashed] (0.3,1.1) -- (0.3,0.68) (1.2,1.1) -- (1.2,0.68);
\draw[rounded corners=8pt] (0.3,1.1) |- (0.75,3.45)
(1.2,1.1) |- (0.75,3.45)
(0.3,0.68) |- (0.75,-0.3)
(1.2,0.68)|- (0.75,-0.3);
\end{tikzpicture}
\end{document}


• As opposed to having black lines running through, is it possible for the shading itself to be stripped? I.e. having stripes of blue shaded regions interspersed with white regions? – Sid Jul 5 at 14:19
• @Sid So you want to have white diagonal and blue diagonal areas alternating? (Yes, that is possible.) – user121799 Jul 5 at 14:23
• Yes, that's what i'm looking for – Sid Jul 5 at 14:26
• @Sid Done. You can control all aspects since things are stored in pgf keys. – user121799 Jul 5 at 15:07

Like this ?

\documentclass[tikz,11pt,border=5mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{shapes,fit,chains,positioning,patterns}
\usepackage{xcolor}
\usepackage{graphicx}