Advertisement
Matthen

Mandelbrot visualisation

Jun 18th, 2013
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. f21 = Compile[{{n, _Real}, {x, _Real}, {y, _Real}}, Re[
  2. With[{f =
  3. Nest[If[Abs[#] <= 100, (#^2 + x + I y), #] &, 0, Floor[n]],
  4. t = n - Floor[n]},
  5. f (1 - t) + (f^2 + x + I y) (t)
  6. ]
  7.  
  8. ], CompilationTarget -> "C"];
  9. f22 = Compile[{{n, _Real}, {x, _Real}, {y, _Real}},
  10. Im[
  11. With[{f =
  12. Nest[If[Abs[#] <= 100, (#^2 + x + I y), #] &, 0, Floor[n]],
  13. t = n - Floor[n]},
  14. f (1 - t) + (f^2 + x + I y) (t)
  15. ]
  16. ]
  17. , CompilationTarget -> "C"];
  18.  
  19. img0 = Rasterize[Graphics[
  20. Table[
  21. {ColorData["DarkRainbow"][r], Disk[{0, 0}, 1 - r]}
  22. , {r, 0, 1, 0.04}]
  23. , Background -> Black], RasterSize -> 200, ImageSize -> 200];
  24.  
  25. frame[n_] := ImageTransformation[img0,
  26. Function[{p}, With[{x = p[[1]], y = p[[2]]},
  27. {f21[n, x, y], f22[n, x, y]}
  28. ]
  29. ]
  30. , DataRange -> {{-2, 1}, {-1.5, 1.5}}];
  31. frames = Table[frame[n^2], {n, 1, 3.5, 2.5/87}];
  32. Export["mandel.gif", frames]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement