Skip to content

Instantly share code, notes, and snippets.

@wanbinkimoon
Last active March 14, 2018 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wanbinkimoon/0771fea9b199ce5ac32edc8f6d815584 to your computer and use it in GitHub Desktop.
Save wanbinkimoon/0771fea9b199ce5ac32edc8f6d815584 to your computer and use it in GitHub Desktop.
p5 multiple graphics in es6
import p5 from 'p5';
import 'p5/lib/addons/p5.sound';
const sketch = p => {
let canvas;
let scene1;
let scene2;
p.setup = () => {
p.createCanvas(p.windowWidth, p.windowHeight);
// p.colorMode(p.HSB)
scene1 = p.createGraphics(400, 400);
scene2 = p.createGraphics(400, 400);
p.background(100)
};
const drawScene1 = () => {
console.log(p.createGraphics)
}
const drawScene2 = () => {
scene2.background(125, 255, 125)
}
p.draw = () => {
drawScene1()
drawScene2()
};
p.windowResized = () => {
p.resizeCanvas(p.windowWidth, p.windowHeight);
};
p.mousePressed = () => {};
};
new p5(sketch);
@byxor
Copy link

byxor commented Mar 12, 2018

You mentioned on stackoverflow that you were having problems with this snippet. What are they? I might be able to help but I won't guarantee it.

@wanbinkimoon
Copy link
Author

i fixed the issue, I forgot to reference the graphic in p.Image(scene2, 0, 0 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment