v1.2.0.1-beta1

Description

Math Object Extensions

Note
Note that all Math functions are also available in the global object scope, w/out the Math. qualifier.

Public Member Functions

number clamp (number value, number min, number max)
 
number constrain (number value, number min, number max)
 
number roundTo (number value, number precision)
 
number toDegrees (number radians)
 
number toRadians (number degrees)
 
number percentOfRange (number percentValue, number rangeMin, number rangeMax)
 
number rangeValueToPercent (number value, number rangeMin, number rangeMax)
 

Member Function Documentation

◆ clamp()

number clamp ( number  value,
number  min,
number  max 
)

Constrain value between min and max values.

◆ constrain()

number constrain ( number  value,
number  min,
number  max 
)

Alias for Math.clamp()

◆ roundTo()

number roundTo ( number  value,
number  precision 
)

Round value to precision decimal places.

◆ toDegrees()

number toDegrees ( number  radians)

Convert radians to degrees.

◆ toRadians()

number toRadians ( number  degrees)

Convert degrees to radians.

◆ percentOfRange()

number percentOfRange ( number  percentValue,
number  rangeMin,
number  rangeMax 
)

Scales percentValue into the numeric range specified by rangeMin and rangeMax and returns the new value. In other words, "what value does this percentage represent within this range." This may return a value outside the given range if percentValue is greater or less than 100. percentValue is always treated as absolute.
Either of rangeMin or rangeMax can be the larger number. The returned value will be proportional in either case.

◆ rangeValueToPercent()

number rangeValueToPercent ( number  value,
number  rangeMin,
number  rangeMax 
)

Returns the percentage of the rangeMin through rangeMax numeric range represented by value. In other words, "what percentage does this value represent of the given range." This may return a percentage greater than 100 if value falls outside of rangeMin and rangeMax.
Either of rangeMin or rangeMax can be the larger number. The returned percentage will be proportional in either case.