Why is my processing 2.x.x program not working with Processing 3.x.x?

edited November 2017 in Arduino

Hello All,

I have a program that was originally written for processing 2, and I'm trying to move it over to processing 3. None of the GUI will show up, though. I can change the background color of the window, but I can't make text or any tracings appear. I'm running Windows 10, but this is also the case on Mac OS. For the sake of experiment, I tried starting from scratch and adding element by element back in. I can't even make text show up in the new program. What am I missing here?

From Scratch Program:

PFont font;
void setup () {
  // set the window size
  surface.setSize(2000, 500);

  // set initial background to white
  background(255, 255, 255);
  textAlign(CENTER,TOP);  
  textSize(32);
  text("word", 10, 30); 
  fill(0, 102, 153);
}

Answers

  • Replace this surface.setSize(2000, 500);

    with size(1200,500);

    Fill must be before text

  • the code in the reference works:

    PFont myFont;
    
    void setup() {
      size(200, 200);
      myFont = createFont("Georgia", 32);
      textFont(myFont);
      textAlign(CENTER, CENTER);
      text("!@#$%", width/2, height/2);
    }
    

    also, back to your code, if you change the background to mid grey you can see your text flash up in white (and massively oversize).

    PFont font;
    void setup () {
      // set the window size
      surface.setSize(2000, 500);
    
      // set initial background to white
      background(128);
      textAlign(CENTER,TOP);  
      textSize(32);
      text("word", 10, 30); 
      fill(0, 102, 153);
    }
    

    change the surface.setSize()(????) to just size() and it'll stay but is white on white. your fill is after the text so it's not having any effect.

  • edited November 2017

    Thank you for the input. I got the text to display, but it broke again after I added "println(Serial.list());"

    PFont font; Serial myPort; void setup () { // set the window size size(2000, 500);

    fill(255,0,0); textAlign(CENTER);

      text("Marquette University",width*0.8,60);//
      text("Heart Rate (bpm): ",width/2,60); //Note: this will only display the last calculated heart rate
      text("Heart Rate Instant: ",width/6,60);
      text("Alarm: ",width/6,35); //Comment Out this line to get rid of alarm UI
      println(Serial.list());
    

    }

  • edit post, highlight code, press ctrl-o to format

Sign In or Register to comment.