Options
All
  • Public
  • Public/Protected
  • All
Menu

Module MathTools

Index

Modules

Functions

Functions

Clamp

  • Clamp(val: number, min: number, max: number): number
  • Clamp a value to a specified integer range [min, max], without scaling.

    Parameters

    • val: number

      The value to clamp

    • min: number

      Minimum value

    • max: number

      Maximum value

    Returns number

    An integer in [min, max]

ClampRectToBounds

  • ClampRectToBounds(rectPos: Readonly<Vec2>, rectSize: Readonly<Vec2>, bounds: Readonly<Vec2>): [number, number, number, number]
  • Clamp a rectangle to within a given boundary.

    The position is assumed to be relative to the boundary.

    Parameters

    • rectPos: Readonly<Vec2>

      The position of the rect, as an [x, y] pair

    • rectSize: Readonly<Vec2>

      The size of the rect, as a [width, height] pair

    • bounds: Readonly<Vec2>

      The canvas boundary, as a [width, height] pair

    Returns [number, number, number, number]

    The dimensions of the clamped rect, as a 4-tuple of [x, y, width, height].

Generated using TypeDoc