like2d
    Preparing search index...

    Variable Vec2Const

    Vec2: {
        add: (a: Pair<number>, b: number | Pair<number>) => Pair<number>;
        ceil: (a: Pair<number>) => Pair<number>;
        div: (a: Pair<number>, b: number | Pair<number>) => Pair<number>;
        floor: (a: Pair<number>) => Pair<number>;
        map: <I, O>(op: (a: I) => O) => (a: Pair<I>) => Pair<O>;
        map2: <I, O>(
            op: (a: I, b: I) => O,
        ) => (a: Pair<I>, b: I | Pair<I>) => Pair<O>;
        max: (a: Pair<number>, b: number | Pair<number>) => Pair<number>;
        min: (a: Pair<number>, b: number | Pair<number>) => Pair<number>;
        mod: (a: Pair<number>, b: number | Pair<number>) => Pair<number>;
        mul: (a: Pair<number>, b: number | Pair<number>) => Pair<number>;
        negate: (a: Pair<number>) => Pair<number>;
        round: (a: Pair<number>) => Pair<number>;
        sub: (a: Pair<number>, b: number | Pair<number>) => Pair<number>;
        angle(v: Vector2): number;
        clamp(v: Vector2, min: Vector2, max: Vector2): Vector2;
        cross(a: Vector2, b: Vector2): number;
        distance(a: Vector2, b: Vector2): number;
        dot(a: Vector2, b: Vector2): number;
        eq(v: Vector2, other: Vector2, epsilon: 0): boolean;
        fromAngle(angle: number, len?: number): Vector2;
        fromPolar(r: number, angle: number): Vector2;
        length(v: Vector2): number;
        lengthSq(v: Vector2): number;
        lerp(a: Vector2, b: Vector2, t: number): Vector2;
        normalize(v: Vector2): Vector2;
        rotate(v: Vector2, angle: number): Vector2;
        toPolar(v: Vector2): { angle: number; r: number };
        zero(): Vector2;
    } = ...

    The full library of Vector2 functions.

    Type Declaration

    • add: (a: Pair<number>, b: number | Pair<number>) => Pair<number>
    • ceil: (a: Pair<number>) => Pair<number>
    • div: (a: Pair<number>, b: number | Pair<number>) => Pair<number>
    • floor: (a: Pair<number>) => Pair<number>
    • map: <I, O>(op: (a: I) => O) => (a: Pair<I>) => Pair<O>

      Turn a unary function into a pair-wise unary function.

      A function that takes one arg and returns something.

      A function that takes a pair such as [number, number] (Vector2) and transforms it with op.

    • map2: <I, O>(op: (a: I, b: I) => O) => (a: Pair<I>, b: I | Pair<I>) => Pair<O>

      Turn a binary function into a pair-wise binary function, for example one that operates on two Vector2s.

      A function that takes two values and calculates one.

      A function that runs op pair-wise on both arguments, constructing a new pair.

    • max: (a: Pair<number>, b: number | Pair<number>) => Pair<number>

      Returns the maximum of two coordinates, i.e. the lower right corner of a bounding box containing them.

    • min: (a: Pair<number>, b: number | Pair<number>) => Pair<number>

      Returns the minimum of two coordinates, i.e. the upper left corner of a bounding box containing them.

    • mod: (a: Pair<number>, b: number | Pair<number>) => Pair<number>

      Apply a true modulus (i.e. where -1 % 3 == 2) to a Vector2.

      For JS-style modulus (who wants that?) use Vec2.map2((a,b) => a % b)

    • mul: (a: Pair<number>, b: number | Pair<number>) => Pair<number>
    • negate: (a: Pair<number>) => Pair<number>
    • round: (a: Pair<number>) => Pair<number>
    • sub: (a: Pair<number>, b: number | Pair<number>) => Pair<number>
    • angle: function
    • clamp: function
    • cross: function
    • distance: function
    • dot: function
    • eq: function
      • Apply deep (not referential) equality to a pair of Vec2s.

        Parameters

        • v: Vector2
        • other: Vector2
        • epsilon: 0

          Tolerance factor for inexact matches.

        Returns boolean

    • fromAngle: function
    • fromPolar: function
    • length: function
    • lengthSq: function
    • lerp: function
    • normalize: function
    • rotate: function
    • toPolar: function
    • zero: function