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
cd pyfracgen
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
from matplotlib import colormaps
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(colormaps["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:
import itertools as itt
reals = itt.chain(np.linspace(-1, 2, 60)[0:-1], np.linspace(2, 3, 40))
series = pf.julia(
(complex(real, 0.75) for real in reals),
xbound=(-1, 1),
ybound=(-0.75, 1.25),
update_func=pf.funcs.magnetic_2,
maxiter=300,
width=5,
height=4,
dpi=200,
)
pf.images.save_animation(
list(series),
cmap=colormaps["ocean"],
gamma=0.6,
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, colormaps["bone"], colormaps["bone_r"], gammas=(8, 1)
)
plt.savefig("example_images/lyapunov_ex.png")
Random Walk
Image produced with this code:
moves = pf.construct_moves((1, 0), (0, 1))
res = pf.randomwalk(moves, niter=1000000, width=4, height=3, dpi=300)
pf.images.image(res, cmap=colormaps["gnuplot"], 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
- 2D random walks
Image Creation
- Function
imagewrappingmatplotlib.pyplot.imshow - Function
nebula_imagefor Buddhabrot "nebula" coloration - Function
markus_lyapunov_imagefor Markus-Lyapunov coloration - Function
save_animationfor 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 iterfuncs module
of pyfracgen for a few examples.
Metadata
Release files for pyfracgen 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyfracgen-0.3.0.tar.gz | 10.3 kB | Without provenance | Details for pyfracgen-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyfracgen-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for pyfracgen-0.3.0-py3-none-any.whl |
Total release size: 25.4 kB
Release files / pyfracgen-0.3.0.tar.gz
| Download URL | pyfracgen-0.3.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb03cf12956f488e16f591c1796e504f1c0c99d92d842df7c710b2c23f6ade56
|
|
BLAKE2b-256 checksum How to use checksums |
75ca09c8d39f7f5f0ff5d930293996c8dc2e5a5ca95c8b187c70378e8fe95daf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / pyfracgen-0.3.0-py3-none-any.whl
| Download URL | pyfracgen-0.3.0-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
83a41ab1072cee7567d8a90ec356ab068bab1b79ce4eddef9d5d2d669dcb5ef5
|
|
BLAKE2b-256 checksum How to use checksums |
00bf1394030893db996ffe78e1dbef5933a9eb791041c5b4ec2b812420461024
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for pyfracgen 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.