Android page flip

Source: Internet
Author: User

In the past two days, I have studied the paging effect of the reading software. Among them, ireader has a good effect. The effect is as follows:

 

Now let's take a look at my own results:

Draw a red line in it to determine the drawing range.

    1. Mpath0.moveto (JX, JY );
    2. Mpath0.quadto (HX, Hy, kx, KY );
    3. Mpath0.lineto (ax, ay );
    4. Mpath0.lineto (BX, );
    5. Mpath0.quadto (ex, ey, CX, CY );
    6. Mpath0.lineto (FX, FY );
    7. Mpath0.close ();

The next step is to specify the vertices required to draw path0.

The conditions we know are: A Point Coordinate (touch point), F point coordinate (display interface size), and a straight line Eh is the vertical split line of AF.

The rest is a mathematical problem ~~

First, obtain the coordinates of the gpoint because G is the point of AF:

Apparently GX = (AX + FX)/2; Gy = (Ay + FY)/2;

Ecoordinate:

Add the subsidy line GM. The M coordinate is (GX, mheight );

According to the EGM and GMF of similar vertical triangles:

Em = GM * GM/MF;

In this way, the coordinates of the evertex are: (GX-Em, mheight)

Similarly, the coordinates of the H point can be obtained.

Coordinate C:

To simplify the calculation, we set the N point to the AG point. In this way, the triangle CJF and EHF are obtained:

Cx = ex-EF/2;

The coordinates of the cpoint are: (ex-EF/2, mheight)

Similarly, the J-point coordinate is obtained.

The following derivation requires a lot of mathematical knowledge. If you do not remember the shoes, you can consciously review them ~~

The function of a straight line is:

Y = AX + B;

Calculate the line by knowing two points: a = (y2-y1)/(x2-x1 );

B = (X2 * y1-y2 * X1)/(x2-x1 );

The coordinates of the intersection lines are: x = (b2-b1)/(a1-a2 );

Y = a1x + B1 or Y = a2x + b2

In summary, the intersection of the four points is:

X = (X4 * y3-y4 * X3)/(x4-x3)-(X2 * y1-y2 * X1)/(x2-x1 ))/

(Y2-y1)/(x2-x1)-(y4-y3)/(x4-x3 ))

= (X4 * y3-y4 * X3) (x2-x1)-(X2 * y1-y2 * X1) (x4-x3 ))/

(Y2-y1) (x4-x3)-(y4-y3) (x2-x1 ))

If the preceding four vertices A, E, C, and J are brought into the formula, B can be obtained. Similarly, K can be obtained.

D coordinate:

D is the midpoint of PE, so:

DX = (cx + bx)/2 + ex)/2

DY = (CY + by)/2 + ey)/2

Similarly, I points can be obtained.

 

OK. You can find the texture and shadow in all the points and areas to be drawn, and write the remaining values in another day.

Related Article

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.