Implement book paging in Android-light and shadow in extra articles

Source: Internet
Author: User

By he minggui (http://blog.csdn.net/hmg25) reprint please indicate the source

For the source code of the previously released paging effect, due to the rush in writing, there are not many annotations, and my text is poor, so many people are not very clear about many of them, in particular, I don't know how to explain the light and shade, which makes me feel ashamed. So I will analyze it in my spare time today.

PS: Due to the limited time, the text is also fragmented. Sorry ~

First, we will analyze the shadow of the intersection of the page and the next page, that is (marked in red circles ):

It is obtained by selecting canvas. Rotate and canvas. clippath,

 

View plaincopy to clipboardprint?
  1. Canvas. clippath (mpath0 );
  2. Canvas. clippath (mpath1, Region. Op. Intersect );
  3. Canvas. Rotate (mdegrees, mbezierstart1.x, mbezierstart1.y );

 

 

Variable annotation diagram:

Now let's restore the image before we perform the preceding operations. Get:

Select mpath0 in blue and mpath1 in green. Run canvas. clippath (mpath0); canvas. clippath (mpath1, Region. Op. Intersect); that is, it is drawn only in the area where mpath0 and mpath1 intersect. The area where the blue border and the Green Border intersect.

Let's take a look at it before returning to canvas. rotate.

The position of the shadow before rotation is outside the image. Under the image, the mdegrees in the image is about-128 °, so the canvas is executed. rotate (mdegrees, mbezierstart1.x, mbezierstart1.y); that is, after the canvas is rotated-128 ° counterclockwise, the skewed shadows in the graph can be obtained.

In the figure, the shadow width is mtouchtocornerdis/4, and mtouchtocornerdis is the straight line distance between the touch point and its turning angle. This can be achieved. If touch is farther away from turning the angle, the width of the Shadow increases. The shadow length is mmaxlength, which is the diagonal line of the screen, because I assume that the shadow reaches the maximum when it approaches the diagonal line of the screen, that is, if my screen is 480*800, then mmaxlength = math. hypot (1, 480,800 );

Haha, you should understand it here. The other shadow effects below are similar. You can think about it yourself. Also, because the shadow position is related to mbezierstart1.x and mbezierstart1.y, some bugs may occur when mbezierstart1.x is less than 0, so in calcpoints, (mbezierstart1.x <0 | mbezierstart1.x> 480. If you try to block the IF (mbezierstart1.x <0 | mbezierstart1.x> 480) in calcpoints (), the following situations may occur.

Yes, half of the shadows on the intersection page cannot be displayed, because mbezierstart1.x is a negative number. We previously assumed that the maximum shadow length is based on the minimum value of mbezierstart1.x 0, when mbezierstart1.x is a negative number and is smaller than a certain degree, the shadow length cannot be completely drawn. If you need to implement the paging angle, you need to recalculate the starting coordinate of the shadow.

O (partition _ partition) o ha! Well, let's talk about it. If you don't understand anything or have errors in the code, please point it out !!

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.