Open ianhi opened 3 years ago
Thanks for opening an issue! It's a good idea indeed :) Note that you can use ipyevents already (although not yet JupyterLab 3 compatible but should soon be) but having it built-in ipycanvas would be good.
[...] and am thinking about re-writing it entirely using ipycanvas to make it easier to develop/contribute to and to make it more extensible for users
That sounds like a good idea. But I suppose ipycanvas also has multiple disadvantages compared to your implementation (slow server roundtrip for mouse-interaction/redraw). One idea would be to make it a subwidget of ipycanvas, and implement the lasso selection fully in the front-end so that you don't pay the server roundtrip cost.
but having it built-in ipycanvas would be good.
I think it would also be necessary for https://github.com/martinRenou/ipycanvas/issues/179 to happen.
One idea would be to make it a subwidget of ipycanvas, and implement the lasso selection fully in the front-end so that you don't pay the server roundtrip cost.
oooh that's a good idea. I think this is the probably the best way forward.
slow server roundtrip for mouse-interaction/redraw).
I was worried about this, but when I tried the hand-drawing example I found that even with the extra latency of binder it was very responsive. Especially in contrast to the equivalent implemented using matplotlib and run locally (https://mybinder.org/v2/gh/ianhi/mpl-interactions/0.17.12?filepath=examples/image-segmentation.ipynb)
It would be nice to be capture scroll events in order to implement things like scrolling on zoom. This could borrow from how ipympl achieved this:
https://github.com/matplotlib/ipympl/blob/54b2a2213f4941933c00f570f3008bf6db153b99/js/src/mpl_widget.js#L565-L575
For context I've put some work into a purely
js
canvas implementation of a segmentation library https://github.com/ianhi/ipysegment but was slowed down by writing everything in javascript and am thinking about re-writing it entirely using ipycanvas to make it easier to develop/contribute to and to make it more extensible for users. And scroll to zoom and move around is crucial feature for such a library