0

I currently have two vector paths in a VectorDrawable and I am morphing one to another using AnimatedVectorDrawable:

First path:

M 1890.8582,2192.6484 L 505.06434,1392.5588 C 169.4833,2023.6601 168.2137,2777.0708 503.79469,3408.1721 L 1891.1961,2607.1555 C 1836.8977,2474.0145 1836.5598,2325.7894 1890.8582,2192.6484 Z

and my second path:

M 2300,200 L 200,200 C 200,1666.6667 200,3133.3333 200,4600 L 2300,4600 C 2300,3133.3333 2300,1666.6667 2300,200 Z

The catch is that the second path is dependent on the size of the screen, so some math has to go into those figures and I have to set them dynamically.

As it stands, it seems there doesn't seem to be a way to do that. So I have decided to use the Path class and draw it on a Canvas. The problem is that doesn't seem to be to be a way to morph paths when drawing with Path.

So my question is, is there some way to morph paths that have been set dynamically?

I have been looking at the accepted answer to this question and if all else fails, I'm going to take their suggestion and move the points of the path as the animation draws frame-by-frame on a Canvas.

Is there a better way to do this?

Community
  • 1
  • 1
skwear
  • 563
  • 1
  • 5
  • 24
  • see `PathParser#interpolatePathDataNode` method, this is the place where morphing is done – pskink Nov 25 '16 at 06:23
  • Interesting, I was not aware of the existence of this class. So is the idea to have `onDraw` loop over each iteration of the node? Although this is already plenty helpful, are there any examples of this in use? Thanks – skwear Nov 25 '16 at 06:47
  • how are you creating your `Path` object based on `"M 2300,200 L 2..."` string? – pskink Nov 25 '16 at 07:32
  • Oh. I'm sorry if that wasn't clear. I'm saying that I'm going to switch from using the svg path string to using the `Path` class, but there doesn't seem to be a way to morph paths in the `Path` class. – skwear Nov 25 '16 at 07:35

0 Answers0