-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Description
With pixelDensity(2) enabled, PDF exports using offscreen buffers like beginRecord() and createGraphics(PDF) need to be scaled by 0.5 (1 / float(pixelDensity)) to have the expected result.
Steps to Reproduce
import processing.pdf.*;
void settings()
{
pixelDensity(2);
size(500, 500);
}
void setup()
{
beginRecord(PDF, "test.pdf");
//scale(1 / float(pixelDensity)); // uncomment to get expected pdf output
background(0, 255, 0);
rect(0, 0, width, height, 100, 100, 100, 100);
endRecord();
}
void draw() {}
void exportUsingPGraphics()
{
PGraphics pdf = createGraphics(width, height, PDF, "test_usingpgraphics.pdf");
pdf.beginDraw();
pdf.background(0, 0, 255);
//pdf.scale(1 / float(pixelDensity)); // uncomment to get expected pdf output
pdf.fill(255, 0, 0);
pdf.rect(0, 0, width, height, 100, 100, 100, 100);
pdf.dispose();
pdf.endDraw();
}
void keyReleased()
{
exportUsingPGraphics();
}
Your Environment
- Processing version: 3.5.4
- Operating System and OS version: macOS Mojave 11.4 (20F71)
Metadata
Metadata
Assignees
Labels
No labels