Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- map[{u_, v_}] := {1, 1} - v {Sin[Pi u/2], Cos[Pi u/2]};
- pts = RandomReal[{0, 1}, {1000, 2}];
- n = 2000;
- squares = Table[
- pts = N@Join[
- s Table[{0, t/n} , {t, 0, n}],
- s Table[{ t/n, 1}, {t, 0, n}],
- s Table[{1, 1 - t/n}, {t, 0, n}],
- s Table[{1 - t/n, 0}, {t, 0, n}]
- ];
- Map[# + (1 - s) {1, 1}/2 &, pts],
- {s, 0.1, 1, 0.1}];
- f[pts_] := Map[map, pts];
- ptsLists = Table[NestList[f, pts, 20], {pts, squares}];
- frame[i_] :=
- With[{\[Iota] = If[i < 5,
- If[i == 0, 0,
- 1 + Sum[0.5 + 0.5 Tanh[5 (i - j - 0.5)], {j, 5}]],
- 5 + (i - 5)^1.5]},
- Graphics[{
- EdgeForm[],
- Table[
- Module[{ps},
- ps =
- ptsLists[[j, Floor@\[Iota]]] (1 - Mod[\[Iota], 1]) +
- ptsLists[[j, Floor@\[Iota] + 1]] Mod[\[Iota], 1];
- ps =
- Map[(# - {0.5, 0.5}) (0.7 + 0.3 (1 - Cos[2 Pi \[Iota]])/2) &,
- ps];
- {
- FaceForm[ColorData["RedBlueTones"][j/Length@squares]],
- Polygon[ps.RotationMatrix[Pi \[Iota]/2]]
- }
- ]
- , {j, Length@squares, 1, -1}]
- },
- PlotRange -> 0.5
- ]
- ];
- frames = Table[frame[i], {i, 1, 11.1, 11.1/87}];
- Export["walker.gif", frames]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement