|
||
| Inside Technique : Animation Toolkit : Creating Custom Paths The sinus path object is based on the sinus wave. A sinus wave follows a path similar to the following (we are avoiding the mathematical lesson :-)
Path ObjectsThe sinus path is a Javascript object that extends the base path object and exposes the core properties and methods. First we create a basic template of the object that we will add functions to later.
This represents the minimal implementation necessary to create a custom path. You need to write the int_step() and int_reset() functions that move the element to the next x and y position. Most path objects will require additional initialization parameters to set the starting x and y coordinate as well as any additional settings. InitializationFirst we start with a very brief lesson on sinus waves. This lesson
identifies the arguments necessary to create the SinusWave constructor object.
The sinus function returns values in the interval [1,-1]. This value is multiplied by the amplitude. The period value represents how many waves you want in the SinusPath. The phase shift property allows the wave to start at a different point other than (0,0) (actually a different angle than 0). We define the constructor to enable setting all of these parameters. This allows you to create a new SinusWave object as follows: var p1 = new SinusPath(inLength, inAmplitude, inPeriod, inPhase, steps) Calling In the constructor, the public step() and reset() methods are defined by the functions int_step() and int_reset(). Next we show you how these methods are written and used to position the element. Page 1:Animation Toolkit © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |