A simple library for drawing IFS fractals and fractal-flames
Project description
A simple python library for IFS fractals and fractal flames.
It allows you to render fractals as numpy arrays. Then, you can analyze it, display it using matplotlib or save as image with Pillow.
Installation
Install using pip:
pip install fracted
or clone this repo:
git clone https://github.com/Skrret/fracted
and install in editable mode:
cd fracted
pip install -e .
Usage
from fracted import fractals
Serpinski Triangle
transformations = [
(lambda point: (point[0] / 2 + 100 * 3 ** 0.5, point[1] / 2)),
(lambda point: (point[0] / 2, point[1] / 2 + 100)),
(lambda point: (point[0] / 2, point[1] / 2 - 100)),
]
frac = fractals.IFS(
transformations,
min_x=0,
min_y=-200,
max_x=400,
max_y=200,
)
plt.imshow(frac.draw(20, 50_000))
plt.show()
Fractal Flames
Fracted can be also used to generate fractal flames.
transformations = [
(
lambda point: (
0.8 * point[0] + 0.5 * numpy.cos(point[1]) - 3,
0.8 * point[1] + 0.5 * numpy.cos(point[0]) - 3,
)
),
(
lambda point: (
-0.5 * point[1] + 0.5 * abs(point[0]) ** 0.5 + 1,
0.5 * point[0] + 0.5 * abs(point[0]) ** 0.5 + 3,
)
),
]
frac = fractals.IFS(
transformations, resolution=50, min_x=-10, min_y=-10, max_x=10, max_y=10
)
plt.imshow(numpy.log10(frac.draw(20, 50000)))
plt.show()
More examples are in examples/.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fracted-0.1.0.tar.gz.
File metadata
- Download URL: fracted-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fbc6b002dc4edd4ac6fe7df4a1654d3520aa23e7bd4021c1baf5994e6413afc
|
|
| MD5 |
634385a703eab7120357828a222f5dfd
|
|
| BLAKE2b-256 |
5975adb7bc7afd2070665d8bd6ffbdc878e33ff79d6741546fe80dc8c64bf833
|
File details
Details for the file fracted-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fracted-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72ec164c542d1a9d727d84a1787e0e24b3c716b10005571e3e904384c4fd577a
|
|
| MD5 |
e890d3bc3eedfa01c3eacb4ee80c9057
|
|
| BLAKE2b-256 |
55f9d556a4d7b3183e5220c23d03c4afc7d2c7604d361cbd580208f0177e14ce
|