The Tear Transition creates the illusion of the current billboard getting torn off the applet like a piece of It gets ripped upwards and toward the left to reveal the next billboard image underneath, There is only one member variable used in this transition, x_cross. It is used as a multiplier to create the tear effect. The larger the value of this variable, the smaller the ‘ tear effec. will appear to be.
The code for this transition has many optimizations. One optimization of significance is to create the cell frames in reverse order, building the last cell frame first and the first, last. In their normal order, each subsequent cell frame reveals a little bit more of the new image underneath-If the frames were to be created in the normal order, the tear effect would have to be drawn; along with the new image pixels revealed in the current frame, which had been covered by the tearing effect in the previous frame. Doing it in reverse only requires redrawing tile tearing effect each cell frame, For example the last frame, created first, starts out with the tearing effect using only a small portion of the upper-left corner of the image, while the rest of the pixels are taken from the new billboard image. In the second to the last frame, which is ,created second, the new tear effect draws over a little bit more of the upper-left corner of the image, while the rest of the image remains the same. The cell frames that follow draw the new tear effect over more and more of the image, but always covering lip the old tear effect from the last frame.
The init() method for this transition starts like all other transitions, with a call to the base class’ init( ) method. It then copies all of the new billboard’s pixels into the work_pixels array and copies the first line of the old billboard’s pixels onto the first line of the work_pixels array. After the x_cross variable is initialized, the init( ) method ,loops through each cell frame in reverse order. Inside the loop, it creates each cell frame and decreases the value of the x_cross variable.