Two page-flipping effects in Android platform.
The first page turn effect is as follows:
Implementation principle:
The current finger touch point is a, the a point coordinate is (ax,ay), the triangle ACB and the triangular CMB are symmetric triangles and the line CP is AM perpendicular bisector, then the b point coordinates (AX/2,AY/2).
As GF perpendicular to OM and CB perpendicular to AM, triangular cfg and GFM similar, then CF:GF = GF:MF cf= (GF * GF)/MF GF Length of G-point ordinate MF length is g-point horizontal axis
CF length can be obtained by C-point coordinates can be determined by the C-point, G-Point can determine the line between two points, when the line is x=0 to find the intersection with the Y-foot.
The second page turn effect is as follows:
Implementation principle:
Use Bezier curves. The curve has four points: the starting point, the terminating point (also known as the anchor Point), and the two mutually separated intermediate points. Sliding two intermediate points, the shape of the Bezier curve changes.
According to the first page turn effect principle can be determined a, E, H, F, g, by eh parallel to CJ and AF perpendicular to eh, then af perpendicular to CJ triangular EGF similar to triangular cnf is EF:CF = gf:nf.
Set N as the midpoint of the AG has cf= (3/2) *ef, then the c point coordinates can be found by the C point, the K-point coordinates known over two points between the line
By the line can be calculated with the y-axis intersection point J by a, E, C, J can calculate the intersection of two lines of point B the same can be obtained points K.
Specific implementation steps in Android:
Start Page Show
1. Create a BMP for screen size
2. Convert the picture to canvas
3. Get the Start Page data
4. Drawing the Start page data in the canvas
5. OnDraw a BMP object in the current view by copying it
Page Turn processing
1. Create two BMP (BMP1, BMP2) at initialization and convert it to canvas (CANVAS1, CANVAS2)
2. Get the area of the first touch of the gesture (example: X<50&&Y<50 is the upper left corner when the first click of the screen is placed)
3. Determine the data to be displayed according to the first-click Area (Example: the first click in the left-hand area "upper left, bottom left" to determine the action for the next page action)
4. Get the data from the next page and draw it out in Canvas2
5. Call the start animation based on the region position obtained in 1 to move the view to the first click position of the gesture
6. Get the coordinates of each move of the gesture and calculate the coordinates of each point plotted according to the moving coordinates
7. Refresh the view each time you move
More knowledge of Android development , you can log in to mentor Network learning.
?
Flip-page effects in Android platform