Android Curve Fitting

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.