Reproducing A Clever Animation Product, Part 9

Yesterday’s attempt wasn’t too bad; I needed to fix the declaration and use of the object that holds the transform information (yesterday’s form only works if you initialize the internal member values with literals) and I needed to tweak a couple of indexes. The corrected code is shown below, along with an extra function for displaying the information.

Here is how I loaded up the array. It includes a series of three transformations for the left location of the first object, but out of order. It then displays the information before sorting, does the sort, and displays the information again after the sort.

Here’s the output before the sort:

TransformList
Element: handle001
Type: left
start: 301 end: 25 begin: 0 duration: 0.75 method: linear
start: 301 end: 25 begin: 4 duration: 0.5 method: linear
start: 25 end: 301 begin: 2 duration: 1 method: linear
Type: opacity
start: 0 end: 1 begin: 0 duration: 0.75 method: linear
Element: handle002
Type: top
start: -25 end: 125 begin: 0.5 duration: 0.75 method: linear
Type: opacity
start: 0 end: 1 begin: 0.5 duration: 0.75 method: linear

…and here it is after the sort:

TransformList
Element: handle001
Type: left
start: 301 end: 25 begin: 0 duration: 0.75 method: linear
start: 25 end: 301 begin: 2 duration: 1 method: linear
start: 301 end: 25 begin: 4 duration: 0.5 method: linear
Type: opacity
start: 0 end: 1 begin: 0 duration: 0.75 method: linear
Element: handle002
Type: top
start: -25 end: 125 begin: 0.5 duration: 0.75 method: linear
Type: opacity
start: 0 end: 1 begin: 0.5 duration: 0.75 method: linear

Now that this is done I can modify the tween definition functions to write out the full and correct state of every element for every animation step.

Also, it can be argued that it’s unnecessary to specify the beginning and ending state of each transform. The properties to be transformed are already initialized, so in theory the transform functions would only have to specify what the new value should be. That would obviate the need to correctly specify the initial value of a property as being the same as the final value from then end of a previous transformation. I note that the Greensock product does this, including not just a “to” transform but also a “from” transform. If you initialize all the elements where you want them to end up you can get an idea of the final layout, and then the animation sequence can start from where you specify and end up where they were initialized. That said, one thing at a time…

This entry was posted in Tools and methods and tagged , , . Bookmark the permalink.

Leave a Reply