A Pythonic creative coding package inspired by p5.js.
Project description
p5-py
p5-py is a Pythonic creative-coding package inspired by p5.js.
It keeps the familiar p5 sketch lifecycle and many p5-style APIs while staying native to Python, backend-agnostic, typed, and testable.
Status
The current package supports a strong 2D-first workflow, a deterministic headless renderer, a native Pyglet interactive backend, optional WEBGL-style/3D APIs, optional media extras, and optional Rust acceleration for a few compute-heavy paths.
The public API is intentionally Python-first:
- canonical APIs use
snake_case, such ascreate_canvas()andframe_rate() - p5.js-style aliases such as
createCanvas()andframeRate()delegate to the same implementations - excluded browser-only APIs fail with explicit
p5exceptions instead of failing indirectly
Installation
Install the published package with pip:
pip install p5-py
Install optional media support when you need camera/video helpers:
pip install "p5-py[media]"
For local development in this repository, use uv:
uv sync --dev
Quick start
import p5
def setup() -> None:
p5.create_canvas(320, 240)
p5.no_stroke()
def draw() -> None:
p5.background(245)
p5.fill(255, 80, 80)
p5.circle(160, 120, 80)
p5.run(setup=setup, draw=draw)
Run a sketch headlessly for deterministic tests or export flows:
uv run python examples/basic_shapes.py --backend headless --frames 1
Backends
p5-py keeps the user-facing API backend-agnostic.
headlessrenders deterministically with Pillow and is ideal for tests, CI, and export.pillowis currently an alias ofheadless.pygletopens a native interactive window and presents frames with HiDPI support.
For backend details, see docs/user/backends.md.
Examples
Examples live in examples/.
A few useful entry points:
examples/basic_shapes.pyexamples/bouncing_ball.pyexamples/transforms.pyexamples/image_text_data.pyexamples/pixels_blend_export.pyexamples/plugin_hooks.pyexamples/webgl_primitives_gallery.py
See examples/README.md for the full index.
Documentation map
User docs:
docs/user/getting_started.mddocs/user/lifecycle.mddocs/user/backends.mddocs/user/compatibility.mddocs/user/images_and_pixels.mddocs/user/events.mddocs/user/plugins.md
Technical docs:
docs/technical/testing.mddocs/technical/releasing.mddocs/technical/hidpi_rendering.mddocs/technical/native_pyglet_renderer.mddocs/technical/rust_acceleration.mddocs/technical/advanced_3d_media_strategy.mddocs/technical/project_plan.md
Development workflow
Common local commands:
uv run ruff check .
uv run ruff format .
uv run mypy src
uv run pytest
uv run python examples/basic_shapes.py --backend headless --frames 1
uv build
Equivalent shortcuts are available in Makefile:
make lint
make test-fast
make test
make typecheck
make build
Compatibility policy
p5-py aims to keep the p5 mental model while remaining idiomatic Python.
- Use the snake_case APIs as the canonical interface.
- Use camelCase aliases when porting or teaching from p5.js material.
- DOM and browser-only features are excluded.
- Unsupported compatibility stubs raise explicit package-specific errors.
See docs/user/compatibility.md for details.
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 p5py_vibe-0.1.2.tar.gz.
File metadata
- Download URL: p5py_vibe-0.1.2.tar.gz
- Upload date:
- Size: 324.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce890681d514853818764b61967211aa1b73146113c04e929b2cac2d30e3c770
|
|
| MD5 |
655af26d3f1de1863ca65e0485d14fb7
|
|
| BLAKE2b-256 |
8075fd87d8f9877b3d57d0ec8c962a27026d7d6fa49b6d28534a91eb8d65a84d
|
Provenance
The following attestation bundles were made for p5py_vibe-0.1.2.tar.gz:
Publisher:
publish.yml on JonathanHHenson/p5.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
p5py_vibe-0.1.2.tar.gz -
Subject digest:
ce890681d514853818764b61967211aa1b73146113c04e929b2cac2d30e3c770 - Sigstore transparency entry: 1829524500
- Sigstore integration time:
-
Permalink:
JonathanHHenson/p5.py@a732191cd8c10ef5b7ccc96b42dd332879386eb9 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/JonathanHHenson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a732191cd8c10ef5b7ccc96b42dd332879386eb9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file p5py_vibe-0.1.2-py3-none-any.whl.
File metadata
- Download URL: p5py_vibe-0.1.2-py3-none-any.whl
- Upload date:
- Size: 85.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f06c0a54d8271f4f722719924715462a9c23a679de77c1f781e6f9bb0600583
|
|
| MD5 |
697c9ba5d1a3592ac60e72945d3a8049
|
|
| BLAKE2b-256 |
2c0d7f02ec8181061ac2d6156aaae2a45e647d825f04afdeaaf762cc28fe5b4d
|
Provenance
The following attestation bundles were made for p5py_vibe-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on JonathanHHenson/p5.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
p5py_vibe-0.1.2-py3-none-any.whl -
Subject digest:
4f06c0a54d8271f4f722719924715462a9c23a679de77c1f781e6f9bb0600583 - Sigstore transparency entry: 1829524622
- Sigstore integration time:
-
Permalink:
JonathanHHenson/p5.py@a732191cd8c10ef5b7ccc96b42dd332879386eb9 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/JonathanHHenson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a732191cd8c10ef5b7ccc96b42dd332879386eb9 -
Trigger Event:
push
-
Statement type: