Constrain a value to lie between two further values.
(number)
Lower end of the range into which to constrain v.
(number)
Upper end of the range into which to constrain v.
(number)
Value to clamp.
number
:
The value to constrain.
Clamps a value between 0 and 1 and returns value
(number)
Value to clamp
number
:
The clamped value
Generate a step function by comparing two values.
(number)
Location of the edge of the step function.
(number)
Value to be used to generate the step function.
number
:
Step value.
Re-maps a number from one range to another (Also known as scale)
(number)
The incoming value to be converted
(number)
Lower bound of the value's current range
(number)
Upper bound of the value's current range
(number)
Lower bound of the value's target range
(number)
Upper bound of the value's target range
number
:
Remapped number
Return diagonal of a rectangle.
number
:
Diagonal length.
Returns the euclidian distance between the two given set of coordinates
(number)
X coord of the first point.
(number)
Y coord of the first point.
(number)
X coord of the second point.
(number)
Y coord of the second point.
number
:
The computed distance.
Smooth a value.
number
:
Smoothed value.
Linearly interpolate between two values (mix).
(number)
Start of the range in which to interpolate.
(number)
End of the range in which to interpolate.
(number)
Value to use to interpolate between x and y.
number
:
Lerped value
Normalize a value between two bounds.
number
:
Normalized value.
Generate a random float.
(number)
Minimum boundary.
(number)
Maximum boundary.
(number?
= 2
)
Precision.
number
:
Generated float.
Generate a random integer
number
:
Generated integer.
Generate random sign (1 or -1).
number
:
Either 1 or -1.
Ensures that the value always stays between min and max, by wrapping the value around. If 'max' is not larger than 'min' the result is 0.
(number)
The value to wrap.
(number)
The minimum the value is allowed to be.
(number)
The maximum the value is allowed to be, should be larger than 'min'.
number
:
Wrapped value.
Convert degrees to radians.
(number)
Degrees.
number
:
Angel in radians.
Convert radians to degrees.
(number)
Radians.
number
:
Angel in degrees.
Calculates a fuzzy floor to the given value.
(number)
The value to floor.
(number?
= 0.0001
)
The epsilon (a small value used in the calculation).
number
:
floor(value+epsilon).
Calculates a fuzzy ceil to the given value.
(number)
The value to ceil.
(number?
= 0.0001
)
The epsilon (a small value used in the calculation).
number
:
ceiling(value+epsilon).
Two numbers are fuzzyEqual if their difference is less than epsilon.
(number)
The first number to compare.
(number)
The second number to compare.
(number?
= 0.0001
)
The epsilon (a small value used in the calculation).
boolean
:
True if |a-b|<epsilona otherwise false.
A is fuzzyGreaterThan B if it is more than B - epsilon.
(number)
The first number to compare.
(number)
The second number to compare.
(number?
= 0.0001
)
The epsilon (a small value used in the calculation).
boolean
:
True if a>b-epsilon.
A is fuzzyLessThan B if it is less than B + epsilon.
(number)
The first number to compare.
(number)
The second number to compare.
(number?
= 0.0001
)
The epsilon (a small value used in the calculation).
boolean
:
True if a<b+epsilon.
Adds the given amount to the value, but never lets the value go over the specified maximum.
(number)
The value to add the amount to.
(number)
The amount to add to the value.
(number)
The maximum the value is allowed to be.
number
:
The new value.
Subtracts the given amount from the value, but never lets the value go below the specified minimum.
(number)
The base value.
(number)
The amount to subtract from the base value.
(number)
The minimum the value is allowed to be.
number
:
The new value.
Returns true if the number given is odd.
(number)
The number to check.
boolean
:
True if the given number is odd. False if the given number is even.
Returns true if the number given is even.
(number)
The number to check.
boolean
:
True if the given number is even. False if the given number is false.
Checks if a number is a power of two.
(number)
Number to test.
boolean
:
returns true if the value is power of two.
Returns the closest power of two value.
(number)
Value.
number
:
The nearest power of 2i.
Returns the next power of two value.
(number)
Value.
number
:
The next power of two.
Work out what percentage value a
is of value b
using the given base.
Clamps returned value between 0-1.
(number)
The percent to work out.
(number)
The value you wish to get the percentage of.
(number?
= 0
)
The base value.
number
:
The percentage a is of b, clamped between 0 and 1.
Return the avarage of all values passed to the function.
(...number)
The numbers to average.
number
:
The average of all given values.
The absolute difference between two values.
number
:
The absolute difference between the two values.
Checks if two values are within the given tolerance of each other.
(number)
The first number to check
(number)
The second number to check
(number)
The tolerance. Anything equal to or less than this is considered within the range.
boolean
:
True if a is <= tolerance of b.
Calculates the linear parameter t that produces the interpolant value within the range [a, b].
number
:
The result of the reverse interpolation.
Linearly interpolates between x and y by a with no limit to a.
(number)
The start value.
(number)
The end value.
(number)
The interpolation between the two floats.
number
:
The float value as a result from the linear interpolation.
Calculates the shortest difference between two given angles given in degrees.
number
:
The distance.
Calculates the shortest difference between two given angles given in radians.
number
:
The distance.
Compute the fractional part of the argument.
(number)
Specify the value to evaluate.
number
:
Returns the fractional part of x.
Compute value of one parameter modulo another.
number
:
Returns the value of x modulo n.
Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
number
:
The interpolated value.
Same as Lerp but makes sure the values interpolate correctly when they wrap around 2 radians.
number
:
The interpolated value.
Converts the given value from gamma (sRGB) to linear color space.
(number)
Gamma value.
number
:
Value in linear color space.
Converts the given value from linear to gamma (sRGB) color space.
(number)
Linear color space value.
number
:
Value in gamma.
Almost Identity.
number
:
Smoothed value.
Impulse.
number
:
Impulse.
Cubic Pulse.
number
:
Cubic pulse.
ExpStep.
(number)
Value to be used to generate the step function.
(number)
Edge of the step.
(number)
n value.
number
:
Exponential step.
Remap the 0..1 interval into 0..1 parabola, such that the corners are remaped to 0 and the center to 1. In other words, parabola(0) = parabola(1) = 0, and parabola(1/2) = 1.
number
:
Mapped value.
Power Curve.
number
:
Value.
Smooth Min.
(number)
First value to compare.
(number)
Second value to compare.
(number)
Radious/distance of the smoothness.
number
:
Smooth min output.
Smooth Max.
(number)
First value to compare.
(number)
Second value to compare.
(number)
Radious/distance of the smoothness.
number
:
Smooth min output.
Return delta time
(number)
Time previous frame in milliseconds
(number?
= Date.now()
)
Time current frame in milliseconds
number
:
Time difference in milliseconds
Compute the greatest common divisor using Euclid's algorithm.
number
:
Greatest common divisor.
Compute the dot product of any pair of 2D vectors.
(number)
First x start position.
(number)
First y start position.
(number)
First x end position.
(number)
First y end position.
(number)
Second x start position.
(number)
Second y start position.
(number)
Second x end position.
(number)
Second y end position.
number
:
Dot product.