Hi , I have the same requirement, I have to rotate an image of a wheel
as the user moves finger on the wheel on screen. Can u pls tell me how
I can use this code thr? What is cx, cy, mPreviousX, mPreviousY?

Thanks

On Mar 6, 2:56 am, Nathan <nathan.d.mel...@gmail.com> wrote:
> On Mar 5, 3:25 am, Bart <bvandep...@gmail.com> wrote:
>
> > Hi, I'd like to display a given String in acircle(so bend the string
> > so that the end of the string touches the beginning of the string).
> > And Then I'd like to let the user rotate thecircleby grabbing and
> > dragging it clockwise or counterclockwise.
> > Do you guys know what would be the best (simplest, smoothest) way to
> > do this? I already saw that using drawOnPath i can drawtextin a
> >circle. Do you have any tips on how to proceed with dragging and
> > rotating the textcircle?
>
> I've done this, and as mentioned, Canvas.translate and canvas.rotate
> are the way to go.
>
> If you are just using a hold and drag, you wouldn't have to worry so
> much about angular velocity. Code like this would work:
>
>         @Override
>         public boolean onTouchEvent(MotionEvent e) {
>         float x = e.getX();
>         float y = e.getY();
>         switch (e.getAction()) {
>         case MotionEvent.ACTION_MOVE:
>             //find an approximate angle between them.
>
>                 float dx = x-cx;
>             float dy = y-cy;
>             double a=Math.atan2(dy,dx);
>
>             float dpx= mPreviousX-cx;
>             float dpy= mPreviousY-cy;
>             double b=Math.atan2(dpy, dpx);
>
>             double diff  = a-b;
>             this.bearing -= Math.toDegrees(diff);
>             this.invalidate();
>         }
>         mPreviousX = x;
>         mPreviousY = y;
>         return true;
>         }
>
> Nathan

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to