Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. DynamicModule[{shapes, t, a, next, keyframes},
  2. shapes[i_] :=
  3. Thread@{Table[
  4. ColorData["BlueGreenYellow"]@Rescale[a, {1, i}], {a, i}],
  5. Disk /@ First@
  6. Fold[Module[{pts = #[[1]], r = #[[2]],
  7. n = #2}, {Join @@
  8. Table[# + n r Through@{Cos, Sin}[a 2 Pi/n + Pi/2] & /@
  9. RotationTransform[a 2 Pi/n + If[n == 2, Pi/2, 0]]@
  10. pts, {a, n}], n r}] &, {{{0., 0.}}, 1},
  11. Join @@ ConstantArray @@@ FactorInteger@i]};
  12. t = 1;
  13. a = 1;
  14. next[] :=
  15. keyframes =
  16. Thread[{Prepend[#, #[[1]]], #2} & @@ (shapes /@ {a, a + 1})];
  17. next[];
  18. Dynamic[If[(t += .02) >= a + 1, a++; next[]];
  19. Graphics[{Blend[{#[[1]], #2[[1]]}, t - a],
  20. Disk[#[[2, 1]] + (t - a) (#2[[2, 1]] - #[[2, 1]])]} & @@@
  21. keyframes, PlotRange -> t*{{-2, 2}, {-2, 2}}, AspectRatio -> 1,
  22. ImageSize -> 300]]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement