# Drawing 5-gons with equally spaced in Tikz

I found a nice graphic that I want to recreate as a 5-gon using Tikz (the colors are meaningless as well as the white boxes):

In theory I know how to generate this: Filldraw closed graphs using coordinates. But is there a smarter way to get a graphic like this without special packages? Can tikz draw 5-gons equally distant itself given certain commands?

• see regular polygons, pp 698 (pgf and tikz manual, v 3.0.1a). – Zarko Nov 6 '17 at 11:36

There will be several different ways of doing this, here is one approach.

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\tikzset{
hex/.style={
regular polygon,
regular polygon sides=6,
minimum size=2cm,
fill=green!30
},
pent/.style={
hex,
regular polygon sides=5
}
}
\begin{document}
\begin{tikzpicture}
\node [hex] (inner) {};
\foreach \i in {1,...,6}
\path (inner.center) ++({360/6*(\i-0.5)}:2cm) node[hex,fill=blue!10]{};

\node [pent] (inner) at (6,0) {};
\foreach \i in {1,...,5}
\path (inner.center) ++({90+360/5*(\i-0.5)}:2cm)
node[pent,fill=blue!10, rotate={360/5*(\i-0.5)}]{};
\end{tikzpicture}
\end{document}


As a follow-up to Sigur's comments, a small variation where the distance from the center polygon to the surrounding ones are the same in both cases.

\begin{tikzpicture}
\node [hex] (inner) {};
\foreach [evaluate={\j=360/6*(\i-0.5)}] \i in {1,...,6}
\path (inner.\j) ++(\j:2mm) node[hex,fill=blue!10,rotate=\j-90,anchor=270]{};

\node [pent] (inner2) at (6,0) {};
\foreach [evaluate={\j=90+360/5*(\i-0.5)}] \i in {1,...,5}
\path (inner2.\j) ++(\j:2mm)
node [pent,fill=blue!10,rotate=\j-90,anchor=270] {};
\end{tikzpicture}

• Nice and pretty. Just observation: the space between the green and blue shapes looks different for hex and pent. But I guess that you used 2cm in both. – Sigur Nov 6 '17 at 13:19
• I suspect that it is right, only an illusion since the green bottom edges are not aligned. – Sigur Nov 6 '17 at 13:20
• @Sigur Not an illusion, they are different. The minium size relates to the diameter of the circumscribed circle I think, so the distance from center to vertex is the same for both polygons. But the hexagon is a better approximation of a circle, so the distance from the center to the middle of one the sides is different -- longer for hexagons. While the distance between the centers of the polygons are the same, the separation is larger because of that effect. – Torbjørn T. Nov 6 '17 at 13:42
• Very very nice... Maybe I need some coffee to improve my vision... lol – Sigur Nov 6 '17 at 15:23