jupyter-widgets-contrib / ipycanvas

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

Proposal: `canvas.copy()` #198

Open erincar opened 3 years ago

erincar commented 3 years ago

Hi,

First off, let me say that I like your project. I am planning to use it for having step-by-step logs of interactive experiments on the canvas.

When I first started with this idea, I tried to incrementally make changes on the same canvas & redraw under each cell. However, since this operation modifies the same canvas instance, different states of the progress can not be logged with this approach.

Therefore, I have implemented a small prototype for copy functionality to be added to Canvas, RoughCanvas, MultiCanvas, MultiRoughCanvas. You can find it in this Jupyter notebook. As GitHub is unable to render the canvas outputs, I'll share a few visuals as well:

output 1

output 2

output 3

Let me know if you'd be interested in this, and I would be happy to propose the PR for it.

Best wishes, Erinc

martinRenou commented 3 years ago

Hi Erinc :)

That would be nice, but I fear there will be problems with the way hold_canvas works, this kind of API (manipulating multiple canvases) would not work properly with hold_canvas.

So I would be 👍🏼 for this, but we might need to rethink the logic of hold_canvas before adding such a feature.

erincar commented 3 years ago

Thanks for the swift answer :)

I am going to look into this and let you know if I come up with an idea about it. I'm not an expert in this field so it might take a while 😀 Cheers!