The previous article on The Imitation 58 Loadingview of the same city, there is a Bezier curve to draw a circle, the Bezier curve theory is very complex, I would like to talk about what is known and can be used.
For example, in the previous Loadingview project, to use Path.cubic () to draw a circle with a Bezier curve, the first thing to know is
Definition of the Path.cubic () method:
void cubicTo(float x1,float y1,float x2,float y2,float x3,floatfrom the last point,approaching control points(x1,y1)and(x2,y2),and ending at (x3,y3)
What do you mean, from our last point of departure to close (X1,y1) (X2,y2) The direction of the two points to go to the end at (x3,y3) point.
What do you mean close? For example, y = 1/x^3 the trajectory of this function when x approaches 0 o'clock, the trajectory infinitely approaching the y-axis value tends to infinity.
Such a trajectory is presented when the curve progresses from 0 to a point approaching 1 points and ends at 4 o'clock.
So when you want to draw a circle with a three-time equation Bezier curve, the method in the project is to draw 4 1/4 circles, and it takes 1/4 points to draw the four circle with three times a time.
In this picture (0,0) is our starting point (the first) is the end of the two points are on the circle can know the coordinates, so to calculate (x1,0) (1,y1) The coordinates of the two points.
这就是magicNumber的由来。
We connect the center of the Circle with (x1,0) (0,0) and the angle of the two lines is 20°, which calculates the coordinates of the X1. Similarly y1, this coordinate value is magicnumber.
You can draw a circle by counting the coordinates of four points.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Three times the Bezier curve to draw the circle method.