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

Fix p5.Graphics.remove() reference #7057

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/core/p5.Graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,22 @@ p5.Graphics = class extends p5.Element {
/**
* Removes the graphics buffer from the web page.
*
* Calling `myGraphics.remove()` removes the graphics buffer's canvas along
* with any HTML elements it created.
* Calling `myGraphics.remove()` removes the graphics buffer's
* `<canvas>` element from the web page. The graphics buffer also uses
* a bit of memory on the CPU that can be freed like so:
*
* ```js
* // Remove the graphics buffer from the web page.
* myGraphics.remove();
*
* // Delete the graphics buffer from CPU memory.
* myGraphics = undefined;
* ```
*
* Note: All variables that reference the graphics buffer must be assigned
* the value `undefined` to delete the graphics buffer from CPU memory. If any
* variable still refers to the graphics buffer, then it won't be garbage
* collected.
*
* @method remove
*
Expand Down Expand Up @@ -358,7 +372,11 @@ p5.Graphics = class extends p5.Element {
* // Remove the p5.Graphics object when the
* // the user double-clicks.
* function doubleClicked() {
* // Remove the p5.Graphics object from the web page.
* pg.remove();
*
* // Delete the p5.Graphics object from CPU memory.
* pg = undefined;
* }
* </code>
* </div>
Expand Down
Loading