Learn a little flash (52) Paging Component Algorithm every day (2)

Source: Internet
Author: User
  • The ebook is divided into three layers, which are stacked in order. The first layer is the current page layer, which is the page currently being displayed; the second layer is the page angle that is rolled up when you drag the mouse, and the third layer is the layer that exposes the next page when the page angle is rolled up.
  • Set mask: When the page is rolled up, Layer 1 only displays the part inside the Quadrilateral fbde, Layer 2 only displays the ABCD part, and Layer 3 only displays the bghd part.
  • Rotation: Content in Layer 2 changes the tilt angle continuously as the mouse moves, and the angle is always the same as that of the AC side.
  • Page flip: When the page is completely turned over, the current page number of Layer 1 = Current page number + 1

 

Program CoreIt is how to obtain the coordinates of the four ABCD points. I am using the vertical bisector method, that is, point C is the mouse position, and point h is the page Angle Position, BD is the vertical split line between the two points. After finding the tangent function y = kx + B of a straight line BD from the known C and H coordinates, find the tangent points between it and Fg and eh, and obtain the coordinates B and D, point A is the symmetric point of point G in a straight line BD. By finding the symmetric point of point G to BD, we can obtain the coordinate of point.

This is from the Internet.

After an afternoon's understanding, I wrote a corner algorithm. Only the coordinates of the four points are obtained here. X1 and Y1 are the coordinates in the lower right corner, X4, and Y4 are the vertices in the upper right corner.

Coordinate, k is the slope, T is the slope of the vertical bisector, the other is the same, where the result is calculated, especially the location of the two intersections, B and D, there is also a method to obtain symmetric points, which requires a lot of knowledge about plane ry.

 

VaR X1: Number = 912;
VaR Y1: Number = 684;

VaR X4: Number = 912;
VaR Y4: Number = 84;

Onenterframe = Init;

Function Init (): void {
Clear ();
VaR X: Number = _ root. _ xmouse;
Var y: Number = _ root. _ ymouse;
VaR K: Number = (Y-y1)/(X-x1 );
VaR T: Number =-1/K;
VaR x0: Number = (x + X1)/2;
VaR y0: Number = (Y + Y1)/2;
VaR bposx: Number = (T * x0-y0)/T;
VaR bposy: Number = Y4;
VaR dposx: Number = (Y1 + T * x0-y0)/T;
VaR dposy: Number = Y1;

VaR aposy: Number = (-K * X4 + 2 * K * x0 + 2 * K * y0-k * K * Y4 + y4-k * X4) /(1 + K * k );
VaR aposx: Number = (AposY-y4 + X4 * k)/K;

VaR xposa: Number = x1;
VaR yposa: Number = xposa * t-t * x0 + y0;

Linestyle (2, 0xff00ff, 100 );
If (yposa> 84 ){
MoveTo (x, y );
Lineto (dposx, dposy );
Lineto (xposa, yposa );
Lineto (x, y );
} Else {
MoveTo (x, y );
Lineto (dposx, dposy );
Lineto (bposx, bposy );
Lineto (aposx, aposy );
Lineto (x, y );
}
}

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.