Llama a esta función en setup() para fijar la orientación del teléfono de modo horizontal o vertical y evite la rotación automática (lo que además reinicia el app:
                 
void setup() {
  orientation(LANDSCAPE);    
}
void draw() {
  background(255);
  line(0, 0, width, height);
  line(0, width, 0, height);  
}
                
                
void setup() {
  orientation(PORTRAIT);    
}
void draw() {
  background(255);
  line(0, 0, width, height);
  line(0, width, 0, height);  
}