# Toggle rulers in sketch processing 3.53

**URL:** https://discourse.processing.org/t/toggle-rulers-in-sketch-processing-3-53/9474
**Category:** Beginners
**Created:** [March 20, 2019, 12:48pm UTC](https://discourse.processing.org/t/toggle-rulers-in-sketch-processing-3-53/9474 "2019-03-20T12:48:40Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [March 21, 2019, 4:39pm UTC](https://discourse.processing.org/t/toggle-rulers-in-sketch-processing-3-53/9474/5 "2019-03-21T16:39:55Z")

</div>

here is a simple ruler

Chrisir

```auto

String helpText=""; 

void setup() {
  size(600, 800);
  background(255);
}

void draw() {
  background(255);
  showRuler();
}

// ---------------------------------------------------------------

void showRuler() {

  int fullLengthLine=28; 

  // X-Ruler 
  stroke(0, 0, 255); // BLUE  
  fill(0, 0, 255); 
  line(0, 0, width, 0); 
  // if (false) 
  for (int x=0; x<=width; x+=50) {
    if (x%100==0) {
      // at 0, 100, 200, 300..... we show text and line
      if (x==width) {
        line(x-1, 0, x-1, fullLengthLine); 
        text(x, x-30, fullLengthLine+15);
      } else if (x==0) {
        line(1, 0, 1, fullLengthLine); 
        text(x, x+2, fullLengthLine+15);
      } else {
        line(x, 0, x, fullLengthLine); 
        text(x, x-11, fullLengthLine+15);
      }
    } else if (x%50==0) {
      // at 50, 150, 250.... we only show a shorter line
      line(x, 0, x, fullLengthLine/2);
    }
  }//for

  // ------------------------------------------------------

  // Y-Ruler 
  stroke(255, 0, 0); // RED 
  fill(255, 0, 0); 
  line(0, 0, 
    0, height); 
  for (int y=0; y<=height; y+=50) {
    if (y%100==0) {
      // at 0, 100, 200, 300..... we show text and line
      if (y==height) {
        line(0, height-1, fullLengthLine, height-1); 
        text(y, 
          30, height-7);
      } else if (y==0) {
        line(0, 1, fullLengthLine, 1);
        text(y, 30, 18);
      } else {
        // normal line and text  
        line(0, y, fullLengthLine, y); 
        text(y, fullLengthLine+3, y+4);
      }
    } else if (y%50==0) {
      // at 50, 150, 250.... we only show a shorter line 
      line(0, y, fullLengthLine/2, y);
    }
  }//for

  helpText="The screen is "
    +width
    +" wide and \n"
    +height 
    + " high.\nMouse is at "
    +mouseX+"(x), "
    +mouseY+"(y).";

  showHelpText();
}// func

// ------------------------------------------
// Minor Tools 

void showHelpText() {
  // Yellow box
  fill(#F6FA1C); // Yellow
  stroke(0); // Black
  rect(width-225, 63, 
    210, 62);

  // Black text
  fill(0); // Black
  textSize(12); 
  text(helpText, 
    width-220, 80);
  textSize(14);
}

```

---

_[View the full topic](https://discourse.processing.org/t/toggle-rulers-in-sketch-processing-3-53/9474)._
