Packagede.popforge.interpolation
Classpublic class Interpolation
SubclassesInterpolationCosine, InterpolationCubic, InterpolationLinear

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.



Public Properties
 PropertyDefined by
  mode : uint
Interpolation
Protected Properties
 PropertyDefined by
  numPoints : uint
The number of control points.
Interpolation
  points : Array
An array of control points.
Interpolation
Public Methods
 MethodDefined by
  
Interpolation(mapping:IMapping = null)
Creates a new Interpolation object.
Interpolation
  
addChangedCallbacks(callback:Function):void
Interpolation
  
Adds a control point.
Interpolation
  
bake(resolution:uint = 0xff):void
Bakes the current interpolation.
Interpolation
  
getInterpolationAt(x:Number):Number
Interpolation
  
getValueAt(x:Number):*
Retrievs the interpolated value at position x and returns the mapped value.
Interpolation
  
removeChangedCallbacks(callback:Function):void
Interpolation
  
Removes a control point by reference.
Interpolation
  
toString():String
Creates the string representation of the current object.
Interpolation
Protected Methods
 MethodDefined by
  
clamp(value:Number):Number
Clamps a value so that 0 <= value <= 1 is true.
Interpolation
  
findPointBefore(x:Number):uint
Searches for a point that is prior to x.
Interpolation
  
interpolate(x:Number):Number
Calculates the interpolated value y for x based on the control points.
Interpolation
Property detail
modeproperty
mode:uint  [read-write]Implementation
    public function get mode():uint
    public function set mode(value:uint):void
numPointsproperty 
protected var numPoints:uint

The number of control points.

pointsproperty 
protected var points:Array

An array of control points. The control points are always sorted on their x value.

Constructor detail
Interpolation()constructor
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.
Method detail
addChangedCallbacks()method
public function addChangedCallbacks(callback:Function):voidParameters
callback:Function
addControlPoint()method 
public function addControlPoint(point:ControlPoint):void

Adds a control point.

Parameters
point:ControlPoint — The control point to add.
bake()method 
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.
clamp()method 
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.
findPointBefore()method 
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.
getInterpolationAt()method 
public function getInterpolationAt(x:Number):NumberParameters
x:Number

Returns
Number
getValueAt()method 
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.
interpolate()method 
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.
removeChangedCallbacks()method 
public function removeChangedCallbacks(callback:Function):voidParameters
callback:Function
removeControlPoint()method 
public function removeControlPoint(point:ControlPoint):void

Removes a control point by reference. This is not done by a value check.

Parameters
point:ControlPoint — The control point to remove.
toString()method 
public function toString():String

Creates the string representation of the current object.

Returns
String — The string representation of the current object.