Skip to content

Instantly share code, notes, and snippets.

@memish
Created November 28, 2018 13:59
Show Gist options
  • Save memish/dbdd371c408edbb5419ec536429ea90d to your computer and use it in GitHub Desktop.
Save memish/dbdd371c408edbb5419ec536429ea90d to your computer and use it in GitHub Desktop.
PrintWriter output;
void setup() {
// Create a new file in the sketch directory
output = createWriter("positions.txt");
}
void draw() {
point(mouseX, mouseY);
output.println(mouseX); // Write the coordinate to the file
}
void keyPressed() {
output.flush(); // Writes the remaining data to the file
output.close(); // Finishes the file
exit(); // Stops the program
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment