Classes
Methods
(static) clamp(value, min, max) → {number}
Method to clamp a value between a range.
| Name | Type | Description |
|---|---|---|
value | number | Value to clamp. |
min | number | Minimum. |
max | number | Maximum. |
Original value if it is not clamped.
- Type:
- number
(static) degrees(degrees) → {number}
Method to convert radians to cartesian degrees.
| Name | Type | Description |
|---|---|---|
degrees | number | The amount of radians to convert. |
- Type:
- number
(static) dist(x1, y1, x2, y2) → {number}
Method to get the distance between two 2D points.
| Name | Type | Description |
|---|---|---|
x1 | number | X-coordinate of the first point. |
y1 | number | Y-coordinate of the first point. |
x2 | number | X-coordinate of the second point. |
y2 | number | Y-coordinate of the second point. |
- Type:
- number
(static) lerp(start, end, amt) → {number}
Linear interpolation method.
| Name | Type | Description |
|---|---|---|
start | number | Value to interpolate from. |
end | number | Value to interpolate to. |
amt | number | Amount to interpolate by. |
- Type:
- number
(static) map(value, valLow, valHigh, resLow, resHigh) → {number}
Method to map a number to another range.
| Name | Type | Description |
|---|---|---|
value | number | The value to map. |
valLow | number | The minimum of value. |
valHigh | number | The maximum of value. |
resLow | number | The minimum value of the result. |
resHigh | number | The maximum value of the result. |
- Type:
- number
(static) radians(degrees) → {number}
Method to convert cartesian degrees to radians.
| Name | Type | Description |
|---|---|---|
degrees | number | The amount of degrees to convert. |
- Type:
- number
(static) random(low, high) → {number}
Utility method to get a random floating point value in a range, instead of 'Math.random' which only does 0-1.
| Name | Type | Default | Description |
|---|---|---|---|
low | number | 0 | The minimum resulting value (inclusive). |
high | number | 1 | The maximum resulting value (exclusive). |
- Type:
- number
(static) randomInt(low, high) → {number}
Utility method to get a random integer in a range, instead of 'Math.random' which only does floats 0-1.
| Name | Type | Default | Description |
|---|---|---|---|
low | number | 0 | The minimum resulting value (inclusive). |
high | number | 1 | The maximum resulting value (exclusive). |
- Type:
- number
(static) rectCircleCollision(rectPos, rectSize, circleCenter, circleRadius) → {boolean}
Method to check for a collision between an axis-aligned rectangle and a circle.
| Name | Type | Description |
|---|---|---|
rectPos | glMatrix. | Position of the rectangle. |
rectSize | glMatrix. | Size of the rectangle. |
circleCenter | glMatrix. | Position of the center of the circle. |
circleRadius | number | Radius of the circle. |
true if colliding.
- Type:
- boolean
(static) rectRectCollision(vectorA, sizeA, vectorB, sizeB) → {boolean}
Method to check for a collision between two axis-aligned rectangles.
| Name | Type | Description |
|---|---|---|
vectorA | glMatrix. | Position of the first rectangle. |
sizeA | glMatrix. | Size of the first rectangle. |
vectorB | glMatrix. | Position of the second rectangle. |
sizeB | glMatrix. | Size of the second rectangle. |
true if colliding.
- Type:
- boolean
(static) wrap(value, min, max) → {number}
Method to wrap a value once it is too big or small.
| Name | Type | Description |
|---|---|---|
value | number | Value to wrap. |
min | number | Minimum to wrap around. |
max | number | Maximum to wrap around. |
Original value if it is not wrapped.
- Type:
- number