Skip to content
FutureBlitz

    Install

    Import std.math.int_vector

    Vec2i

    std.math.int_vector

    struct

    Public Struct Vec2i Implements Numeric, Hashable, Printable, Defaultable

    A cell or step on a 2D grid.

    Examples

    Local a = Vec2i(1, 2)
    Local b = Vec2i(4, 6)
    Expect(a + b == Vec2i(5, 8))
    Expect(ManhattanDistance(a, b) == 7 && ChebyshevDistance(a, b) == 4)
    // Cells are Map keys.
    Local walls = {Vec2i(0, 0): True}
    Expect(walls.Contains(Vec2i(0, 0)) && !walls.Contains(a))

    std/math/int_vector.fb, line 36

    • Public Field x: Int field #

      Its x component.

    • Public Field y: Int field #

      Its y component.

    • Public Static Method Zero(): Vec2i static method #

      The zero vector, (0, 0).

    • Public Static Method One(): Vec2i static method #

      The vector (1, 1), which multiplying leaves alone.

    • Public Static Method DefaultValue(): Vec2i static method #

      The zero vector, (0, 0).

    • Public Method ToVec2(): Vec2 method #

      The components as Floats, rounded to the nearest one a Float holds.

    • Public Method ToString(): String method #

      Its components, as "(1, 2)".

    • @PanicsAtCaller Operator [](index: Int): Int operator #

      The component at the index: x at 0, and y at 1. Any other index panics.

    • @PanicsAtCaller Operator +(a: Vec2i, b: Vec2i): Vec2i operator #

      a plus b, component by component. Panics in a debug build when a component overflows, and wraps in a release one.

    • @PanicsAtCaller Operator -(a: Vec2i, b: Vec2i): Vec2i operator #

      a minus b, component by component. Panics in a debug build when a component overflows, and wraps in a release one.

    • @PanicsAtCaller Operator *(a: Vec2i, b: Vec2i): Vec2i operator #

      a times b, component by component. Panics in a debug build when a component overflows, and wraps in a release one.

    • @PanicsAtCaller Operator /(a: Vec2i, b: Vec2i): Vec2i operator #

      a divided by b, component by component. Each rounded toward 0. A component of 0 in b panics.

    • @PanicsAtCaller Operator *(a: Vec2i, scale: Int): Vec2i operator #

      a times scale.

    • @PanicsAtCaller Operator *(scale: Int, a: Vec2i): Vec2i operator #

      scale times a.

    • @PanicsAtCaller Operator /(a: Vec2i, scale: Int): Vec2i operator #

      a divided by scale.

    • @PanicsAtCaller Operator -(a: Vec2i): Vec2i operator #

      a negated.

    Report an issue with this page or with FutureBlitz on GitHub.