### clamp

Constrain a value to lie between two further values.

clamp(min: number, max: number, v: number): number
Parameters
min `(number)` Lower end of the range into which to constrain v.
max `(number)` Upper end of the range into which to constrain v.
v `(number)` Value to clamp.
Returns
`number`: The value to constrain.

### clamp01

Clamps a value between 0 and 1 and returns value

clamp01(v: number): number
Parameters
v `(number)` Value to clamp
Returns
`number`: The clamped value

### step

Generate a step function by comparing two values.

step(edge: number, v: number): number
Parameters
edge `(number)` Location of the edge of the step function.
v `(number)` Value to be used to generate the step function.
Returns
`number`: Step value.

### map

Re-maps a number from one range to another (Also known as scale)

map(value: number, start1: number, stop1: number, start2: number, stop2: number): number
Parameters
value `(number)` The incoming value to be converted
start1 `(number)` Lower bound of the value's current range
stop1 `(number)` Upper bound of the value's current range
start2 `(number)` Lower bound of the value's target range
stop2 `(number)` Upper bound of the value's target range
Returns
`number`: Remapped number

### diagonal

Return diagonal of a rectangle.

diagonal(w: number, h: number): number
Parameters
w `(number)` Width.
h `(number)` Height.
Returns
`number`: Diagonal length.

### distance

Returns the euclidian distance between the two given set of coordinates

distance(x1: number, y1: number, x2: number, y2: number): number
Parameters
x1 `(number)` X coord of the first point.
y1 `(number)` Y coord of the first point.
x2 `(number)` X coord of the second point.
y2 `(number)` Y coord of the second point.
Returns
`number`: The computed distance.

### smoothStep

Smooth a value.

smoothStep(min: number, max: number, v: number): number
Parameters
min `(number)` Minimum boundary.
max `(number)` Maximum boundary.
v `(number)` Value.
Returns
`number`: Smoothed value.

### lerp

Linearly interpolate between two values (mix).

lerp(x: number, y: number, r: number): number
Parameters
x `(number)` Start of the range in which to interpolate.
y `(number)` End of the range in which to interpolate.
r `(number)` Value to use to interpolate between x and y.
Returns
`number`: Lerped value

### normalize

Normalize a value between two bounds.

normalize(min: number, max: number, x: number): number
Parameters
min `(number)` Minimum boundary.
max `(number)` Maximum boundary.
x `(number)` Value to normalize.
Returns
`number`: Normalized value.

### randomFloat

Generate a random float.

randomFloat(minValue: number, maxValue: number, precision: number?): number
Parameters
minValue `(number)` Minimum boundary.
maxValue `(number)` Maximum boundary.
precision ```(number? = 2)``` Precision.
Returns
`number`: Generated float.

### randomInt

Generate a random integer

randomInt(min: number, max: number): number
Parameters
min `(number)` Minimum boundary.
max `(number)` Maximum boundary.
Returns
`number`: Generated integer.

### randomSign

Generate random sign (1 or -1).

randomSign(): number
Returns
`number`: Either 1 or -1.

### wrap

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.

wrap(value: number, min: number, max: number): number
Parameters
value `(number)` The value to wrap.
min `(number)` The minimum the value is allowed to be.
max `(number)` The maximum the value is allowed to be, should be larger than 'min'.
Returns
`number`: Wrapped value.

Parameters
degrees `(number)` Degrees.
Returns
`number`: Angel in radians.

Parameters
radians `(number)` Radians.
Returns
`number`: Angel in degrees.

### fuzzyFloor

Calculates a fuzzy floor to the given value.

fuzzyFloor(value: number, epsilon: number?): number
Parameters
value `(number)` The value to floor.
epsilon ```(number? = 0.0001)``` The epsilon (a small value used in the calculation).
Returns
`number`: floor(value+epsilon).

### fuzzyCeil

Calculates a fuzzy ceil to the given value.

fuzzyCeil(value: number, epsilon: number?): number
Parameters
value `(number)` The value to ceil.
epsilon ```(number? = 0.0001)``` The epsilon (a small value used in the calculation).
Returns
`number`: ceiling(value+epsilon).

### fuzzyEqual

Two numbers are fuzzyEqual if their difference is less than epsilon.

