Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CanvasView and clear_rect #58

Closed
JeremiasE opened this issue Dec 20, 2019 · 5 comments
Closed

CanvasView and clear_rect #58

JeremiasE opened this issue Dec 20, 2019 · 5 comments

Comments

@JeremiasE
Copy link
Contributor

Clearing a rectangle is not visible in previous views of the widget. To be more precise construct a canvas widget and show it:

from ipycanvas import Canvas  
canvas = Canvas(size=(200, 200))  
canvas.fill_rect(0,0,100,100)  
canvas  

Now clear a rectangle:

canvas.clear_rect(0,0,20,20)

This does not result in a change of the visible canvas widget.
Showing another instance of the widget by putting

canvas

in a new cell shows the cleared rectangle however.

Is this intentional?

It seems to be due to the fact that the views are updated by drawing the model canvas on them, but clearing a rectangle makes it transparent. Putting this.clear() before
the call to drawImage in updateCanvas fixes this for me.

@martinRenou
Copy link
Collaborator

martinRenou commented Dec 20, 2019

I am surprised I did not see this! Thanks a lot :)

Indeed calling this.clear before updating the view with drawImage should fix this. Do you want to open a PR so you get credits for your fix?

@JeremiasE
Copy link
Contributor Author

I opened #60. I was afraid that clearing the canvas would result in flickering animations but at least in the game of life example I didn't notice anything.

@martinRenou
Copy link
Collaborator

Thanks a lot! I was also afraid of the flickering at first but I suppose it will be fine.

@martinRenou
Copy link
Collaborator

Fixed by #60

@martinRenou
Copy link
Collaborator

0.4.1 with your fix released on PyPi :) Coming soon on conda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants