Skip to content

Instantly share code, notes, and snippets.

@REAS
Last active Oct 12, 2018
Embed
What would you like to do?
Create a PDF file with mouse press
import processing.pdf.*; // Import PDF code
boolean recordPDF = false;
int count = 0;
void setup() {
size(600, 600);
}
void draw() {
if (recordPDF) {
beginRecord(PDF, "line" + nf(count, 4) + ".pdf"); // Start writing to PDF
}
// START PATTERN
background(255);
strokeWeight(10);
for (int y = 100; y < height; y += 100) {
line(mouseX, y, mouseX+200, y); // Draw lines to screen and to PDF
}
// STOP PATTERN
if (recordPDF) {
endRecord(); // Stop writing to PDF
recordPDF = false;
count = count + 1;
}
}
void mousePressed() {
recordPDF = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment