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.
- Mpath0.moveto (JX, JY );
- Mpath0.quadto (HX, Hy, kx, KY );
- Mpath0.lineto (ax, ay );
- Mpath0.lineto (BX, );
- Mpath0.quadto (ex, ey, CX, CY );
- Mpath0.lineto (FX, FY );
- 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.