Skip to content

Instantly share code, notes, and snippets.

@REAS
Last active October 12, 2018 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save REAS/32ec9ad511dbbce67de75204c997c7fc to your computer and use it in GitHub Desktop.
Save REAS/32ec9ad511dbbce67de75204c997c7fc to your computer and use it in GitHub Desktop.
Create a PDF file and draw to the screen
import processing.pdf.*; // Import PDF code
void setup() {
size(600, 600);
noLoop(); // Run the draw() only once
}
void draw() {
beginRecord(PDF, "line.pdf"); // Start writing to PDF
// START PATTERN
background(255);
strokeWeight(10);
for (int y = 100; y < height; y += 100) {
line(200, y, 400, y); // Draw lines to screen and to PDF
}
// STOP PATTERN
endRecord(); // Stop writing to PDF
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment