Android curve fitting and android Curve Fitting
I have been studying a problem recently. There are a series of points that need to be merged into a beautiful curve and drawn out. The research results are as follows. Thank you!
// Obtain the curve Path of a series of points. private Path getPointCurvePath (List <Point> points) {Point startp; Point endp; Point p3 = new Point (); point p4 = new Point (); Path path = new Path (); if (null = points | 0 = points. size () {return path;} startp = points. get (0); path. moveTo (startp. x, startp. y); int xCenter, yCenter; for (int I = 0; I <points. size ()-1; I ++) {startp = points. get (I); endp = points. get (I + 1); xCenter = (int) (startp. getX () + endp. getX ()/2; yCenter = (int) (startp. getY () + endp. getY ()/2; p3.y = startp. y; p3.x = xCenter; p4.y = endp. y; p4.x = xCenter; // determine the path of the curve. cubicTo (p3.x, p3.y, p4.x, p4.y, endp. x, endp. y); // path. quadTo (xCenter, yCenter, endp. x, endp. y);} return path ;}
The effect is as follows: