Ruler at windows

edited January 2014 in Using Processing

Hello together,

I just used Processing for a programming-introduction at school. Some students had problems in determining the correct coordinates of specific shapes. Is there an easy way to display rulers in the output-window? Or is such a feature planned? I saw something like this at the great new Hello Processing videos (http://hello.processing.org/).

Regards, Daniel

Answers

  • There is no functionality to achieve this from within the PDE at the moment, and there likely won't be without the help of a tool or a library or something. There may be, however, an external editor, such as that found in the Hello Processing videos, that is capable of this functionality. I do not know of any other.

    It is possible to add code to your sketches to provide the user / developer with feedback as to the coordinate location of shapes. While it would be entirely possible to draw a ruler, I would recommend, instead, the less obtrusive method of displaying the coordinates of the mouse pointer in the frame's title. Of course, this may not necessarily be sufficient for your purposes... but it (as far as I can tell) requires the least amount of code and has the least graphical impact on the resulting sketch, while still providing coordinate feedback.

    If you chose to go this route, you can tell your students to add the following code at the end of the draw() function:

    void draw() {
      //...
      frame.setTitle(mouseX + ", " + mouseY);
    }
    

    This will display the coordinates of the pointer in the frame title.

    Of course, if your students are still creating sketches in static mode (not using setup() and draw()), then you cannot implement this solution... and should instead look into drawing a ruler.

  • Thanks for your answer! I showed the students how to print the coordinates at the console (println(mouseX + ", " + mouseY)). Displaying it at the frame title is a bit more elegant. But as you said: At the beginning (where this would help) I started with static sketches and it would not work.

    Despite these possibilities, I would like to avoid to let them write things they don't understand, which is the case at frame.setTitle(). println() is a little bit better (no object), but the concatenation of (already not discussed) strings is still not optimal in my opinion.

    I am wondering, that I am (obvious) the first one who addresses this aspect. :)

  • This might help you determine the coordinates on screen. Nothing fancy it just prints coordinates following the mouse.

    void setup() {
      size(300, 300);
    }
    
    void draw() {
      background(0);
      coordinates();
    }
    
    void coordinates() {
      text(mouseX, mouseX - 30, mouseY - 10);
      text(mouseY, mouseX, mouseY - 10);
    }
    
  • edited January 2014

    "the concatenation of strings is still not optimal"
    Not sure what you mean by "not optimal" there...

    You have to provide a code that would draw the ruler on the sketch area. It isn't hard, but it has to be pasted on each project. Or to be provided as a library...

Sign In or Register to comment.