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

Program crashes upon resizing window to 0 #473

Open
PsychoticTomato opened this issue Oct 10, 2024 · 3 comments
Open

Program crashes upon resizing window to 0 #473

PsychoticTomato opened this issue Oct 10, 2024 · 3 comments

Comments

@PsychoticTomato
Copy link

Describe the bug
When resizing the p5 program window to a state where either the height or the width are zero, the program crashes with a ZeroDivisionError.

To Reproduce
This is my code:

import p5


class DrawSquare():
    def __init__(self):
        p5.size(600, 600)
        p5.no_stroke()
        p5.background(204)


if __name__ == '__main__':
    p5.run(renderer="vispy")
    square = DrawSquare()

Expected behavior
The program keeps running for a second with the window turning black, then crashes.

Screenshots
image

System information:

  • p5 release (version number or latest commit): 0.8.4
  • Python version: 3.10
  • Operating system: Windows
Copy link
Contributor

Thank you for submitting your first issue to p5py

@tushar5526
Copy link
Member

I am curious to know the use case behind setting height or width to 0.

@PsychoticTomato
Copy link
Author

It's not a use case, it's a normal occurence when manually resizing the window with your cursor. Try resizing it in a way that minimizes one of the axes and the program crashes. Seems to happen because some of the screen update functions divide length by width or width by length. Having a minimum number of pixels for height/width would solve the issue.

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