Exporting images seems broken in Processing 4.4.4
Here’s a sketch that demonstrates the issue. The canvas size is set to 500x500, but the .png file exports at 1000x1000. Exporting as .pdf or .svg results in the correct page size, but it only includes the upper left corner of the image.
/*Testing Export in Processing 4.4.4
*
* canvas size is 500x500, but .png exports at 1000x1000
* PDF/SVG exports at 500x500, but only contains top, left corner of image
*/
//import libraries
import processing.svg.*; //for export
import processing.pdf.*; //for export
//change these settings
boolean record = false;
//declare global variables
float midX, midY; //store midpoints of screen
void setup() {
size(500, 500);
//derived variables
midX = width/2;
midY = height/2;
noLoop();
}
void draw() {
if (record) {
beginRecord(PDF, "exportTest_##.pdf");
//beginRecord(SVG, "exportTest_##.svg");
}
//drawing code goes here
rectMode(CENTER);
rect(midX, midY, width*0.9, height*0.9); //draw a box slightly smaller than the canvas
//done drawing
if (record) {
endRecord();
println("SVG/PDF recorded!");
record=false;
saveFrame("exportTest_##.png"); //save screenshot
//println("PNG saved!");
}
}
void keyReleased() {
if (key == ' ') redraw(); //redraw the screen on spacebar
if (key == 's') {
record = true;
redraw(); //run again
}
}