Skip to main content

A Pythonic creative coding package inspired by p5.js.

Project description

p5py

PyPI Python Versions License: LGPL-2.1 CI Downloads

p5py is a friendly Python creative-coding library inspired by p5.js. It is for people who want to sketch with code: draw shapes, animate motion, react to input, load images, play with pixels, and make small visual experiments without first building a full app.

The public API is Python-first. Function names use snake_case, sketches are ordinary Python files, and the renderer is powered by the packaged Rust canvas runtime.

Install

pip install p5py-vibe

Install optional media helpers when you need camera, video, or sound-related extras:

pip install "p5py-vibe[media]"

First Sketch

Create a file named circle_sketch.py:

import p5


@p5.setup
def setup() -> None:
    p5.create_canvas(400, 300)
    p5.no_stroke()


@p5.draw
def draw() -> None:
    p5.background(245)
    p5.fill(255, 90, 90)
    p5.circle(200, 150, 100)


p5.run()

Run it:

python circle_sketch.py

For repeatable scripts, use a bounded headless render:

p5.run(headless=True, max_frames=1)

Callbacks can also be async def, which is useful with async-compatible asset helpers:

image = None


@p5.preload
async def preload() -> None:
    global image
    image = await p5.load_image_async("sprite.png")

What You Can Make

  • 2D drawings with shapes, curves, color, transforms, and blend modes.
  • Animated sketches using the familiar setup() and draw() lifecycle.
  • Decorator-based sketches, async-compatible callbacks, and object-oriented Sketch subclasses.
  • Image and pixel experiments, including canvas export.
  • Text, font measurement, and accessibility descriptions.
  • Interactive sketches with mouse, keyboard, and touch state when native window support is available.
  • WEBGL-style 3D sketches with primitives, lights, materials, models, textures, and shaders.
  • Small games and visual toys using the examples as starting points.

Learn More

For Contributors

This repository uses uv for Python commands:

uv sync --dev
uv run ruff check .
uv run mypy src
uv run pytest

The canvas runtime is a required PyO3 extension:

uvx maturin develop --manifest-path crates/p5_canvas/Cargo.toml --module-name p5.rust._canvas --python-source src --features extension-module

The contributor documentation explains the architecture, lifecycle, testing workflow, and release shape in more detail:

Compatibility

p5py is inspired by p5.js, but it is not a browser port. It does not include DOM helpers, browser-only APIs, JavaScript aliases, or a Pillow/Pyglet fallback. Unsupported features raise explicit package errors so sketches fail clearly.

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

p5py_vibe-0.3.0.tar.gz (135.4 kB view details)

Uploaded Source

Built Distributions

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

p5py_vibe-0.3.0-cp312-cp312-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.12Windows x86-64

p5py_vibe-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

p5py_vibe-0.3.0-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

p5py_vibe-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file p5py_vibe-0.3.0.tar.gz.

File metadata

  • Download URL: p5py_vibe-0.3.0.tar.gz
  • Upload date:
  • Size: 135.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for p5py_vibe-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ab241eefc2b00ac61ac457f3f66b83fad0d811184d83d56287a3eb2712c015db
MD5 48fbf41f2ce18b83ed073b98775b4fa5
BLAKE2b-256 7538431f863f138fc6d5f3fee9176b8fc2b92f82ed847bc980d2f6632cb812b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for p5py_vibe-0.3.0.tar.gz:

Publisher: publish.yml on JonathanHHenson/p5.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file p5py_vibe-0.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: p5py_vibe-0.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for p5py_vibe-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b151b39237137e0097285da44128361dccd0be149594738037b3dc25631e9b95
MD5 f2abe8779f82679c5e23691356676477
BLAKE2b-256 12c69cb1356e2073fec0770578379981049ec1ae55b8cd5e7be63e2a8cb55df1

See more details on using hashes here.

Provenance

The following attestation bundles were made for p5py_vibe-0.3.0-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on JonathanHHenson/p5.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file p5py_vibe-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for p5py_vibe-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 79bf152c3da35ed1f7364f9c0018cd313d0e93d5eb5d23e2e368dafddb2cd25d
MD5 8ad7ecbde487edc546bb469926004705
BLAKE2b-256 c13e01abc32ac7c14397f24fbef59d1a696db556dc39d453051333b2b958a689

See more details on using hashes here.

Provenance

The following attestation bundles were made for p5py_vibe-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on JonathanHHenson/p5.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file p5py_vibe-0.3.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for p5py_vibe-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b78083cf8920b46ff678d38974791f5af1e5f9874fab6fd3451c24eb8f80c97
MD5 815368ac4f843b68fd5f665d22d1ac00
BLAKE2b-256 badd2ece0880474e6ac5c75db9e8d686e47f951ba346757336b8bacf6a4883e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for p5py_vibe-0.3.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on JonathanHHenson/p5.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file p5py_vibe-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for p5py_vibe-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b940224d0c25e824a48050f0dc540352e41136a17f98f96418b9331337d988fc
MD5 2daaa87d1c2e500d812fa2fdfdf0916c
BLAKE2b-256 bb888bdca8ccd42c5b18263b3bd387e4388830694e5795213f9a74e4d2559930

See more details on using hashes here.

Provenance

The following attestation bundles were made for p5py_vibe-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: publish.yml on JonathanHHenson/p5.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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