We are about to switch to a new forum software. Until then we have removed the registration on this forum.
When running this sketch, press any key to cause the PGraphics to be displayed. When P2D and noSmooth() are used, the PGraphics is displayed only momentarily. Is there a logical reason for this?
PGraphics pg1;
void setup() {
size(640, 480, P2D); // remove P2D's to allow pg1 to be displayed
noSmooth(); // or remove this to allow pg1 to be displayed
background(0);
fill(0, 255, 0);
rect(0, 0, 100, 200);
pg1 = createGraphics(width, height, P2D);
pg1.noSmooth();
pg1.beginDraw();
pg1.background(255);
pg1.fill(0);
pg1.rect(100, 100, 100, 50);
pg1.endDraw();
}
void draw() {
}
void keyPressed() {
background(0);
image(pg1, 0, 0, width, height);
}
Answers
That is weird. You should consider filing a bug on GitHub (make sure you look to see if an existing bug has already been filed).
A workaround would be to get rid of your
keyPressed()
function and check thekeyPressed
variable indraw()
instead:@brontosplachna -- was this ever filed as a bug on https://github.com/processing/processing/issues ?