Morpholux_EDM4611/Cours Data/Exploiter données csv/ecrire_fichier_texte_csv/ecrire_fichier_texte_csv.pde
PrintWriter output;
boolean record = false;

void setup() {
  size(400,400);
  // Create a new file in the sketch directory
  output = createWriter("positions.csv");
}

void draw() {
  if (record) {
    point(mouseX, mouseY);
    output.println(str(mouseX) + char(',') + str(mouseY)); // Write the coordinate to the file
  }
  record = false;
}

void keyPressed() {
  output.flush(); // Writes the remaining data to the file
  output.close(); // Finishes the file
  exit(); // Stops the program
}

void mouseDragged() {
  record = true;
}
