Package Exports
- ipycanvas
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ipycanvas) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ipycanvas
Interactive widgets library exposing the browser's Canvas API to Python. There are some API differences though:
- The
Canvaswidget is exposing theCanvasRenderingContext2DAPI - All the API is written in
snake_caseinstead ofcamelCase, so for examplec.fillStyle = 'red'becomesc.fill_style = 'red' - The
Canvaswidget exposes aclearmethod,c.clear()is a shortcut forc.clear_rect(0, 0, c.size[0], c.size[1]) - We provide a
hold_canvascontext manager if you want to perform lots of commands at once - The Web canvas
putImageDatamethod does not support transparency, ourCanvas.put_image_datadoes support it!
Try it online!
You can try it online by clicking on this badge:
Documentation
You can read the documentation following this link: https://ipycanvas.readthedocs.io/en/latest/
Examples
Create John Conway's Game Of Life

Draw Particles from IPython

Custom Sprites
![]()
Draw data directly from a NumPy array

Installation
You can install using pip:
pip install ipycanvasOr using conda:
conda install -c conda-forge ipycanvasAnd if you use jupyterlab:
jupyter labextension install @jupyter-widgets/jupyterlab-manager ipycanvasIf you are using Jupyter Notebook 5.2 or earlier, you may also need to enable the nbextension:
jupyter nbextension enable --py [--sys-prefix|--user|--system] ipycanvasInstallation from sources
You can install using pip:
git clone https://github.com/martinRenou/ipycanvas
cd ipycanvas
pip install .And if you use jupyterlab:
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install .And you use the classical Jupyter:
jupyter nbextension install --py --symlink --sys-prefix ipycanvas
jupyter nbextension enable --py --sys-prefix ipycanvas