Skip to content

jtpio/ipyp5

Folders and files

NameName
Last commit message
Last commit date
Jul 7, 2019
Jul 6, 2019
Jul 2, 2018
Jul 6, 2019
Jul 6, 2019
Jul 6, 2019
Jul 2, 2018
Jul 6, 2019
Jul 6, 2019
Jul 2, 2018
Jul 2, 2018
Jul 7, 2019
Jul 2, 2018
Oct 16, 2020
Jul 6, 2019
Jul 27, 2018
Jul 2, 2018
Dec 3, 2018
Jul 28, 2018
Jul 6, 2019
Dec 3, 2018

Repository files navigation

ipyp5

Build Status Documentation Status Code style: black pypi Python Versions License Binder

⚠️ Disclaimer: this is a work in progress! ⚠️

p5.js in the Jupyter Notebook using the Jupyter Widgets.

This project aims to be a follow-up of p5-jupyter-notebook, so that p5 can be used in JupyterLab (and in the classic Notebook) as a proper package.

Current Status

screencast

  • Define a sketch using the instance mode of p5. This explains the use of p in the sample sketch.
  • The sketch is synced to the widget as a raw string and evaluated on the frontend.

TODO

  • Figure out how to expose a Python wrapper to the p5 API
  • How to avoid round trips to the server (syncing of values) when making animations (updating values at every frame)?
  • Proper testing, packaging and documentation once the problems above are solved

Goal

The ideal goal (disclaimer: not implemented yet) would be to write code like this in a notebook cell:

class MySketch(BaseSketch):
    W, H = 400, 400

    def setup(s):
        s.createCanvas(s.W, s.H)
        s.rectMode(s.CENTER)

    def draw(s):
        s.background('#ddd')
        s.translate(200, 200)
        for i in range(4):
            s.push()
            s.rotate(s.frameCount / 200 * (i + 1))
            s.fill(i * 5, i * 100, i * 150)
            s.rect(0, 0, 200, 200)
            s.pop()

sketch = MySketch()
sketch

Contributing

See CONTRIBUTING.md