Skip to main content

A framework for creating generative art with Python

Project description

gen-art-framework

A Python framework for generating art from parameterised scripts. Define parameter distributions in YAML, and the framework samples from them to create unique variations of your artwork.

Installation

pip install gen-art-framework

Or with uv:

uv add gen-art-framework

Quick Start

Create a script with a YAML parameter block in its docstring:

"""
parameters:
  - name: seed
    distribution: constant
    value: 42
  - name: width
    distribution: constant
    value: 800
  - name: height
    distribution: constant
    value: 600
  - name: num_circles
    distribution: randint
    low: 20
    high: 50
  - name: colour
    distribution: choice
    values: ["#e94560", "#f39c12", "#00b894"]
"""

from PIL import Image, ImageDraw
import random

random.seed(seed)

img = Image.new("RGB", (width, height), "#1a1a2e")
draw = ImageDraw.Draw(img)

for _ in range(num_circles):
    x = random.randint(0, width)
    y = random.randint(0, height)
    r = random.randint(10, 50)
    draw.ellipse([x - r, y - r, x + r, y + r], fill=colour)

img

Generate images using the CLI:

# Generate a single image
gen-art sample my_script.py

# Generate 10 variations
gen-art sample my_script.py --count 10

# Specify output directory and seed for reproducibility
gen-art sample my_script.py -n 5 -o ./output -s 42

Output files are named {script_name}_{index}_{seed}.png.

Documentation

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

gen_art_framework-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gen_art_framework-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file gen_art_framework-0.1.0.tar.gz.

File metadata

  • Download URL: gen_art_framework-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for gen_art_framework-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7e97bd215406fce95227c9801baa92b7ffa5d71dec538d9d998b4589fd82741c
MD5 f753601f8456f822e533038f957572a6
BLAKE2b-256 0ce3ba20179b46ee146d0cac79f172f2076c2483c18c0495505ea1ff1ae1e013

See more details on using hashes here.

File details

Details for the file gen_art_framework-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gen_art_framework-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3e9be29e69c43ab048516fac0d05b03d963b637c51a9711e3b20f4504550daf
MD5 0292538177b7d7ba9deaf25bab52e918
BLAKE2b-256 108bddb30288b8c41a2218e38def0fcc4523c2ca6279047d1527108f5a765165

See more details on using hashes here.

Supported by

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