# Animate Koch curve generation and include a transition effect

Recently, I saw two kinds of animation of Koch curve iteration generation.

I don't know how to make this effect, now I can only do this Clear[koch];
koch[{A_, B_}] :=
Partition[
{A, (2 A + B)/3, (A + B)/2 + Cross[B - A]/(2 Sqrt),(A + 2 B)/3, B},
2, 1];
Manipulate[
Graphics[Line /@ Nest[Join @@ koch /@ # &, N @ {{{-1, 0}, {1, 0}}}, n]],
{n, 1, 4, 1}]


Question: How to make animation with transition effect like that?

## 1 Answer

Isn't the fastest but there is not much to see for higher iterations anyway. Let me know if anything is unclear.

Manipulate[
Graphics[
Line[
{#, #2, Dynamic[.5 (#5 + #) + (t + 1 - n) (#3 - .5 (# + #5))], #4, #5}
] & @@@ Partition[KochCurve[n][], 5, 4]
, PlotRange -> {{0, 1}, {0, .3}}
, ImageSize -> 500
],
{{n, 1}, None},
{t, 0, 5, .1, TrackingFunction :> ((t = #; n = Ceiling[t]) &)}
] Manipulate[Graphics[{
Opacity@.5,
Line[
{{#, #2, Dynamic@RotationTransform[-Pi/3. (n - t), #2][#3]},
{#5, #4, Dynamic@RotationTransform[Pi/3. (n - t), #4][#3]}
}
] & @@@ Partition[KochCurve[n][], 5, 4]
}, PlotRange -> {{0, 1}, {0, .3}}, ImageSize -> 500], {{n, 1},
None}, {t, 0, 5, .1,
TrackingFunction :> ((t = #; n = Ceiling[t]) &)}] 