This is a very lovely demonstration of La Hire's line (or the "two-cusp hypocycloid"). A related demonstration can be found in this Mathematica Stack Exchange post.
Having gotten the "name dropping for search engines" out of the way, here's my version of Clayton's code:
With[{a = 1, b = 1/2, cols = RGBColor /@ {"#303841", "#f3f6f6"}},
DynamicModule[{clist = Map[RGBColor, Transpose[{1 - #, #} & @ Subdivide[75]].
{Append[List @@ cols[[2]], 0],
Append[List @@ cols[[1]], 1]}],
iF1 = Interpolation[{{{0}, 1, 0}, {{8 ?}, 1, 0}, {{12 ?}, 0, 0},
{{14 ?}, 0, 0}, {{18 ?}, 1, 0}}],
iF2 = Interpolation[{{{0}, 0, 0}, {{6 ?}, 0, 0}, {{8 ?}, 1, 0},
{{14 ?}, 1, 0}, {{18 ?}, 0, 0}}]},
Manipulate[Graphics[{{Directive[Thickness[.0075],
Append[cols[[1]], iF1[t]]],
Table[Circle[ReIm[(a - b) Exp[I (t + ? i)]],
b], {i, 0, 1}]},
{Directive[Opacity[iF2[t]], Thickness[.01]],
Line[ReIm[Table[(a - b) Exp[I s] +
b Exp[-I (a - b)/b s],
{s, t - 3 ?/4, t, ?/100}]],
VertexColors -> clist],
Line[ReIm[Table[(a - b) Exp[I (s + ?)] +
b Exp[-I (a - b)/b s],
{s, t - 3 ?/4, t, ?/100}]],
VertexColors -> clist]},
{Directive[cols[[1]], Thickness[.0075]],
Circle[]},
{Directive[cols[[1]], PointSize[.03]],
Point[ReIm[Table[(a - b) Exp[I (t + i ?)] +
b Exp[-I (a - b)/b t],
{i, 0, 1}]]]}},
Background -> cols[[-1]], PlotRange -> Sqrt[2],
ImageSize -> 540], {t, 0, 18 ?}]]]
Notes on the code, in no particular order:
I often prefer the complex formulation whenever I deal with epi- or hypocycloids; that way, I don't have to worry about whether I used the same argument in the sine and cosine for the components.
Since smoothstep was only being used here for keyframing purposes, it is more compact and equivalent to directly construct a piecewise Hermite interpolant instead, which Interpolation[]
has no trouble doing. (If you need further convincing, compare the InterpolatingFunction[]
in my version and the Which[]
-based function in Clayton's version in a plot.)
The snippet Append[List @@ color, 0]
effectively adds an alpha channel to color
.
Since the list of colors used in VertexColors
does not change, one can just generate the list once and then plug it into the Manipulate[]
with DynamicModule[]
. (Note also the slightly different method to get a pile of linearly interpolated colors all at once.)