0005-JS-P5E-CreateGraphics

 




let pg;

/*
Use this class if you need to draw into an off-screen graphics buffer. 
The two parameters define the width and height in pixels.
*/

function setup() {
  createCanvas(710400);
  pg = createGraphics(400250);
}

function draw() {

  fill(012);
  rect(00, width, height);

  fill(255);
  noStroke();
  ellipse(mouseX, mouseY, 6060);

  pg.background(51);
  pg.noFill();
  pg.stroke(255);
  pg.ellipse(mouseX - 150, mouseY - 756060);

  //Draw the offscreen buffer to the screen with image()
  image(pg, 15075);

}

Comments