window.Math Class

Defined in: window.Math:7
Module: Core

Add methods to Math

Methods

clamp

(
  • value
  • max
)
Number
static

Defined in clamp:122

Constrain a number between 0 and a max value.

Parameters:

  • value Number

    The number to be constrained.

  • max Number

    Highest number.

Returns:

Number:

The constrained value

clamp

(
  • value
  • min
  • max
)
Number
static

Defined in clamp:131

Constrain a number between a minimum and maximum values.

Parameters:

  • value Number

    The number to be constrained.

  • min Number

    Lowest number to constrain value to.

  • max Number

    Highest number.

Returns:

Number:

The constrained value

dist

(
  • x
  • y
  • x0
  • y0
)
Number
static

Defined in dist:50

Return distance between two points

Parameters:

  • x Number

    The x position of the first point

  • y Number

    The y position of the first point

  • x0 Number

    The x position of the second point

  • y0 Number

    The y position of the second point

Returns:

Number:

The distance

dist

(
  • p1
  • p2
)
Number
static

Defined in dist:61

Return distance between two points

Parameters:

  • p1 Object

    The first point

    • x Object

      The x position of the first point

    • y Object

      The y position of the first point

  • p2 Object

    The second point

    • x Object

      The x position of the second point

    • y Number

      The y position of the second point

Returns:

Number:

The distance

distSq

(
  • x
  • y
  • x0
  • y0
)
Number
static

Defined in distSq:78

Return squared distance between two points

Parameters:

  • x Number

    The x position of the first point

  • y Number

    The y position of the first point

  • x0 Number

    The x position of the second point

  • y0 Number

    The y position of the second point

Returns:

Number:

The distance

distSq

(
  • p1
  • p2
)
Number
static

Defined in distSq:89

Return squared distance between two points

Parameters:

  • p1 Object

    The first point

    • x Object

      The x position of the first point

    • y Object

      The y position of the first point

  • p2 Object

    The second point

    • x Object

      The x position of the second point

    • y Number

      The y position of the second point

Returns:

Number:

The distance

randomFloat

(
  • min
  • max
)
Number
static

Defined in randomFloat:31

Return a random float between minimum and maximum values. If a single value is supplied, it will return a number between 0 and the supplied value.

Parameters:

  • min Number

    Lowest number. If max is omitted, then this becomes max.

  • max Number

    Highest number.

Returns:

Number:

The random value

randomInt

(
  • min
  • max
)
Int
static

Defined in randomInt:12

Return a random int between minimum and maximum values. If a single value is supplied, it will return a number between 0 and the supplied value.

Parameters:

  • min Int

    Lowest number. If max is omitted, then this becomes max.

  • max Int

    Highest number.

Returns:

Int:

The random value