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 (for Python) and (hopefully) easily. Many unique fractal images can be generated using only a few functions.

Installation

pyfracgen can currently be installed from the following sources (if you want to install from GH, probably do so using poetry).

Git

git clone https://github.com/rytheranderson/pyfracgen.git
poetry 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 bounds, x is the real part and y is the imaginary part
xbound = (
    0.3602404434376143632361252444495 - 0.00000000000003,
    0.3602404434376143632361252444495 + 0.00000000000025,
)
ybound = (
    -0.6413130610648031748603750151793 - 0.00000000000006,
    -0.6413130610648031748603750151793 + 0.00000000000013,
)
res = pf.mandelbrot(
    xbound, ybound, pf.funcs.power, width=4, height=3, dpi=300, maxiter=5000
)
stacked = pf.images.get_stacked_cmap(plt.cm.gist_gray, 50)
pf.images.image(res, cmap=stacked, gamma=0.8)
plt.savefig("example_images/mandelbrot_ex.png")

Julia Set Animation

Animation produced with this code:

cvals = (complex(i, 0.75) for i in np.linspace(0.05, 3.0, 100))
series = pf.julia(
    cvals,
    xbound=(-1, 1),
    ybound=(-0.75, 1.25),
    update_func=pf.funcs.magnetic_2,
    maxiter=300,
    width=4,
    height=3,
    dpi=200,
)
pf.images.save_animation(
    list(series),
    cmap=plt.cm.gist_ncar,
    gamma=0.9,
    file=Path("example_images/julia_animation_ex"),
)

Markus-Lyapunov Fractal

Image produced with this code:

string = "AAAAAABBBBBB"
xbound = (2.5, 3.4)
ybound = (3.4, 4.0)
res = pf.lyapunov(
    string, xbound, ybound, width=4, height=3, dpi=300, ninit=2000, niter=2000
)
pf.images.markus_lyapunov_image(res, plt.cm.bone, plt.cm.bone_r, gammas=(8, 1))
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)
res = pf.randomwalk(moves, niter=5000000, width=4, height=3, depth=10, dpi=300)
pf.images.randomwalk_image(res, cmap=plt.cm.gist_yarg, gamma=1.0)
plt.savefig("example_images/randomwalk_ex.png")

Buddhabrot with Nebula Coloring

Image produced with this code:

xbound = (-1.75, 0.85)
ybound = (-1.10, 1.10)
res = pf.buddhabrot(
    xbound,
    ybound,
    ncvals=10000000,
    update_func=pf.funcs.power,
    horizon=1.0e6,
    maxiters=(100, 1000, 10000),
    width=4,
    height=3,
    dpi=300,
)
pf.images.nebula_image(tuple(res), gamma=0.4)  # type: ignore[arg-type]
plt.savefig("example_images/buddhabrot_ex.png")

Fractal "Types" Supported

  • Mandelbrot
  • Julia
  • Buddhabrot
  • Markus-Lyapunov
  • 3D random walks

Image Creation

  • Function image wrapping matplotlib.pyplot.imshow
  • Function nebula_image for Buddhabrot "nebula" coloration
  • Function markus_lyapunov_image for Markus-Lyapunov coloration
  • Function randomwalk_image for coloring 3D random walks with depth
  • Function save_animation for animating a sequence of results

More than Quadratic Polynomials

Mandelbrot, Julia, and Buddhabrot fractal images are almost always created by iterating the function $f_c(z) = z^2 + c$. Makes sense, since this function is part of the definition of the Mandelbrot set. However, you can iterate lots of other functions to produce similarly striking images: see the updaters module of pyfracgen for a few examples.

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.11.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

pyfracgen-0.0.11-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyfracgen-0.0.11.tar.gz
  • Upload date:
  • Size: 10.7 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.11.tar.gz
Algorithm Hash digest
SHA256 2befdc43e62f2c79178a8df139485f5f4f97103cc27ecb7637485a4def71f0da
MD5 bd673fb4747cb384618d4b62af39eb8d
BLAKE2b-256 c21b2a77d4dae8780af7d77fd0ee0c7eb73d6c69fb7e9fc65a6accab7f2708dd

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pyfracgen-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 15.5 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.11-py3-none-any.whl
Algorithm Hash digest
SHA256 745a3aa73d1d1ae9b4fe8e1441ce9a6263d8b0df5fb8541785bf0c55e86b385f
MD5 a318c069b2252007b8262c73a70af241
BLAKE2b-256 fe35fb4ea5112013f9b3599cd015c6829d0bbca7a0aa8bdb717f2c185268662c

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