The Interpolation class represents a interpolation between given control points.
Control points work on a normalized range from
0 to
1.
Depending on the given IMapping an Interpolation object
can store different types of values.
mode:uint
[read-write]Implementation
public function get mode():uint
public function set mode(value:uint):void
protected var numPoints:uint
The number of control points.
protected var points:Array
An array of control points.
The control points are always sorted on their x value.
public function Interpolation(mapping:IMapping = null)
Creates a new Interpolation object.
Parameters
| mapping:IMapping (default = null ) — The IMapping object used to map the normalized value.
|
public function addChangedCallbacks(callback:Function):void
Parameters
public function addControlPoint(point:ControlPoint):void
Adds a control point.
Parameters
public function bake(resolution:uint = 0xff):void
Bakes the current interpolation.
This way your interpolation will act much faster but changes to the
interpolation by adding points or chainging their position will not
affect the output unless you call bake() again or set the mode
back to InterpolationMode.RUNTIME.
Do not forget to set the mode
of the interpolation to InterpolationMode.BAKED
or InterpolationMode.BAKED_LINEAR in order to use the baked values.
Parameters
| resolution:uint (default = 0xff ) — The resolution of the baked interpolation. The higher the resolution the more accurate results you will get.
|
protected function clamp(value:Number):Number
Clamps a value so that 0 <= value <= 1
is true.
Parameters
| value:Number — The value to clamp.
|
Returns
| Number — The value in the range of 0..1 .
|
protected function findPointBefore(x:Number):uint
Searches for a point that is prior to x.
Parameters
| x:Number — The position on the x-axis to search for.
|
Returns
| uint — The index of the point that has been found.
|
public function getInterpolationAt(x:Number):Number
Parameters
Returns
public function getValueAt(x:Number):*
Retrievs the interpolated value at position x and returns the mapped value.
If no control points are added a default value of 0 is used as the interpolated value.
Parameters
| x:Number — A normalized value from 0 to 1.
|
Returns
| * — The mapped value at interpolated position x.
|
protected function interpolate(x:Number):Number
Calculates the interpolated value y for x based on the control points.
This function has to be overriden.
Parameters
| x:Number — Normalized position on the x-axis.
|
Returns
| Number — The y value at given position x.
|
public function removeChangedCallbacks(callback:Function):void
Parameters
public function removeControlPoint(point:ControlPoint):void
Removes a control point by reference.
This is not done by a value check.
Parameters
public function toString():String
Creates the string representation of the current object.
Returns
| String — The string representation of the current object.
|