fuzzyEqual(a: number, b: number, epsilon: number?): boolean
Parameters
a `(number)` The first number to compare.
b `(number)` The second number to compare.
epsilon ```(number? = 0.0001)``` The epsilon (a small value used in the calculation).
Returns
`boolean`: True if |a-b|<epsilona otherwise false.

### fuzzyGreaterThan

A is fuzzyGreaterThan B if it is more than B - epsilon.

fuzzyGreaterThan(a: number, b: number, epsilon: number?): boolean
Parameters
a `(number)` The first number to compare.
b `(number)` The second number to compare.
epsilon ```(number? = 0.0001)``` The epsilon (a small value used in the calculation).
Returns
`boolean`: True if a>b-epsilon.

### fuzzyLessThan

A is fuzzyLessThan B if it is less than B + epsilon.

fuzzyLessThan(a: number, b: number, epsilon: number?): boolean
Parameters
a `(number)` The first number to compare.
b `(number)` The second number to compare.
epsilon ```(number? = 0.0001)``` The epsilon (a small value used in the calculation).
Returns
`boolean`: True if a<b+epsilon.

Adds the given amount to the value, but never lets the value go over the specified maximum.

maxAdd(value: number, amount: number, max: number): number
Parameters
value `(number)` The value to add the amount to.
amount `(number)` The amount to add to the value.
max `(number)` The maximum the value is allowed to be.
Returns
`number`: The new value.

### minSub

Subtracts the given amount from the value, but never lets the value go below the specified minimum.

minSub(value: number, amount: number, min: number): number
Parameters
value `(number)` The base value.
amount `(number)` The amount to subtract from the base value.
min `(number)` The minimum the value is allowed to be.
Returns
`number`: The new value.

### isOdd

Returns true if the number given is odd.

isOdd(number: number): boolean
Parameters
number `(number)` The number to check.
Returns
`boolean`: True if the given number is odd. False if the given number is even.

### isEven

Returns true if the number given is even.

isEven(number: number): boolean
Parameters
number `(number)` The number to check.
Returns
`boolean`: True if the given number is even. False if the given number is false.

### isPowerOfTwo

Checks if a number is a power of two.

isPowerOfTwo(value: number): boolean
Parameters
value `(number)` Number to test.
Returns
`boolean`: returns true if the value is power of two.

### closestPowerOfTwo

Returns the closest power of two value.

closestPowerOfTwo(value: number): number
Parameters
value `(number)` Value.
Returns
`number`: The nearest power of 2i.

### nextPowerOfTwo

Returns the next power of two value.

nextPowerOfTwo(v: number): number
Parameters
v `(number)` Value.
Returns
`number`: The next power of two.

### percent01

Work out what percentage value `a` is of value `b` using the given base. Clamps returned value between 0-1.

percent01(a: number, b: number, base: number?): number
Parameters
a `(number)` The percent to work out.
b `(number)` The value you wish to get the percentage of.
base ```(number? = 0)``` The base value.
Returns
`number`: The percentage a is of b, clamped between 0 and 1.

### average

Return the avarage of all values passed to the function.

average(numbers: ...number): number
Parameters
numbers `(...number)` The numbers to average.
Returns
`number`: The average of all given values.

### difference

The absolute difference between two values.

difference(a: number, b: number): number
Parameters
a `(number)` The first value to check.
b `(number)` The second value to check.
Returns
`number`: The absolute difference between the two values.

### within

Checks if two values are within the given tolerance of each other.

within(a: number, b: number, tolerance: number): boolean
Parameters
a `(number)` The first number to check
b `(number)` The second number to check
tolerance `(number)` The tolerance. Anything equal to or less than this is considered within the range.
Returns
`boolean`: True if a is <= tolerance of b.

### inverseLerp

Calculates the linear parameter t that produces the interpolant value within the range [a, b].

inverseLerp(a: number, b: number, v: number): number
Parameters
a `(number)` The start value.
b `(number)` The end value.
v `(number)` The value.
Returns
`number`: The result of the reverse interpolation.

### lerpUnclamped

Linearly interpolates between x and y by a with no limit to a.

lerpUnclamped(x: number, y: number, a: number): number
Parameters
x `(number)` The start value.
y `(number)` The end value.
a `(number)` The interpolation between the two floats.
Returns
`number`: The float value as a result from the linear interpolation.

### deltaAngleDeg

Calculates the shortest difference between two given angles given in degrees.

