Message Boards Message Boards

[GIF] Come Together (Spinning hexagons)

Spinning hexagons

Come Together

An offshoot of another project which may become a thing some day. The basic idea is that a hexagon is just a truncated triangle, and so by adjusting how much you truncate you can morph smoothly between the two. Plus some spinning.

Here's the code:

smootherstep[t_] := 6 t^5 - 15 t^4 + 10 t^3;
smootheststep[t_] := -20 t^7 + 70 t^6 - 84 t^5 + 35 t^4;

NgonToNOver2Gon[n_, r_, center_, ?_, t_] := 
  DeleteDuplicates[Table[center + ReIm[r Exp[I (? + 2 ? /n (i + (-1)^i *t/2))]], {i, 0, n - 1}]];

DynamicModule[{t},
 Manipulate[
  t = smootheststep[1 - Abs[1 - s]];
  Graphics[{CapForm["Round"], FaceForm[None], 
    EdgeForm[Directive[JoinForm["Round"], Thickness[.008]]], 
    Table[{EdgeForm[Blend[{ColorData["BrightBands"][i/5], White}, t]],
       Polygon[
       NgonToNOver2Gon[6,1 - t/2, (2 - 3/2 t) ReIm[Exp[I*2 ?/6 (i + 6 (2 smootheststep[Mod[s/2 + 1/2, 1]] - 1))]], 
         ?/6 (1 + 2 i + 4 smootheststep[Mod[s, 1]] + 12 (2 smootherstep[Mod[s/2 + 1/2, 1]] - 1)), t]]},
     {i, 0, 5}]},
   PlotRange -> 4, ImageSize -> 540, Background -> GrayLevel[.15]],
  {s, 0, 2}]
 ]

enter image description here - Congratulations! This post is now a Staff Pick! Thank you for your wonderful contributions. Please, keep them coming!

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract