Processing for CPython
Project description
py5
py5 is a new version of Processing for Python 3.9+. The goal of py5 is to create a version of Processing that is integrated into the Python ecosystem. Built into the library are thoughtful choices about how to best get py5 to work with other popular Python libraries and tools such as Jupyter, numpy, shapely, trimesh, matplotlib, and Pillow.
py5 is an excellent choice for educators looking to teach Python in the context of creative coding and is currently used in classrooms all around the world. The documentation website includes introductory tutorials as well as extensive reference documentation, complete with example code.
Basic Example
Here is a basic example of a working py5 Sketch:
import py5
def setup():
py5.size(400, 400)
py5.rect_mode(py5.CENTER)
def draw():
py5.square(py5.mouse_x, py5.mouse_y, 10)
def mouse_clicked():
py5.fill(py5.random_int(255), py5.random_int(255), py5.random_int(255))
py5.run_sketch()
Installation
If you have Java 17 installed on your computer, you can install py5 using pip:
pip install py5
Detailed installation instructions are available on the documentation website. There are some Special Notes for Mac Users that you should read if you use macOS.
Getting Started
If you are new to Python, start with the intro to py5 and python tutorials. If you are familiar with Java programming and Processing, you'll find the Tips for Processing Java Users page to be helpful.
There are currently five basic ways to use py5. They are:
- module mode: create a sketch with
setup()
anddraw()
functions that call methods provided by thepy5
library. The above example is created in module mode. - class mode: create a Python class inherited from
py5.Sketch
. This mode supports multiple Sketches running at the same time. - imported mode: simplified code that omits the
py5.
prefix. This mode is supported by the py5 Jupyter notebook kernel and therun_sketch
command line utility. - static mode: functionless code to create static images. This mode is supported by the py5bot Jupyter notebook kernel, the
%%py5bot
IPython magic, and therun_sketch
command line utility. - processing mode: make calls to Python from a Processing (Java) Sketch. This mode enables py5 to function as bridge, connecting the Python and Java ecosystems through a new
callPython()
method.
Source Code
py5 was created by the artist and software developer Jim Schmitz (@hx2A) starting in March of 2020. The library is the foundation of his art practice.
The py5 library makes the Java Processing jars available to the CPython interpreter using JPype. It can do just about everything Processing can do, except with Python instead of Java code. New py5 features and bug fixes are being added to py5 every day. The library is always in active development and is well maintained.
To view the actual installed py5 library code, look at the py5 repository. The py5 library code is the output of the meta-programming project py5generator. All py5 development is done through py5generator.
Funding
This project is not an official part of the Processing Foundation and is not receiving any funding from them. Any funds you contribute will be used first for website expenses and next to support @hx2A's time to further develop py5 as a solid creative coding framework used by educators, artists, and hobbyists all around the world.
Get In Touch
Have a comment or question? We'd love to hear from you! The best ways to reach out are:
- github discussions and issues
- Mastodon fosstodon.org/@py5coding
- twitter @py5coding
- processing foundation discourse
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
File details
Details for the file py5-0.10.3a1.tar.gz
.
File metadata
- Download URL: py5-0.10.3a1.tar.gz
- Upload date:
- Size: 11.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f757d13518e60245436927ab780208f154f928774db7ecc33a5e2df1a8fa4dec |
|
MD5 | 8fea024550edc444b8628ebae267675e |
|
BLAKE2b-256 | 8c2f22060b373c0b5d4ac49aa5aa8963cb09740b0761a4c289a783d627813671 |
File details
Details for the file py5-0.10.3a1-py3-none-any.whl
.
File metadata
- Download URL: py5-0.10.3a1-py3-none-any.whl
- Upload date:
- Size: 11.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e1c6c55ba4eb426ea2e35bdd502cb2d13ca7ccfb748ca609f30217f3689e871 |
|
MD5 | 643c4c97264c4784f511163b442fb995 |
|
BLAKE2b-256 | 2eaf0fc7dab0916308d75f28be2e4a32eef756421c0270e61ab6e30a0c8daf64 |