Last active
October 12, 2018 23:41
-
-
Save REAS/2cee7383c3dae72253cc583067e6ecad to your computer and use it in GitHub Desktop.
Create a PDF file with mouse press
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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