Skip to content

Commit 6db04bb

Browse files
author
lauren mccarthy
committed
small fix to p5.dom
1 parent 66e0844 commit 6db04bb

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
// CASE 1: no node specified, createCanvas called
22
// Canvas is generated and appended to body.
3-
var s = function( sketch ) {
3+
4+
5+
var s = function( p ) {
46

57
var gray = 0;
68

7-
sketch.setup = function() {
8-
sketch.createCanvas(400, 400);
9+
p.setup = function() {
10+
p.createCanvas(400, 400);
911
};
1012

11-
sketch.draw = function() {
12-
sketch.background(gray);
13-
sketch.rect(sketch.width/2, sketch.height/2, 50, 50);
13+
p.draw = function() {
14+
p.background(gray);
15+
p.rect(p.width/2, p.height/2, 50, 50);
1416
}
1517

16-
sketch.mousePressed = function() {
18+
p.mousePressed = function() {
1719
gray += 10;
1820
}
1921

2022
};
2123

22-
var myp5 = new p5(s);
24+
var myp5 = new p5(s);
25+

lib/addons/p5.dom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ var p5DOM = (function(){
292292
w = w || v.width;
293293
h = h || v.height;
294294
}
295-
this._curElement.context.drawImage(frame, x, y, w, h);
295+
this.canvas.getContext('2d').drawImage(frame, x, y, w, h);
296296
};
297297

298298

0 commit comments

Comments
 (0)