blob: eebd1d561f57a925047eb4c797110212f857b7cc [file] [log] [blame]
////////////////////////////////////////////////////////////////////////////////
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package mx.effects.easing
{
/**
* The Spark effects provided as of Flex 4 use classes which implement the
* IEaser interface instead of the easing functions in classes like Linear for
* the earlier Flex 3 effects. To achieve the same functionality of the old
* Linear class, create a new instance of spark.effects.easing.Linear or call
* spark.effects.easing.Linear.getInstance() to get a singleton instance.
*/
[Alternative(replacement="spark.effects.easing.Linear", since="4.0")]
/**
* The Linear class defines easing functions to implement
* linear motion with Flex effect classes.
*
* For more information, see http://www.robertpenner.com/profmx.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public class Linear
{
include "../../core/Version.as";
//--------------------------------------------------------------------------
//
// Class methods
//
//--------------------------------------------------------------------------
/**
* The <code>easeNone()</code> method defines a constant motion,
* with no acceleration.
*
* @param t Specifies time.
*
* @param b Specifies the initial position of a component.
*
* @param c Specifies the total change in position of the component.
*
* @param d Specifies the duration of the effect, in milliseconds.
*
* @return Number corresponding to the position of the component.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public static function easeNone(t:Number, b:Number,
c:Number, d:Number):Number
{
return c * t / d + b;
}
/**
* The <code>easeIn()</code> method starts motion from zero velocity,
* and then accelerates motion as it executes.
*
* @param t Specifies time.
*
* @param b Specifies the initial position of a component.
*
* @param c Specifies the total change in position of the component.
*
* @param d Specifies the duration of the effect, in milliseconds.
*
* @return Number corresponding to the position of the component.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public static function easeIn(t:Number, b:Number,
c:Number, d:Number):Number
{
return c * t / d + b;
}
/**
* The <code>easeOut()</code> method starts motion fast,
* and then decelerates motion to a zero velocity as it executes.
*
* @param t Specifies time.
*
* @param b Specifies the initial position of a component.
*
* @param c Specifies the total change in position of the component.
*
* @param d Specifies the duration of the effect, in milliseconds.
*
* @return Number corresponding to the position of the component.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public static function easeOut(t:Number, b:Number,
c:Number, d:Number):Number
{
return c * t / d + b;
}
/**
* The <code>easeInOut()</code> method combines the motion
* of the <code>easeIn()</code> and <code>easeOut()</code> methods
* to start the motion from zero velocity, accelerate motion,
* then decelerate back to zero velocity.
*
* @param t Specifies time.
*
* @param b Specifies the initial position of a component.
*
* @param c Specifies the total change in position of the component.
*
* @param d Specifies the duration of the effect, in milliseconds.
*
* @return Number corresponding to the position of the component.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public static function easeInOut(t:Number, b:Number,
c:Number, d:Number):Number
{
return c * t / d + b;
}
}
}