Not displaying graphics on screen when using beginRecord()

Hello!

I hope, you can help me with a little problem: I want to draw something on the screen as well as drawing this into a PDF file. The PDF file is written correctly, but there is no output on the screen.

Do you have an idea, why it does not work?

Thanks a lot!

Cheers, Sebastian

import processing.pdf.*;

void setup() {
  size(400, 400);
  noLoop();
}

void draw() {
  selectInput("Select a listener file:", "fileSelected");
}


void fileSelected(File selection) {
  if (selection == null) {
    println("Window was closed or the user hit cancel.");
  } else {
    println("User selected " + selection.getAbsolutePath());
    drawGraphic(selection.getAbsolutePath());
  }
}


void drawGraphic(String inputString) {

  // DRAWING
  beginRecord(PDF, "filename.pdf");

  background(127);
  text(inputString, 10, 10);

  endRecord();
}

Answers

  • edited November 2016

    Much probably b/c you're calling function drawGraphic() from the Thread created by selectInput(). :-@

    We should never modify sketch's canvas outside the "Animation" Thread! L-)

Sign In or Register to comment.