py5

py5 is a new version of Processing for Python 3.8+. It makes the Java Processing jars available to the CPython interpreter using JPype. It can do just about all of the 2D and 3D drawing Processing can do, except with Python instead of Java code.

The goal of py5 is to create a new 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, and Pillow.

Here is a simple example of a working py5 Sketch, written in module mode:

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()

That creates a Sketch that looks like this:

/images/py5/project_example.gif

This project started at the beginning of the COVID pandemic as a way for me to manage stress. Since then it has grown into a library used by Python programmers all around the world. There's much more to be said than what can be included here. Head over to the py5 documentation website to learn more!