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

Graphics buffer and clearing the canvas #222

Open
AhmadMoussa opened this issue May 19, 2022 · 1 comment
Open

Graphics buffer and clearing the canvas #222

AhmadMoussa opened this issue May 19, 2022 · 1 comment

Comments

@AhmadMoussa
Copy link

First off thanks so much for this wonderful library! It helped me out a lot for a project! This is not an issue per se, but I was stuck for a while on some behaviour that took me quite a while to wrap my head around it.

When using a graphics buffer in the regular P5 runtime, there's generally no need to call the background() function or clear the canvas when the graphics buffer takes up the entire size of the canvas and is drawn over it with image(buffer, 0, 0, windowWidth, windowHeight).

The graphics buffer needs to essentially be instantiated like this createGraphics(buffer_size, buffer_size, SVG) same is not true for the SVG runtime, it will simply keep adding the graphics buffer over and over again as a new, nested SVG, slowly increasing the size.

This can be solved in two ways, either by calling background() which clears the canvas, or renderer.drawingContext.__clearCanvas() before redrawing the graphics buffer. This is fine, but it might be nice to have a little note about that behaviour somewhere.

@petemahon
Copy link

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