I have two nodes (drawn as rectangles) in my picture, one filled in green, the other red. I wish to produce a third 'rectangle' which shows the effect of splicing these two rectangles and stitching them back together.
Or, in other words, I wish to produce a rectangle twice the width of my starting rectangles that is subdivided up into smaller segments, each segment filled alternating between red and green.
Given my picture:
\begin{tikzpicture}[node distance=5mm]
\node [fill=red!30,minimum width=40mm] (b1) {Bank 1 \unit[1024]{MiB}};
\node [fill=green!30,minimum width=40mm,right=of b1] (b2) {Bank 2 \unit[1024]{MiB}};
\end{tikzpicture}
I have been able to 'create' the desired effect using two \foreach
loops:
\foreach \n in {0,2,...,10}
\draw [fill=red!30] (\n*6.66mm,1) +(-3.33mm,0) rectangle
++(3.33mm,5mm);
\foreach \n in {1,3,...,11}
\draw [fill=green!30] (\n*6.66mm,1) +(-3.33mm,0) rectangle
++(3.33mm,5mm);
However, this requires several manual factors (40 / 6 = 6.66, 6.66 / 2 = 3.33) and I have been unable to position it under my existing two nodes due to the use of absolute coordinates.
Are there better ways of doing this which would give me more/easier control of the positioning of the 'group'? I looked into splitting a rectangle but this is seemingly limited to four horizontal splits.