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

Drawing circle from mouse_down method glitched #90

Open
ckski opened this issue Nov 25, 2020 · 3 comments
Open

Drawing circle from mouse_down method glitched #90

ckski opened this issue Nov 25, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@ckski
Copy link
Contributor

ckski commented Nov 25, 2020

To reproduce use the following code:

def setup():
    size(400,400)

def draw():
    pass
            
def mouse_down():
    fill_circle(mouse_x, mouse_y, 10)

Click in the top left hand corner repeatedly and after a while the circle will start being drawn at the wrong scale and position.

When testing the fix, test out with the ellipse function also.

@ckski ckski added the bug Something isn't working label Nov 25, 2020
@ckski
Copy link
Contributor Author

ckski commented Nov 25, 2020

The fill_circle method calls helper_fill_arc which manipulates the scale and translation of the canvas. Something is likely not getting reset properly.

@ckski
Copy link
Contributor Author

ckski commented Nov 25, 2020

One suggested solution is to change the implementation of the helper_fill_arc and helper_stroke_arc to not need to use translate and scale.

@lawruble13
Copy link
Contributor

One suggested solution is to change the implementation of the helper_fill_arc and helper_stroke_arc to not need to use translate and scale.

I think this is the best solution, at the original time of writing arc and ellipse did not yet exist, but I believe they were added to later versions of ipycanvas. Another solution is to use canvas.save and canvas.restore instead of manually undoing the transformations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants