0

I have been looking around for hours on how to draw a shape and add a duration while it moves from point a to point b using canvas.

For example I have:

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.drawCircle(40,40,40,paint);

    canvas.rotate(90, 50, 700);
}

This draws the circle and it rotates 90 degrees, moving to x,y location. The problem is it goes straight to the location. I would like mine to have a duration so the user sees it move from point A to point B on x or y axis.

Example:

The square will start at x_position:0 and u_position: 0. Then over 5 seconds it will move to location x_position:50 and y_position:50.

Is there a better way to accomplish this? I am assuming there is a much better way to accomplish this.

I have tried the following:

  1. http://www.compiletimeerror.com/2013/09/introduction-to-2d-drawing-in-android.html#.VtlEM_krKUk

  2. Rotating Image on A canvas in android

  3. How to draw a circle with animation in android with circle size based on a value

This one I believe is doing parts right however I could not implement this:

  1. How to make 2D graphic transition in android canvas
halfer
  • 19,824
  • 17
  • 99
  • 186
L1ghtk3ira
  • 3,021
  • 6
  • 31
  • 70

0 Answers0