jupyter-widgets-contrib / ipycanvas

Interactive Canvas in Jupyter
https://ipycanvas.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
685 stars 62 forks source link

Implement save_gif function #301

Open martinRenou opened 1 year ago

martinRenou commented 1 year ago

This PR makes saving frames more reliable (fix https://github.com/martinRenou/ipycanvas/issues/222), allowing to implement a save_gif method (fix https://github.com/martinRenou/ipycanvas/issues/136)

from time import sleep

# 50Hz
frequency = 20

with save_gif(canvas, "test.gif", frequency=frequency):
    for i in range(50):
        canvas.clear()

        draw(canvas, i * frequency)

        canvas.frame()

TODO