Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- smoothstep[t_, t0_, t1_] :=
- With[{tt = (t - t0)/(t1 - t0)},
- If[tt < 0, 0,
- If[tt > 1, 1, 6 tt^5 - 15 tt^4 + 10 tt^3]]]; numPoints = 20;
- numIter = 200;
- p0 = RandomReal[{-1, 1}, {numPoints, 2}];
- next[p_] := Map[
- With[{w = 0.5}, w #[[1]] + (1 - w) #[[2]]] &
- , Transpose[{p, RotateLeft[p]}]];
- ps = NestList[next, p0, numIter];
- offset[t_] := smoothstep[t, 1, 2] Mean[ps[[-1]]];
- zoom[t_] := 1.2 (1 - smoothstep[t, 1, 2]) + smoothstep[t, 1, 2] 0.3;
- frame[t_, t2_, t3_] := (With[{j = Floor[t], tt = t - Floor[t]},
- Graphics[{
- White,
- Thickness[0.003],
- PointSize[0.02],
- {
- Opacity[1 - smoothstep[tt, 0.66, 1.]],
- Point[ps[[j, ;; Clip[Floor[numPoints t3], {0, numPoints}]]]],
- Line[
- Join[ps[[j]], {ps[[j, 1]]}][[;;
- Clip[Floor[(numPoints + 1) (t3 - 1)], {0, numPoints + 1}]]]]
- },
- {
- Blend[{RGBColor[0.25, 0.85, 1.], White},
- smoothstep[tt, 0.66, 1]],
- {Opacity[smoothstep[tt, 0, 0.33]], Point[ps[[j + 1]]]},
- {Opacity[smoothstep[tt, 0.33, 0.66]],
- Line[Join[ps[[j + 1]], {ps[[j + 1, 1]]}]]}
- },
- If[t2 <= 0, {},
- {
- White,
- Module[{x, y, z},
- {x, y} = offset[2];
- z = 1.05 zoom[2];
- {
- Line[{
- {x - z, y + z}, {x - z + 2 smoothstep[t2, 0, 0.25] z,
- y + z}}],
- If[t2 <= 0.25, {},
- Line[{
- {x + z, y + z}, {x + z,
- y + z - 2 z smoothstep[t2, 0.25, 0.5]}}]
- ],
- If[t2 <= 0.5, {},
- Line[{
- {x + z, y - z}, {x + z - 2 z smoothstep[t2, 0.5, 0.75],
- y - z}}]
- ],
- If[t2 <= 0.75, {},
- Line[{
- {x - z, y - z}, {x - z,
- y - z + 2 z smoothstep[t2, 0.75, 1.]}}]
- ]
- }
- ]
- }
- ]
- },
- PlotRange -> Transpose[{
- offset[t2] + zoom[t2] {1, 1},
- offset[t2] - zoom[t2] {1, 1}
- }],
- Background -> Black, ImageSize -> 500
- ]
- ]);
- Manipulate[
- frame[t, t2, t3],
- {{t, 1}, 1, 120},
- {t2, 0, 2},
- {t3, 0, 2}
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement