FeathersMath
public class
feathers.utils.FeathersMath
API overview
Constructor
FeathersMath
()
Functions
Public functions
| calculateScaleRatioToFill ( originalWidth: Number , originalHeight: Number , targetWidth: Number , targetHeight: Number ): Number |
static Calculates a scale value to maintain aspect ratio and fill the required bounds (with the possibility of cutting of the edges a bit) |
| calculateScaleRatioToFit ( originalWidth: Number , originalHeight: Number , targetWidth: Number , targetHeight: Number ): Number |
static Calculates a scale value to maintain aspect ratio and fit inside the required bounds (with the possibility of a bit of empty space on the edges) |
| clamp ( value: Number , minimum: Number , maximum: Number ): Number |
static Forces a numeric value into a specified range |
| roundDownToNearest ( number: Number , nearest: Number = 1 ): Number |
static Rounds a Number down to the nearest multiple of an input |
| roundToNearest ( number: Number , nearest: Number = 1 ): Number |
static Rounds a Number to the nearest multiple of an input |
| roundToPrecision ( number: Number , precision: Number = 0 ): Number |
static Rounds a number to a certain level of precision |
| roundUpToNearest ( number: Number , nearest: Number = 1 ): Number |
static Rounds a Number up to the nearest multiple of an input |
Constructor
FeathersMath ()
Functions
calculateScaleRatioToFill ( originalWidth: Number , originalHeight: Number , targetWidth: Number , targetHeight: Number ): Number
static
Calculates a scale value to maintain aspect ratio and fill the required bounds (with the possibility of cutting of the edges a bit).
Parameters
| originalWidth: Number | |
| originalHeight: Number | |
| targetWidth: Number | |
| targetHeight: Number |
calculateScaleRatioToFit ( originalWidth: Number , originalHeight: Number , targetWidth: Number , targetHeight: Number ): Number
static
Calculates a scale value to maintain aspect ratio and fit inside the required bounds (with the possibility of a bit of empty space on the edges).
Parameters
| originalWidth: Number | |
| originalHeight: Number | |
| targetWidth: Number | |
| targetHeight: Number |
clamp ( value: Number , minimum: Number , maximum: Number ): Number
static
Forces a numeric value into a specified range.
@author Josh Tynjala (joshblog.net)
Parameters
| value: Number | The value to force into the range. |
| minimum: Number | The minimum bound of the range. |
| maximum: Number | The maximum bound of the range. |
Returns
| Number | A value within the specified range. |
getFullTypeName
(): String
Inherited from Object
native
Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.
Returns
| String | fully qualified type name of the Object. |
getType
(): Type
Inherited from Object
native
Gets the Type that describes the Object.
Returns
| Type | The Type that describes the object. |
getTypeName
(): String
Inherited from Object
native
Gets the type name of the Object.
Returns
| String | type name of the Object. |
roundDownToNearest ( number: Number , nearest: Number = 1 ): Number
static
Rounds a Number down to the nearest multiple of an input. For example, by rounding 16 down to the nearest 10, you will receive 10. Similar to the built-in function Math.floor().
See also:
system.Math#floor
Parameters
| number: Number | |
| nearest: Number = 1 | the number whose mutiple must be found |
Returns
| Number | the rounded number |
roundToNearest ( number: Number , nearest: Number = 1 ): Number
static
Rounds a Number to the nearest multiple of an input. For example, by rounding 16 to the nearest 10, you will receive 20. Similar to the built-in function Math.round().
See also:
system.Math#round
Parameters
| number: Number | |
| nearest: Number = 1 | the number whose mutiple must be found |
Returns
| Number | the rounded number |
roundToPrecision ( number: Number , precision: Number = 0 ): Number
static
Rounds a number to a certain level of precision. Useful for limiting the number of decimal places on a fractional number.
See also:
system.Math#round
Parameters
| number: Number | the input number to round. |
| precision: Number = 0 | the number of decimal digits to keep |
Returns
| Number | the rounded number, or the original input if no rounding is needed |
roundUpToNearest ( number: Number , nearest: Number = 1 ): Number
static
Rounds a Number up to the nearest multiple of an input. For example, by rounding 16 up to the nearest 10, you will receive 20. Similar to the built-in function Math.ceil().
See also:
system.Math#ceil
Parameters
| number: Number | |
| nearest: Number = 1 | the number whose mutiple must be found |
Returns
| Number | the rounded number |