Py5 Magics

Py5 Magics#

The py5 Magics are Jupyter Notebook “meta-commands” that can be within Jupyter Notebooks to enhance py5’s ability to work within the notebook.

Examples#

example picture for Py5 Magics

%%py5draw 100 100
py5.background(128)
py5.fill(255, 0, 0)
py5.rect(40, 50, 25, 25)
%%py5drawsvg 200 200
py5.background(128)
py5.fill(255, 0, 0)
py5.rect(80, 100, 50, 50)
%%py5drawpdf 200 200 /tmp/test.pdf
py5.background(128)
py5.fill(255, 0, 0)
py5.rect(80, 100, 50, 50)

Description#

The py5 Magics are Jupyter Notebook “meta-commands” that can be within Jupyter Notebooks to enhance py5’s ability to work within the notebook. The py5 magics will enable users to create Sketches and embed the results in the Notebook without defining any functions or calling the size() function.

The following magics are provided:

  • %%py5bot: Create a PNG image using py5bot and embed the result in the notebook.

  • %%py5draw: Create a PNG image with py5 and embed the result in the notebook.

  • %%py5drawdxf: Create a DXF file with py5.

  • %%py5drawpdf: Create a PDF with py5.

  • %%py5drawsvg: Create a SVG drawing with py5 and embed the result in the notebook.

Updated on March 06, 2023 02:49:26am UTC