Hi everyone,
I’m trying to run this PGraphics example where the output is shown in an off-screen graphics buffer (3000x3000 canvas), however it seems the mouseX,mouseY coordinates are being taken from the actual 500x500 canvas. I suspect the render function is missing somewhere.
Here’s the code:
PGraphics render;
int printWidth = 10;
int printHeight = 10;
int printDpi = 300;
int renderWidth = printWidth * printDpi;
int renderHeight = printHeight * printDpi;
int[] x;
int[] y;
void setup() {
size(500,500);
render = createGraphics(renderWidth, renderHeight);
x = new int[50]; //the most recent 50 MouseX,MouseY values
y = new int[50];
}
void draw() {
background(0);
render.beginDraw();
render.noStroke();
render.fill(255,102);
for(int i = y.length - 1; i > 0; i--) {
x[i] = x[i-1];
y[i] = y[i-1];
}
//add new values to the beginning
x[0] = mouseX;
y[0] = mouseY;
for(int i = 1; i < y.length; i++) {
render.ellipse(x[i],y[i],i/2,i/2);
}
render.endDraw();
image(render,0,0,width,height);
}
Can you help me identify where the problem is? Thanks!