createGraphics

Static createGraphics 

Source
pub static createGraphics: CreateGraphicsInternalType
Expand 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.

Examples

let pg;
function setup() {
  createCanvas(100, 100);
  pg = createGraphics(100, 100);
}

function draw() {
  background(200);
  pg.background(100);
  pg.noStroke();
  pg.ellipse(pg.width / 2, pg.height / 2, 50, 50);
  image(pg, 50, 50);
  image(pg, 0, 0, 50, 50);
}

Parameters

w width of the offscreen graphics buffer

h height of the offscreen graphics buffer

renderer? either P2D or WEBGL undefined defaults to p2d