Members
(static, constant) average
Return the average of all values
- Source
sum(1, 2, 3); // => 2
(static, constant) constrain
Constrain a number between two limits.
- Source
constrain(999, 0, 50); // => 50
constrain(-999, 0, 50); // => 0
(static, constant) degreeCircle :Number
Full rotation on degree circle
Type:
- Number
- Source
(static, constant) distribute
Returns an array of evenly distributed value across a range
- Source
distribute(10); // => Number[10] evenly distributed across [0, 1]
distribute(5, 10, 20); // => Number[5] evenly distributed across [10, 20]
(static, constant) equals
Determine if two number can considered equals accounting for JS precision.
- Source
equals(0.1 + 0.2, 0.3); // => true
(static, constant) lerp
Linear extrapolation computation, useful when doing animation
- Source
(static, constant) map
Return the equivalent of a value from a scale to another
- Source
map(5, 0, 10, 100, 200); // => 150
(static, constant) modulo
Return modulo with the same sign as the divisor (Floored division)
- Source
modulo(10, 3); // => 1
modulo(10, -3); // => -2
(static, constant) phi :Number
Golden ratio number
Type:
- Number
- Source
(static, constant) radianCircle :Number
Full rotation on radian circle
Type:
- Number
- Source
(static, constant) random
Return a random number between limits
- Source
random(); // => 0.5918807307648482
random(10); // => 4.4856764978326735
random(100, 200); // => 134.57047268453047
(static, constant) sum
Add up all values passed as argument
- Source
sum(1, 2, 3); // => 6
(static, constant) truncate
Truncate a number to its integer part.
- Source
truncate(12.3); // => 12
truncate(-4.9); // => -4