This code creates sequences of images of
Julia sets by iterating complex
numbers through the function f(z) = z^p + c for complex constants c
and (usually) integer exponents p.
Images are RGB .png
files and can be combined to form animations.
These scripts are run in Python 2.7.9. The following third-party packages are used:
numpy
- efficient array operations with complex numbersnumexpr
- optimizesnumpy
array operationsPIL.Image
- creates images fromnumpy
arrays and saves them to diskpathos
- allows for multiprocessing to be used inJulia.py
withJuliaTools.py
imported as a module
First, run JuliaInputs.py
. This creates the file
input.json
which contains all of the constants that are read into
Julia.py
. You can now run Julia.py
, which imports
JuliaTools.py
as a module. The sequence of Julia
fractals will be written to images/
.
There are three types of image sequences that Julia.py
can create.
- Linear - Every frame shows a fixed region of the complex plane centered at the origin. Each successive frame is made by moving c along a straight line in the complex plane. (Example)
- Radial - Every frame shows a fixed region of the complex plane centered at the origin. Each successive frame is made by moving c along a circular arc centered at the origin. (Example)
- Zoom - Every frame shows the same Julia fractal, i.e. c is not changed. The center of each image is also constant, but it may be centered anywhere in the plane. Each successive frame shows a slightly smaller or larger region of the complex plane to give a zooming effect. (Example)
- Power - Every frame shows a fixed region of the complex plane centered at the origin, and c is fixed. The exponent p in f(z) = z^p + c is changed in each frame, usually taking on fractional values.
This code is being used by the twitter bot
@JuliaFractalBot to generate and
tweet videos of Julia fractals. A sequence of images produced by Julia.py
is converted to a .mp4
video compatible with Twitter using
ffmpeg
:
ffmpeg -r 30 -f concat -i framelist.txt -vcodec libx264 -crf 12 -pix_fmt yuv420p -s 1024:1024 -aspect 1:1 JuliaVid.mp4
The video file is then asynchronously uploaded to Twitter using
large-video-upload-python.
One can also create an animated .gif
from the images:
ffmpeg -r 10 -f concat -i framelist.txt JuliaGif.gif
This bot uses .mp4
s over .gif
s because Twitter's file size limit for
videos is 512MB, while it is only 15MB for animated .gif
s.