Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Tweens and Tween Operations
Every tween operation is based on a collection of one or more values from which a range of output values can be algorithmically derived. Each tween is assigned a time duration, and an output value can be generated for any time value within the duration. In the simplest kind of tween operation, a pair of values is provided as input and values between the two values are generated as output.
For example, if the tween data is a pair of integers, 0 and 5, the duration of the tween operation is 100, and the algorithm used to generate output values is linear interpolation (in which generated values, when graphed, fall on a straight line between the input values), the output returned for a time value of 0 is 0, the output for 25 is 1.25, the output for 50 is 2.5, and the output for 100 is 5.
QuickTime supports a variety of tween types. Each tween type is distinguished from other types by these characteristics:
Input values or structures of a particular type.
A particular number of input values or structures (most often one or two).
Output values or structures of a particular type.
A particular algorithm used to derive the output values.
Tween operations for each tween type are performed by a tween component that is specific to that type or, for a number of tween types that are native to QuickTime, by QuickTime itself. Movies and applications that use tweens do not need to specify the tween component to use; QuickTime identifies a tween type by its tween type identifier and automatically routes its data to the correct tween component or to QuickTime. If you need to perform tween operations that QuickTime does not support, you can develop a new tween component, as described in Creating a Tween Component.
When a movie contains a tween track, the tween media handler invokes the necessary component (or built-in QuickTime code) for tween operations and delivers the results to another media handler. The receiving media handler can then use the values it receives to modify its playback. For example, the data in a tween track can be used to alter the volume of a sound track.
Tweens can also be used outside of movies by applications or other software that can use the values they generate.
Tween Types
Each of the tween types supported by QuickTime belongs to one of these categories:
Numeric tween types, which have pairs of numeric values, such as long integers, as input. For these types, linear interpolation is used to generate output values.
The polygon tween type, which takes three four-sided polygons as input. One polygon (such as the bounds for a sprite or track) is transformed, and the two others specify the start and end of the range of polygons into which the tween operation maps it. You can use the output (a
MatrixRecord
data structure) to map the source polygon into any intermediate polygon. The intermediate polygon is interpolated from the start and end polygons for each particular time in the tween duration.Path tween types have as input a QuickTime vector data stream for a path. (For information about QuickTime vectors, see Tween Components and Native Tween Types). Four of the path tween types also have as input a percentage of path’s length; for these types, either a point on the path or a
MatrixRecord
data structure is returned. Two other path tween types treat the path as a function: one returns they
value of the point on the path with a givenx
value, and the other returns thex
value of the point on the path with a giveny
value.The list tween type has as input a QT atom container that contains leaf atoms of a specified atom type. For this tween type, the duration of the tween operation is divided by the number of leaf atoms of the specified type. For time points within the first time division, the data for the first leaf atom is returned; for the second time division, the data for the second leaf atom is returned; and so on. The resulting tween operation proceeds in discrete steps (one step for each leaf atom), instead of the relatively continuous tweening produced by other tween types.
Single Tweens and Tween Sequences
A tween operation can include one or more tweens. A tween operation that includes just one tween is called a single tween. For a single tween, results for any time points in the tween duration are derived from that tween. A tween sequence contains more than one tween of the same type. To specify when each tween is used, you specify an ending percentage for each tween. For example, if you have a tween sequence containing three tweens and want to use the first tween for the first quarter of the tween duration, the second tween for the second quarter of the tween duration, and the third tween for the remainder of the tween duration, you set the end percentage for the first tween to .25, for the second to
.5, and for the third to 1.0. The first tween in the sequence always begins at the beginning, and each subsequent tween begins after the end percentage of the tween before it.
Interpolation Tweens
Interpolation tweens are tweens that modify other tweens. The output of an interpolation tween must be a time value, and the time values generated are used in place of the input time values of the tween being modified. For example, you can use a path tween whose data specifies a curve to modify a tween that uses linear interpolation for its algorithm. The starting and ending values for the modified tween remain the same, but the rate at which output values change over time is determined by the shape of the curve.
Once you create an interpolation tween, you can use it to modify any number of other tweens. You can do this by specifying maximum and/or minimum output values of the interpolation tween to match the time values for the tween to be modified. For example, if there is a curve whose shape describes the natural decay rate for several different sounds, you can can define a single interpolation tween for that curve and apply it, with appropriate maximum and minimum values, to all of the sounds.
An interpolation tween can modify another interpolation tween; the only requirement is that the output of each interpolation tween must be a time value. The ability to define series of interpolations makes it possible to create libraries of standard modifications that can be used together to generate more complex transformations.
Copyright © 2005, 2018 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2018-06-04