Using 0118 Beta.
I'm trying out the PGraphics class for the first time. I'm trying something very simple here. I'm drawing to PGraphics every frame and then drawing PGraphics to the sketch window using image().
Quote:
PGraphics pg;
int x=0;
void setup() {
size(200, 200);
pg = createGraphics(width, height, P2D);
frameRate(1);
}
void draw() {
image(pg, 0, 0);
pg.beginDraw();
pg.stroke(255);
pg.rect(x++, 25, 10, 10);
pg.endDraw();
}
I get the following error, and the line with the 'rect' command is highlighted by Processing:
java.lang.NullPointerException
at processing.core.PGraphics2D.thin_pointAtIndex(PGraphics2D.java:1173)
at processing.core.PGraphics2D.thin_flat_line(PGraphics2D.java:1284)
at processing.core.PGraphics2D.rectImpl(PGraphics2D.java:716)
at processing.core.PGraphics.rect(PGraphics.java:1266)
at Temporary_7691_9576.draw(Temporary_7691_9576.java:16)
at processing.core.PApplet.handleDisplay(PApplet.java:1311)
at processing.core.PGraphics.requestDisplay(PGraphics.java:568)
at processing.core.PApplet.run(PApplet.java:1406)
at java.lang.Thread.run(Thread.java:552)
java.lang.NullPointerException
at processing.core.PGraphics2D.thin_pointAtIndex(PGraphics2D.java:1173)
at processing.core.PGraphics2D.thin_flat_line(PGraphics2D.java:1284)
at processing.core.PGraphics2D.rectImpl(PGraphics2D.java:716)
at processing.core.PGraphics.rect(PGraphics.java:1266)
at Temporary_7691_9576.draw(Temporary_7691_9576.java:16)
at processing.core.PApplet.handleDisplay(PApplet.java:1311)
at processing.core.PGraphics.requestDisplay(PGraphics.java:568)
at processing.core.PApplet.run(PApplet.java:1406)
at java.lang.Thread.run(Thread.java:552)