Processing's PGraphics is an independent off-screen drawing layer with its own coordinate system and settings
In Processing, createGraphics() makes a PGraphics — an off-screen drawing surface, conceptually like a Photoshop layer you can draw onto and then move around. Code between pg.beginDraw() and pg.endDraw() renders into that buffer independently of the main sketch canvas. The PGraphics has its own size, coordinate origin, imageMode, text/font settings, and background; none of the parent sketch’s settings apply to it automatically, so calls like imageMode(CENTER) or textFont() must be repeated on the pg object (as pg.imageMode / pg.textFont). To show it on the main canvas, draw it with image(pg, x, y). This separation lets you compose individual elements independently, then position and composite them in the draw loop.
Examples
PGraphics pg = createGraphics(850, 810); pg.beginDraw(); pg.background(20); pg.imageMode(CENTER); pg.image(img, pg.width/2, pg.height/2); pg.endDraw(); image(pg, width/2, height/2);
Assessment
If you call imageMode(CENTER) in the main sketch, does it affect how images are placed inside a PGraphics? Where must imageMode be set to affect PGraphics contents?