Skip to content

Commit

Permalink
Merge pull request #7057 from nickmcintyre/ref-p5-graphics
Browse files Browse the repository at this point in the history
Fix p5.Graphics.remove() reference
  • Loading branch information
Qianqianye committed May 21, 2024
2 parents f61cbbd + 9863c87 commit f93bc32
Showing 1 changed file with 20 additions and 2 deletions.
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

0 comments on commit f93bc32

Please sign in to comment.