GI Centre Zoom

edited April 2015 in Library Questions

Hi,

I'm using the GI Centre for zooming and panning and it's working really well, but I would like to know how to set the 'x axis' in a fixed vertical position. In other words, when I zoom and pan I would like the line to remain in the 'height/2' position of the display, but use the true zoom and pan values for the x position. I hope that's clear.

Here's my code:

        import org.gicentre.utils.move.*;

        ZoomPan zoomer;

        void setup(){
          size(600,300);
          zoomer = new ZoomPan(this);
        }

        void draw(){
          background(255); 
          zoomer.transform(); 
          stroke(50);

          line(100,height/2,500,height/2);

          ellipse(100,100, 50, 50);
        }

Answers

  • Answer ✓

    After a little more research I found an answer :-):

    void draw(){
      background(255); 
      zoomer.transform(); 
      stroke(50);
      PVector h2 = zoomer.getDispToCoord(new PVector(0, height/2));
      line(100,h2.y,500,h2.y);
    
      ellipse(100,100, 50, 50);
    }
    
Sign In or Register to comment.