Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixes
  • Loading branch information
perminder-17 committed May 18, 2025
commit 178d2cbeb53d00794ba8f1517c17d180b10781d4
21 changes: 15 additions & 6 deletions lib/empty-example/sketch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
let g;

function setup() {
// put setup code here
}

function draw() {
// put drawing code here
}
createCanvas(400, 400);

g = createGraphics(200, 200);
}

function draw() {
g.background(0);
g.stroke(255, 0, 0);
g.strokeWeight(5);
g.noFill();
g.bezier(0, 0, 100, 0, 0, 100, 200, 200);
image(g, 0, 0, 400, 400);
}
5 changes: 1 addition & 4 deletions src/core/p5.Graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,4 @@ function graphics(p5, fn){
}

export default graphics;
export { Graphics };
if (typeof p5 !== 'undefined') {
graphics(p5, p5.prototype);
}
export { Graphics };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor: trailing slash / accidental line change here

6 changes: 4 additions & 2 deletions src/core/p5.Renderer2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ class Renderer2D extends Renderer {
this.filterRenderer = new FilterRenderer2D(this);
}
// Set and return p5.Element
this.wrappedElt = new Element(this.elt, this._pInst);

// this.wrappedElt = new Element(this.elt, this._pInst);
// Pass the *sketch* (p5) instance, not the Graphics buffer itself
const sketch = this._pInst && this._pInst._pInst ? this._pInst._pInst : this._pInst;
this.wrappedElt = new Element(this.elt, sketch);
this.clipPath = null;
}

Expand Down
Loading