Recently in the study of a problem, there are a series of points, it is necessary to synthesize a beautiful curve, drawn out, the results are as follows, thank netizens!
Gets 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);p Ath.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.get Y () + endp.gety ())/2;p3.y = startp.y;p3.x = Xcenter;p4.y = endp.y;p4.x = xcenter;//Determine the path of the curve Path.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:
Android Curve Fitting