Skip to main content

Python Fractal Generation is a package for generating aesthetic fractal images quickly and (hopefully) easily

Project description

Authors

  • Ryther Anderson

Description

Python Fractal Generation is a package for making interesting/aesthetic fractal images quickly and (hopefully) easily. A multitude of unique fractals (from various views) can be generated using only a few functions. Each fractal generation function returns a result object containing an array of floats that can be converted into an image, the desired width/height in inches, and the number of pixels per inch. This result object can be passed to various image creation functions that assign colors to the fractal array based on a colormap (or creates RGB channels from the array).

Installation

pyfracgen can currently be installed from the following sources:

Git

git clone https://github.com/rytheranderson/pyfracgen.git
cd pyfracgen
pip install .

PyPi

pip install pyfracgen

Example Images

All the package functions can be accessed from a single import:

import pyfracgen as pf
from matplotlib import pyplot as plt

Mandelbrot Set

Image produced with this code:

# x and y boundaries, x being the real part and y being the imaginary part in the complex plane
xbound = (0.3602404434376143632361252444495 - 0.00000000000003,
          0.3602404434376143632361252444495 + 0.00000000000025)
ybound = (-0.6413130610648031748603750151793 - 0.00000000000006,
          -0.6413130610648031748603750151793 + 0.00000000000013)

mymap = pf.images.stack_cmaps(plt.cm.gist_gray, 50)
man = pf.mandelbrot(xbound, ybound, pf.updates.power, width=4, height=3, maxiter=5000, dpi=300)
pf.images.image(man, cmap=mymap, gamma=0.8)
plt.savefig('example_images/mandelbrot_ex.png')

Julia Set Animation

Animation produced with this code:

c_vals = np.array([complex(i, 0.75) for i in np.linspace(0.05, 3.0, 100)])
s = pf.julia_series(c_vals, (-1, 1), (-0.75, 1.25), pf.updates.magnetic_2, maxiter=100,
                    width=4, height=3, dpi=200)
pf.images.save_animation(s, gamma=0.9, cmap=plt.cm.gist_ncar,
                         filename='example_images/julia_animation_ex')

Markus-Lyapunov Fractal

Image produced with this code:

string = 'AAABA'
xbound = (2.60, 4.0)
ybound = (2.45, 4.0)

im = pf.lyapunov(string, xbound, ybound, n_init=20, n_iter=80, dpi=300, width=4, height=3)
pf.images.image(im, gamma=3.0, vert_exag=10000.0, cmap=plt.cm.gray)
plt.savefig('example_images/lyapunov_ex.png')

Random Walk

Image produced with this code:

basis = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
moves = pf.construct_moves(basis)
M = pf.random_walk(moves, 5000000, width=4, height=3, depth=10, dpi=300,
                   tracking='temporal')
pf.images.random_walk_image(M, cmap=plt.cm.gist_yarg, gamma=1.0)
plt.savefig('example_images/random_walk_ex.png')

Buddhabrot with Nebula Coloring

Image produced with this code:

xbound = (-1.75, 0.85)
ybound = (-1.10, 1.10)

cvals = pf.compute_cvals(1000000, xbound, ybound, pf.updates.power, width=4, height=3, dpi=300)
bud0 = pf.buddhabrot(xbound, ybound, cvals, pf.updates.power, horizon=1.0E6, maxiter=100,
                     width=5, height=4, dpi=300)
bud1 = pf.buddhabrot(xbound, ybound, cvals, pf.updates.power, horizon=1.0E6, maxiter=1000,
                     width=5, height=4, dpi=300)
bud2 = pf.buddhabrot(xbound, ybound, cvals, pf.updates.power, horizon=1.0E6, maxiter=10000,
                     width=5, height=4, dpi=300)

pf.images.nebula_image(bud0, bud1, bud2, gamma=0.4)
plt.savefig('example_images/buddhabrot_ex.png')

Current Status

There are functions for Mandelbrot and Julia set generation, image and animation creation. There is a function for Buddhabrot generation and a function for the "nebula" coloring of the Buddhabrot. There is a class for creating and visualizaing 2- and 3-dimensional random walks. The most recent addition is a function for generating Markus-Lyapunov fractals, with a special image function for the "classic" blue/green coloring.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfracgen-0.0.9.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

pyfracgen-0.0.9-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file pyfracgen-0.0.9.tar.gz.

File metadata

  • Download URL: pyfracgen-0.0.9.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for pyfracgen-0.0.9.tar.gz
Algorithm Hash digest
SHA256 f87c9f5e61c3a2a0df6407b8354289c633e53b93b13d0538f1f1e82d3ba5028c
MD5 7562e67d12d8b38a30a80a885439642c
BLAKE2b-256 b073fee19b2581a6956cd6dc989d6a4062bf0f099a0d8acdc9c3e99c243ca92d

See more details on using hashes here.

Provenance

File details

Details for the file pyfracgen-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: pyfracgen-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for pyfracgen-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 28e95350383098715d6fecfdd9c1b9a9e6ed38355354f660cf99d9c0fc4244b0
MD5 0e59d6d0d0c605fa2611fa96ee182ba5
BLAKE2b-256 c47f782a2475435784addfa63f8bfcbda72696be2d55938c3b355552dd7f03cb

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page