On Mar 5, 3:25 am, Bart <[email protected]> wrote:
> Hi, I'd like to display a given String in a circle (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 the circle by 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 draw text in 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en