PGraphics::scale() not exporting in P3D

edited June 2016 in Library Questions

When exporting a PGraphicss P3D object, save() doesn't reflect calls to scale(). Consider the example, taken from https://forum.processing.org/two/discussion/3227/high-resolution-export-p3d: (note that endRecord() and PGpx.scale() had to be changed in order for the original example to work):

boolean record;
int scalePG = 2;

void setup() {
    size(600, 600, P3D);
    smooth();
}

void draw() {
    if(!record)
        background(#ffffff);
    translate(width/2, height/2);
    fill(#ff0000);
    rotateX(60);
    rotateZ(60);
    box(100);
}
void keyPressed() {
    save("lowres.png");

    if(keyCode == ENTER) {
        PGraphics PGpx = createGraphics(width * scalePG, height * scalePG, P3D);
        record = true;
        beginRecord(PGpx);
        PGpx.background(#ffffff, 0); // Clear the offscreen canvas (make it transparent)
        PGpx.scale(scalePG);
        draw();
        endRecord(); // originally was AFTER call to save() in next line - but didn't save anything.
        PGpx.save("highres.png"); // Save image as PNG (JPGs can't have an alpha channel) and save it before endRecord()

        record = false;
    }
}

I posted some pictures about this in this post: https://forum.processing.org/two/discussion/17162/high-resolution-output-for-p3d

Does anyone know how to fix this?

Answers

  • I posted some pictures about this in this post

    so why did you create a new thread?

  • @koogs because the problem with scale() wasn't the focus of the previous posts. It seemed worthwhile to point this out explicitly, since it actually seems to be the common problem to the other posts.

Sign In or Register to comment.