Options
All
  • Public
  • Public/Protected
  • All
Menu

External module mathf

Index

Type aliases

EasingFunction

EasingFunction: function

Type declaration

    • (percent: number): number
    • Parameters

      • percent: number

      Returns number

Functions

absZero

  • absZero(value: number): number

angleDegree

  • angleDegree(x1: number, y1: number, x2: number, y2: number): number
  • Parameters

    • x1: number
    • y1: number
    • x2: number
    • y2: number

    Returns number

    The angle in degrees.

angleDistanceDegree

  • angleDistanceDegree(angle0: number, angle1: number, max: number): number
  • Parameters

    • angle0: number
    • angle1: number
    • Optional max: number

    Returns number

angleDistanceRadian

  • angleDistanceRadian(angle0: number, angle1: number, max: number): number
  • Parameters

    • angle0: number
    • angle1: number
    • Optional max: number

    Returns number

    Distance in radians

angleRadians

  • angleRadians(x1: number, y1: number, x2: number, y2: number): number
  • Parameters

    • x1: number
    • y1: number
    • x2: number
    • y2: number

    Returns number

    The angle in radians.

aspectRatio

asymptoticAverage

  • asymptoticAverage(current: number, target: number, amount: number): number
  • Parameters

    • current: number
    • target: number
    • amount: number

    Returns number

boxCollision

  • boxCollision(a: box, b: box): boolean

calculate2dPointRotation

  • calculate2dPointRotation(cx: number, cy: number, x: number, y: number, angle: number): object
  • Parameters

    • cx: number
    • cy: number
    • x: number
    • y: number
    • angle: number

    Returns object

    • x: number
    • y: number

calculate2dPointRotationWithDistance

  • calculate2dPointRotationWithDistance(cx: number, cy: number, x: number, y: number, angle: number, distance: number): object
  • Parameters

    • cx: number
    • cy: number
    • x: number
    • y: number
    • angle: number
    • distance: number

    Returns object

    • x: number
    • y: number

calculateBackgroundContain

calculateBackgroundCover

calculateCenterOffset

  • calculateCenterOffset(parent: number, child: number): number
  • Parameters

    • parent: number
    • child: number

    Returns number

    The offset value.

ceilToPrecision

  • ceilToPrecision(value: number, precision: number): number

childProgress

  • childProgress(progress: number, start: number, end: number, noClamp?: boolean): number
  • Parameters

    • progress: number
    • start: number
    • end: number
    • Default value noClamp: boolean = false

    Returns number

clamp

  • clamp(min: number, max: number, num: number): number
  • Parameters

    • min: number
    • max: number
    • num: number

    Returns number

    A number within the min and max range.

clamp01

  • clamp01(progress: number): number
  • Parameters

    • progress: number

    Returns number

    progress A value within 0-1.

clampAsPercent

  • clampAsPercent(percent: number): number
  • Parameters

    • percent: number

    Returns number

    percent A value within 0-1.

clampAsProgress

  • clampAsProgress(progress: number): number
  • Parameters

    • progress: number

    Returns number

    progress A value within 0-1.

collisionCircVsBox

  • collisionCircVsBox(circ: circ, rect: box): boolean

collisionPointVersusConvexPolygon

  • collisionPointVersusConvexPolygon(point: point, poly: Array<point>): boolean

colorRgbToRgb

  • colorRgbToRgb(colorRgb: ColorRGB): Array<number>

cssToRgba

damp

  • damp(value1: number, value2: number, amount: number, damp: number): number
  • Parameters

    • value1: number
    • value2: number
    • amount: number
    • damp: number

    Returns number

degreeToRadian

  • degreeToRadian(deg: number): number
  • Parameters

    • deg: number

    Returns number

    The converted radian.

direction

  • direction(previous: number, current: number): number
  • Parameters

    • previous: number
    • current: number

    Returns number

distance

  • distance(x1: number, y1: number, x2: number, y2: number): number
  • Parameters

    • x1: number
    • y1: number
    • x2: number
    • y2: number

    Returns number

    The distance between point 1 and point 2.

ease

  • ease(start: number, end: number, progress: number, easeFunction?: Function): number
  • Parameters

    • start: number
    • end: number
    • progress: number
    • Default value easeFunction: Function = EASE.linear

    Returns number

fade

  • fade(t: number): number

fixDigits

  • fixDigits(value: string | number, digits: number): number
  • Parameters

    • value: string | number
    • digits: number

    Returns number

flipCoin

  • flipCoin(): number

floorToPrecision

  • floorToPrecision(value: number, precision: number): number

generateRandomPoints

  • generateRandomPoints(num: number, minX: number, maxX: number, minY: number, maxY: number): point[]
  • Parameters

    • num: number
    • minX: number
    • maxX: number
    • minY: number
    • maxY: number

    Returns point[]

    An array of objects containing x, y values.

getProgressInRangeByValue

  • getProgressInRangeByValue(val: number, min: number, max: number): number
  • Parameters

    • val: number
    • min: number
    • max: number

    Returns number

    The progress within the range.

getRandomFloat

  • getRandomFloat(min: number, max: number): number
  • Parameters

    • min: number
    • max: number

    Returns number

    A random number between the provided range.

getRandomInt

  • getRandomInt(min: number, max: number): number
  • Parameters

    • min: number
    • max: number

    Returns number

    A random integer betwen the provided range.

getUniqueRandomInt

  • getUniqueRandomInt(min: number, max: number, not: number): number
  • Parameters

    • min: number
    • max: number
    • not: number

    Returns number

getValueInRangeByProgress

  • getValueInRangeByProgress(progress: number, min: number, max: number): number
  • Parameters

    • progress: number
    • min: number
    • max: number

    Returns number

    The value within the range.

grad

  • grad(hash: number, x: number, y: number, z: number): number

hexToRgbNormalized

  • hexToRgbNormalized(hexValue: number): any[]

hexToRgba

  • hexToRgba(hex: string, a?: number): ColorRGBA | null

int

  • int(value: number): number

int0

  • int0(value: number): number

interpolateRange

  • interpolateRange(range1Value: number, range1Min: number, range1Max: number, range2Min: number, range2Max: number): number
  • Parameters

    • range1Value: number
    • range1Min: number
    • range1Max: number
    • range2Min: number
    • range2Max: number

    Returns number

inverseLerp

  • inverseLerp(a: number, b: number, value: number, noClamp?: boolean): number
  • Parameters

    • a: number
    • b: number
    • value: number
    • Default value noClamp: boolean = false

    Returns number

    A normalized value between 0-1

inverseProgress

  • inverseProgress(value: number): number

isBetween

  • isBetween(testValue: number, range1: number, range2: number, inclusive?: boolean): boolean
  • Parameters

    • testValue: number
    • range1: number
    • range2: number
    • Default value inclusive: boolean = true

    Returns boolean

    Whether the test value is between range1 and range2.

lerp

  • lerp(value1: number, value2: number, amount: number): number
  • Parameters

    • value1: number
    • value2: number
    • amount: number

    Returns number

    The interporalated value.

lerp

  • lerp(t: number, a: number, b: number): number

lerpEase

  • lerpEase(value1: number, value2: number, amount: number, easeFunction?: Function): number
  • Parameters

    • value1: number
    • value2: number
    • amount: number
    • Default value easeFunction: Function = EASE.linear

    Returns number

mix

  • mix(a: number, b: number, blend: number): number
  • Parameters

    • a: number
    • b: number
    • blend: number

    Returns number

noise3

  • noise3(x: number, y: number, z?: number): number
  • Parameters

    • x: number
    • y: number
    • Default value z: number = 0

    Returns number

    A value between 0 and 1.

normalize

  • normalize(val: number, min: number, max: number): number
  • Parameters

    • val: number
    • min: number
    • max: number

    Returns number

normalizedRgbToHex

  • normalizedRgbToHex(rgb: Array<number>): number

normalizedRgbToRgb

  • normalizedRgbToRgb(rgb: Array<number>): Array<number>

radianToDegree

  • radianToDegree(radian: number): number
  • Parameters

    • radian: number

    Returns number

    The converted degree.

remap

  • remap(minA: number, maxA: number, minB: number, maxB: number, valueB: number): number
  • Parameters

    • minA: number
    • maxA: number
    • minB: number
    • maxB: number
    • valueB: number

    Returns number

resizeDimensionalBoxToHeight

resizeDimensionalBoxToWidth

rgbToHex

rgbToNormalizedRgb

  • rgbToNormalizedRgb(rgb: Array<number>): Array<number>

rgbaEase

rgbaLerp

rgbaToCss

roundToPrecision

  • roundToPrecision(value: number, precision: number): number

scale

  • scale(n: number): number

scaleX

  • scaleX(x1: number, y1: number, y2: number): number
  • Parameters

    • x1: number
    • y1: number
    • y2: number

    Returns number

scaleY

  • scaleY(x1: number, y1: number, x2: number): number
  • Parameters

    • x1: number
    • y1: number
    • x2: number

    Returns number

sigmoid

  • sigmoid(value: number, mix: number): number

sinNormalized

  • sinNormalized(time: number): number

smoothStart2

  • smoothStart2(t: number): number

smoothStart3

  • smoothStart3(t: number): number

smoothStep

  • smoothStep(min: number, max: number, input: number): number
  • Parameters

    • min: number
    • max: number
    • input: number

    Returns number

smoothStep2

  • smoothStep2(value: number, mix: number, t: number): number

smoothStop2

  • smoothStop2(t: number): number

smoothStop3

  • smoothStop3(t: number): number

step

  • step(edge: number, n: number): 0 | 1

sum

  • sum(values: number[]): number

toFixed

  • toFixed(value: number, precision: number): number

wrap

  • wrap(value: number, min: number, max: number): number
  • Parameters

    • value: number
    • min: number
    • max: number

    Returns number