A collection of tools to generate renderings based on iterative functions.
Project description
Overview
iterart is a collection of tools to generate renderings based on iterative functions.
Installation
pip install iterart
Examples
Nebulabrot
from iterart.nebulabrot import nebulabrot
from iterart.shared import Bounds, ImageConfig, BitDepth, DynamicRangeBoost, GPU
gpu = GPU() #You will be prompted to select which GPU to utilize
bounds = Bounds(-2, 2, -2, 2) #Specify the region in the complex plane to render on
image_config = ImageConfig(
width=1000,
height=1000,
bit_depth=BitDepth.EIGHT,
dynamic_range_boost=DynamicRangeBoost.sqrt #Takes the square root of the final pixel values to improve dynamic range.
)
equation = "z=add(multiply(z,z),c)" #The equation to render. Here we render z=z^2+c.
rendering = nebulabrot(
gpu=gpu,
image_config=image_config,
equation=equation,
step_size=0.001, #A grid scan is performed when choosing values of "c". This is the spacing used.
max_iter=5000,
bounds=bounds
)
#Renderings are PIL images, so we can use the "save" method.
rendering.save("render.png")
A More Complex Equation
equation = """
Complex neg_imag = { -z.imag, 0 };
z=add(add(multiply(z,z),c),neg_imag)
"""
Creating Equations
Equations are written in OpenCL. Every equation has access to a "z" and "c" value. The "c" value is a location on the complex plane. The "z" value will always begin at zero for the iterations. Both values are structs of type 'Complex' and require the following functions to manipulate them:
- add
- subtract
- multiply
- divide
You can access the imaginary and real components using the 'imag' and 'real' properties. See A More Complex Equation for an example.
Color Images
To produce color renderings, you can combine grayscale renderings into an RGB image. Since renderings are PIL images, we can use tools from that package to accomplish this.
from iterart.nebulabrot import nebulabrot
from iterart.shared import Bounds, ImageConfig, BitDepth, DynamicRangeBoost, GPU
from PIL import Image, ImageEnhance
gpu = GPU()
bounds = Bounds(-2, 2, -2, 2)
image_config = ImageConfig(
width=1000,
height=1000,
bit_depth=BitDepth.EIGHT,
dynamic_range_boost=DynamicRangeBoost.sqrt
)
equation = """
z=add(multiply(z,z),c)
"""
# Choosing different max iterations will produce slightly different images.
low = nebulabrot(
gpu=gpu,
image_config=image_config,
equation=equation,
step_size=0.001,
max_iter=5000,
bounds=bounds
)
mid = nebulabrot(
gpu=gpu,
image_config=image_config,
equation=equation,
step_size=0.001,
max_iter=10000,
bounds=bounds
)
high = nebulabrot(
gpu=gpu,
image_config=image_config,
equation=equation,
step_size=0.0015,
max_iter=20000,
bounds=bounds
)
image_r = ImageEnhance.Brightness(low).enhance(0.10) #Our goal is an overall blue image, so we can reduce the red channel.
image_g = ImageEnhance.Brightness(Image.blend(mid, high, 0.67)).enhance(0.85) #Green will be made mostly from the higher iteration rendering, which will result in green accents. We also will reduce it overall to still favor a more blue hue.
image_b = Image.blend(low, mid, 0.25)
rgb_image = Image.merge('RGB', (image_r, image_g, image_b))
rgb_image = ImageEnhance.Contrast(rgb_image).enhance(2)
rgb_image = rgb_image.transpose(Image.Transpose.ROTATE_270)
rgb_image.save("color.png")
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
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 iterart-0.2.0.tar.gz.
File metadata
- Download URL: iterart-0.2.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ac0162e8c988140e298f7b7836d7a1bcdbb3a0f6b439a65546ec75a90423eef
|
|
| MD5 |
fe1b0367ecdc84f9cf9025eefb4275a3
|
|
| BLAKE2b-256 |
fa9d86571322dc4c767d1b2f5660b75821b02a83569227455334c015d6e60ac5
|
Provenance
The following attestation bundles were made for iterart-0.2.0.tar.gz:
Publisher:
publish.yaml on karzunn/iterart
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iterart-0.2.0.tar.gz -
Subject digest:
5ac0162e8c988140e298f7b7836d7a1bcdbb3a0f6b439a65546ec75a90423eef - Sigstore transparency entry: 175171766
- Sigstore integration time:
-
Permalink:
karzunn/iterart@452881f06a85d3fdab1aec2c4ddd86ba3e586622 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/karzunn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@452881f06a85d3fdab1aec2c4ddd86ba3e586622 -
Trigger Event:
release
-
Statement type:
File details
Details for the file iterart-0.2.0-py3-none-any.whl.
File metadata
- Download URL: iterart-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2e45ce095d4ee984ee41a1e6af99b69c57c846dcdd33301420b6da45f147141
|
|
| MD5 |
6fbe4e204a7caff98d9b8c89975db54a
|
|
| BLAKE2b-256 |
818c1b6d6da6e40aa0fb697b0e84321632cb984a76ded37e883f2f3205e327ba
|
Provenance
The following attestation bundles were made for iterart-0.2.0-py3-none-any.whl:
Publisher:
publish.yaml on karzunn/iterart
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iterart-0.2.0-py3-none-any.whl -
Subject digest:
c2e45ce095d4ee984ee41a1e6af99b69c57c846dcdd33301420b6da45f147141 - Sigstore transparency entry: 175171768
- Sigstore integration time:
-
Permalink:
karzunn/iterart@452881f06a85d3fdab1aec2c4ddd86ba3e586622 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/karzunn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@452881f06a85d3fdab1aec2c4ddd86ba3e586622 -
Trigger Event:
release
-
Statement type: