Sure. Just use CirclePoints[n]
instead of CirclePoints[4]
and make the appropriate modification to the scaling on midpoints[#[[i]]]
.
Plug in your preferred n
in the following code and play around with depth
until the center completely fills in:
midpoints[pts_] := Mean[{#, RotateLeft[#]} &[pts]];
smootherstep[x_] := 6 x^5 - 15 x^4 + 10 x^3;
DynamicModule[
{n = 8, depth = 100, cols = RGBColor /@ {"#2677bb", "#fbfbfb"}, pts, t},
pts = 2 Sqrt[2.] CirclePoints[n];
Animate[
t = smootherstep[Mod[s, 1]];
Graphics[{
Table[
{FaceForm[If[OddQ[i] && s < 1 || EvenQ[i] && s >= 1, cols[[1]], cols[[2]]]],
Polygon[Riffle[#[[i]], (1 + t (Sec[?/n]^2 - 1)) midpoints[#[[i]]]]]},
{i, 1, Length[#]}] &@NestList[midpoints, pts, depth]},
PlotRange -> 1, ImageSize -> 540],
{s, 0., 2}]
]
Here's what comes out for octagons: