Skip to content

Commit 178d2cb

Browse files
committed
fixes
1 parent b78818b commit 178d2cb

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

lib/empty-example/sketch.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
let g;
2+
13
function setup() {
2-
// put setup code here
3-
}
4-
5-
function draw() {
6-
// put drawing code here
7-
}
4+
createCanvas(400, 400);
5+
6+
g = createGraphics(200, 200);
7+
}
8+
9+
function draw() {
10+
g.background(0);
11+
g.stroke(255, 0, 0);
12+
g.strokeWeight(5);
13+
g.noFill();
14+
g.bezier(0, 0, 100, 0, 0, 100, 200, 200);
15+
image(g, 0, 0, 400, 400);
16+
}

src/core/p5.Graphics.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,4 @@ function graphics(p5, fn){
695695
}
696696

697697
export default graphics;
698-
export { Graphics };
699-
if (typeof p5 !== 'undefined') {
700-
graphics(p5, p5.prototype);
701-
}
698+
export { Graphics };

src/core/p5.Renderer2D.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ class Renderer2D extends Renderer {
7474
this.filterRenderer = new FilterRenderer2D(this);
7575
}
7676
// Set and return p5.Element
77-
this.wrappedElt = new Element(this.elt, this._pInst);
78-
77+
// this.wrappedElt = new Element(this.elt, this._pInst);
78+
// Pass the *sketch* (p5) instance, not the Graphics buffer itself
79+
const sketch = this._pInst && this._pInst._pInst ? this._pInst._pInst : this._pInst;
80+
this.wrappedElt = new Element(this.elt, sketch);
7981
this.clipPath = null;
8082
}
8183

0 commit comments

Comments
 (0)