displayWidth,displayHeight app position

edited November 2013 in Questions about Code

It 's correct in your screen? thanks

PFont work;
void setup() {
  size (displayWidth, displayHeight);
  orientation (LANDSCAPE);

  work = loadFont ("ArialMT-48.vlw");
}
void draw() {
  background (0, 255);
  textFont (work, width/30);
  fill (255, 0, 0); 

  float x = (width*1000 )/( mouseX+1);
  x = x/1000;
  float y = (height*1000 )/( mouseY+1);
  y = y/1000;

  String xx  = nf (x, 1, 3);
  String yy  = nf (y, 1, 3);

  text ("W /", mouseX/1.13, mouseY/1.13 + height/20);
  text (xx, mouseX/1.13 + width/20, mouseY/1.13 + height/20);
  text ("H /", mouseX/1.13, mouseY/1.13 + height/10);
  text (yy, mouseX/1.13 + width/20, mouseY/1.13 + height/10);
}

Answers

  • upgrade:

    PFont work;
    void setup() {
      size (displayWidth, displayHeight);
      orientation (LANDSCAPE);
    
      work = createFont ("Arial",32);
    }
    void draw() {
    
      pushMatrix();
      background (0, 255);
      textFont (work, width/30);
      fill (255, 0, 0); 
    
      float x = (width*1000 )/( mouseX+1);
      x = x/1000;
      float y = (height*1000 )/( mouseY+1);
      y = y/1000;
    
      String xx  = nf (x, 1, 3);
      String yy  = nf (y, 1, 3);
    
      text ("W /", mouseX/1.13, mouseY/1.13 + height/20);
      text (xx, mouseX/1.13 + width/20, mouseY/1.13 + height/20);
      text ("H /", mouseX/1.13, mouseY/1.13 + height/10);
      text (yy, mouseX/1.13 + width/20, mouseY/1.13 + height/10);
      popMatrix();
    }
    
Sign In or Register to comment.