Achieve the effect of turning books to pages in Android-end

Source: Internet
Author: User

Non original conversion from: http://blog.csdn.net/hmg25/article/details/6342539

Previously, due to various trivial matters, I paused the implementation of the page flip effect and finally completed most of the functions this weekend. However, here I just gave a basic prototype and didn't add the page flip animation effect, since the next weekend, we need to turn to the framework layer (the end of the short soy sauce period) O alas, and page flip development will be suspended, therefore, to further improve the functionality of shoes, you need to do it yourself ~~~ I will release the final code provided by myself later.

Today, xiaofanqingzjj, an enthusiastic csdn friend, told me: "in the past two days, your code has been fully adjusted, so that you can automatically roll back the Page Based on the sliding speed or position, or an animation that is automatically flipped to the next page, wait until it is finished and then released. "Haha, I feel his enthusiasm, I also hope that you can make any improvements in the future so that you can learn them together.

Let's talk about the improvements in the code at the last moment. Let's look at the results:



<Ignore_js_op style = "word-wrap: Break-word;">

<Ignore_js_op style = "word-wrap: Break-word;">

 



As you can see from the figure, the first is to fix the problem of turning the page shadow vertex to locate the exception, and then add the display on the back of the page as well as the light and shade effect, and fix it, when the page turns to the vertical direction, the light and shadow effect will drift.

I have uploaded the source code for the paging effect after the article. I will not talk about it in detail here. If I have time later, I will introduce the principle of the code for the light and shade effect and write another blog. The following is an overview to help you study the code.

First, we will analyze the problem of shadow vertex locating. First, we will look at a special situation:



<Ignore_js_op style = "word-wrap: Break-word;">

 


Assume that the straight line at is in the vertical position, and the shadow width on both sides is the same. If it is 25 PX, it is easy to set at to 25 * √ 2 = 25*1.414. In this special case, the vertex is:

A. X = T. X;

A. Y = T. y-25 * 1.414


Now let's look at the general situation:



<Ignore_js_op style = "word-wrap: Break-word;">

 


At is still 25*1.414, if you want to locate the coordinate of point A, you need to find the length of AB and Bt (AB perpendicular to BT). Through analysis, you can know the angle bat, the pin DTE is equal to the 45-degree angle, and the pin DTE can be obtained through the coordinates of the touch point and mbeziercontrol1:


Math. atan2 (mbeziercontrol1.y-mtouch. Y, mtouch. X-mbeziercontrol1.x );



The coordinates of the Shadow vertex can be obtained through the above calculation.


The back of the flip page is divided into two parts for solving, the first part is to flip the source image to get:



<Ignore_js_op style = "word-wrap: Break-word;">

 


The above results are achieved by creating a matrix mmatrix and float [] mmatrixarray.



Mmatrix. setvalues (mmatrixarray );

Mmatrix. pretranslate (-mbeziercontrol1.x,-mbeziercontrol1.y );

Mmatrix. posttranslate (mbeziercontrol1.x, mbeziercontrol1.y );



After the flip, colormatrixfilter must be used to achieve the effect of the light and shade after the flip to achieve the following effect. If you are not familiar with the two, find the materials to study them ~~~ Second (second ^ second) Second


<Ignore_js_op style = "word-wrap: Break-word;">

 


Well, this is probably the content. You can study the code yourself ~~ Below is a program to facilitate the study of the various points:



<Ignore_js_op style = "word-wrap: Break-word;">

 




Implementation of book paging in Android-principles
Http://www.eoeandroid.com/forum... & fromuid = 749688
Implementation of book paging in Android ---- source code
Http://www.eoeandroid.com/forum... & fromuid = 749688
Implementation of book paging in Android ---- conclusion
Http://www.eoeandroid.com/forum... & fromuid = 749688

Implementation of book paging in Android ---- upgrade
Http://www.eoeandroid.com/forum... & fromuid = 749688


<Ignore_js_op style = "word-wrap: Break-word;">

Turntest.rar

 

739.57 kb, download times: 51, download points: ecoins-2 yuan

 

I have not tested whether this code can be used.

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.