How do I draw a curve through tree points in Android?

北战南征 提交于 2019-12-04 19:23:14


I need to connect three points by a smooth curve. I've looked at the same questions already answered on StackOverflow but they all suggest using Path.quadTo(). I do not understand why this is considered a correct answer as Bezier curve is only approaching middle (control) point but not going through it. In my case I have to go exactly through it. So how can I achieve that?


True, what you need is Catmull Rom splines which are guaranted to go through each point. However, I don't know any function in the Android API to draw them. You could also "trick" the quadTo function and pass it a virtual middle point that you compute according to the current point and the next one.


What about the cubicTo (or rCubicTo if you need it from a relative point) function?, float, float, float, float, float)


Here is a very nice, illustrated howto for javascript, but all the used methods are usual and there is an analogue in Androids Path Class