xxxxxxxxxx
30
/*
* @name Create Graphics
* @description Creates and returns a new p5.Renderer object. Use this
* class if you need to draw into an off-screen graphics buffer. The two parameters
* define the width and height in pixels.
*/
let pg;
function setup() {
createCanvas(400, 400);
pg = createGraphics(200, 200);
}
function draw() {
fill(0, 8);
rect(0, 0, width, height);
fill(255);
noStroke();
ellipse(mouseX, mouseY, 40, 40);
pg.background(50);
pg.noFill();
pg.stroke(255);
pg.ellipse(mouseX - 150, mouseY - 75, 60, 60);
//Draw the offscreen buffer to the screen with image()
image(pg, 150, 75);
}