deltaAngleDeg(a: number, b: number): number
Parameters
a `(number)` Current.
b `(number)` Target.
Returns
`number`: The distance.

Calculates the shortest difference between two given angles given in radians.

Parameters
a `(number)` Current.
b `(number)` Target.
Returns
`number`: The distance.

### fract

Compute the fractional part of the argument.

fract(v: number): number
Parameters
v `(number)` Specify the value to evaluate.
Returns
`number`: Returns the fractional part of x.

### mod

Compute value of one parameter modulo another.

mod(a: number, n: number): number
Parameters
a `(number)` Value a.
n `(number)` Value b.
Returns
`number`: Returns the value of x modulo n.

### lerpAngleDeg

Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.

lerpAngleDeg(a: number, b: number, t: number): number
Parameters
a `(number)` The start value.
b `(number)` The end value.
t `(number)` Value to inerpolate.
Returns
`number`: The interpolated value.

Same as Lerp but makes sure the values interpolate correctly when they wrap around 2 radians.

lerpAngleRad(a: number, b: number, t: number): number
Parameters
a `(number)` The start value.
b `(number)` The end value.
t `(number)` Value to inerpolate.
Returns
`number`: The interpolated value.

### gammaToLinearSpace

Converts the given value from gamma (sRGB) to linear color space.

gammaToLinearSpace(v: number): number
Parameters
v `(number)` Gamma value.
Returns
`number`: Value in linear color space.

### linearToGammaSpace

Converts the given value from linear to gamma (sRGB) color space.

linearToGammaSpace(v: number): number
Parameters
v `(number)` Linear color space value.
Returns
`number`: Value in gamma.

### almostIdentity

Almost Identity.

almostIdentity(x: number, m: number, n: number): number
Parameters
x `(number)` Input value.
m `(number)` Threshold.
n `(number)` The value to take when x is zero.
Returns
`number`: Smoothed value.

### impulse

Impulse.

impulse(k: number, x: number): number
Parameters
k `(number)` Stretching of the function. Max is 1.0.
x `(number)` Input value.
Returns
`number`: Impulse.

### cubicPulse

Cubic Pulse.

cubicPulse(c: number, w: number, x: number): number
Parameters
c `(number)` Edge 1.
w `(number)` Edge 2.
x `(number)` Source value for interpolation.
Returns
`number`: Cubic pulse.

### expStep

ExpStep.

expStep(x: number, k: number, n: number): number
Parameters
x `(number)` Value to be used to generate the step function.
k `(number)` Edge of the step.
n `(number)` n value.
Returns
`number`: Exponential step.

### parabola

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.

parabola(x: number, k: number): number
Parameters
x `(number)` Coordinate on X axis.
k `(number)` Value to map.
Returns
`number`: Mapped value.

### powerCurve

Power Curve.

powerCurve(x: number, a: number, b: number): number
Parameters
x `(number)` Input value.
a `(number)` Edge 1.
b `(number)` Edge 2.
Returns
`number`: Value.

### smoothMin

Smooth Min.

smoothMin(a: number, b: number, k: number): number
Parameters
a `(number)` First value to compare.
b `(number)` Second value to compare.
k `(number)` Radious/distance of the smoothness.
Returns
`number`: Smooth min output.

### smoothMax

Smooth Max.

smoothMax(a: number, b: number, k: number): number
Parameters
a `(number)` First value to compare.
b `(number)` Second value to compare.
k `(number)` Radious/distance of the smoothness.
Returns
`number`: Smooth min output.

### deltaTime

Return delta time

deltaTime(oldTime: number, newTime: number?): number
Parameters
oldTime `(number)` Time previous frame in milliseconds
newTime ```(number? = Date.now())``` Time current frame in milliseconds
Returns
`number`: Time difference in milliseconds

### gcd

Compute the greatest common divisor using Euclid's algorithm.

gcd(a: number, b: number): number
Parameters
a `(number)` Value one.
b `(number)` Value two.
Returns
`number`: Greatest common divisor.

### dotProduct

Compute the dot product of any pair of 2D vectors.

dotProduct(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): number
Parameters
x0 `(number)` First x start position.
y0 `(number)` First y start position.
x1 `(number)` First x end position.
y1 `(number)` First y end position.
x2 `(number)` Second x start position.
y2 `(number)` Second y start position.
x3 `(number)` Second x end position.
y3 `(number)` Second y end position.
Returns
`number`: Dot product.