Is it an error to call image() with a "virgin" PGraphics? Or is this a bug?

Question: should I report this as a bug? Or is this considered user error?

Evidently, calling image() on a PGraphics object that hasn't been drawn into generates a NullPointerException. The following program generates a NullPointerException:

void setup() {
    size(800,800);
    PGraphics pg = createGraphics(800, 800);
    pg.colorMode(HSB, 1.0);
    image(pg, 0, 0);      // NullPointerException here
}

The following program works without error:

void setup() {
    size(800,800);
    PGraphics pg = createGraphics(800, 800);
    pg.colorMode(HSB, 1.0);
    pg.beginDraw();
    pg.endDraw();
    image(pg, 0, 0);      // now it works without error
}

Answers

Sign In or Register to comment.