Advertisement
Matthen

Gingerbread Man Generation

Apr 18th, 2013
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. n = 7;
  2. M = 100;
  3. p0s = RandomReal[{-2, 8}, {n, 2}];
  4. cols = Table[
  5. ColorData["DarkRainbow"][Norm[p0s[[i]]]/(Max[Norm /@ p0s])], {i,
  6. n}];
  7. ps = Table[
  8. Map[RotationTransform[5 Pi/4],
  9. NestList[
  10. Function[p, With[{x = p[[1]], y = p[[2]]}, {1 - y + Abs[x], x}]],
  11. p0s[[i]], M]],
  12. {i, n}];
  13. Manipulate[
  14. Graphics[
  15. Table[
  16. Join[{cols[[i]], PointSize[Large], Opacity[0.5]},
  17. With[{ps = ps[[i]][[;; m]]},
  18. {Point[ps], Opacity[1.0], If[M > m > 1, Arrow[ps[[-2 ;;]]], {}],
  19. Opacity[0.8], If[M > m > 2, Line[ps[[-Min[4, m] ;;]]], {}]}
  20. ]], {i, n}], PlotRange -> {{-7, 7}, {-10, 4}}
  21. ]
  22. , {m, 1, M, 1}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement