I couldn't resist making Zarko's answer more concise. This comes with a style connect that picks and connects the right corners for you.
\documentclass[a5paper]{article} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \newcommand{\sizein}{1.0} \newcommand{\distin}{0.15} \newcommand{\opacity}{0.8} \newcommand{\xDist}{2.0} \begin{tikzpicture}[ box/.style = {draw, fill=gray, opacity=\opacity, minimum size=\sizein cm}, wbx/.style = {draw, fill=white, minimum size=\distin cm, outer sep=0pt}, connect/.style args={#1 with #2}{insert path={ let \p1=($(#2.center)-(#1.center)$),\n1={int(mod(8+atan2(\y1,\x1)/90,2))} in \pgfextra{\pgfmathtruncatemacro{\itest}{\n1}} \ifcase\itest (#1.north west) -- (#2.north west) (#1.south east) -- (#2.south east) \or (#1.south west) -- (#2.south west) (#1.north east) -- (#2.north east) \fi }} ] \foreach \i in {2,1,0}% { \node [box,above right] at (\i*\distin,\i*\distin) {}; \node [box,above right] at (\xDist+\i*\distin,\i*\distin) {}; } \node (w1) [wbx] at (0.3,0.3) {}; \node (w2) [wbx] at (\xDist+0.5,0.5) {}; \node (w3) [wbx] at (0.1,0.9) {}; \node (w4) [wbx] at (0.5,-0.3) {}; \node (w5) [wbx] at (-0.5,0) {}; \draw[very thin] [connect=w1 with w2,connect=w1 with w3,connect=w1 with w4,connect=w1 with w5]; \end{tikzpicture} \end{document}

Thanks for the clarification! I added a second style cconnect that connects the outer corners of one rectangle with the center of another whereby the style figures out what the outer corners are.
\documentclass[a5paper]{article} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \newcommand{\sizein}{1.0} \newcommand{\distin}{0.15} \newcommand{\opacity}{0.8} \newcommand{\xDist}{2.0} \begin{tikzpicture}[ box/.style = {draw, fill=gray, opacity=\opacity, minimum size=\sizein cm}, wbx/.style = {draw, fill=white, minimum size=\distin cm, outer sep=0pt}, connect/.style args={#1 with #2}{insert path={ let \p1=($(#2.center)-(#1.center)$),\n1={int(mod(8+atan2(\y1,\x1)/90,2))} in \pgfextra{\pgfmathtruncatemacro{\itest}{\n1}} \ifcase\itest (#1.north west) -- (#2.north west) (#1.south east) -- (#2.south east) \or (#1.south west) -- (#2.south west) (#1.north east) -- (#2.north east) \fi }},cconnect/.style args={#1 with center of #2}{insert path={ let \p1=($(#2.center)-(#1.north west)$),\p2=($(#2.center)-(#1.north east)$), \p3=($(#2.center)-(#1.south west)$),\p4=($(#2.center)-(#1.south east)$), \p5=($(#2.center)-(#1.center)$), \n1={abs(atan2(\y1,\x1)-atan2(\y5,\x5))}, \n2={abs(atan2(\y2,\x2)-atan2(\y5,\x5))}, \n3={abs(atan2(\y3,\x3)-atan2(\y5,\x5))}, \n4={abs(atan2(\y4,\x4)-atan2(\y5,\x5))} in \ifdim\n1>\n2 (#1.north west) -- (#2.center) \else (#1.north east) -- (#2.center) \fi \ifdim\n3>\n4 (#1.south west) -- (#2.center) \else (#1.south east) -- (#2.center) \fi }} ] \foreach \i in {2,1,0}% { \node [box,above right] at (\i*\distin,\i*\distin) {}; \node [box,above right] at (\xDist+\i*\distin,\i*\distin) {}; } \node (w1) [wbx] at (0.3,0.3) {}; \node (w2) [wbx] at (\xDist+0.5,0.5) {}; \node (w3) [wbx] at (0.1,0.9) {}; \node (w4) [wbx] at (0.5,-0.3) {}; \node (w5) [wbx] at (-0.5,0) {}; %\draw[very thin] [connect=w1 with w2,connect=w1 with w3,connect=w1 with w4,connect=w1 with w5]; \draw[very thin,blue] [cconnect=w1 with center of w2,cconnect=w1 with center of w3,cconnect=w1 with center of w4,cconnect=w1 with center of w5]; \end{tikzpicture} \end{document}

Of course, you can use both styles in the same picture. To verify this, just uncomment \draw[very thin] [connect=w1 with w2,connect=w1 with w3,connect=w1 with w4,connect=w1 with w5];. (I did not do this because it makes the plot a bit busy.) If you need to draw chains of these, I'd recommend using show path construction and adjusting the lineto code for this. (If you want this spelled out, could you perhaps consider asking a separate question?)