Project

General

Profile

« Previous | Next » 

Revision 951c4af9

Added by Leszek Koltunski over 7 years ago

Around the World: moving the selection rectangle

View differences:

src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldSurfaceViewPicker.java
64 64
      int x = (int)event.getX();
65 65
      int y = (int)event.getY();
66 66

  
67
      android.util.Log.e("Picker", "touched at x="+x+" y="+y);
67
      int h = mRenderer.getHeight();
68
      int w = mRenderer.getWidth();
69

  
70
      float xf = (x-w/2)*3.0f/h;
71
      float yf =-(y-h/2)*3.0f/h;
72

  
73
      if( yf>-1.5f && yf<1.5f )
74
        {
75
        if( yf>=0 && yf> 1-0.577f*xf )
76
          {
77
          float d = 0.577f*xf + yf;
78
          yf /= d;
79
          xf /= d;
80
          }
81
        else if( yf<=0 && yf< 0.577f*xf-1 )
82
          {
83
          float d = 0.577f*xf - yf;
84
          yf /= d;
85
          xf /= d;
86
          }
87
        else if( xf< -0.865f )
88
          {
89
          yf *= (-0.865f/xf);
90
          xf  =  -0.865f;
91
          }
92

  
93
        mRenderer.move(xf,yf);
94
        }
68 95

  
69 96
      return true;
70 97
      }

Also available in: Unified diff