Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

magnum.Vector2i class

Two-component signed integer vector

Static methods

def x_axis(length: int = 1) -> Vector2i
Vector in a direction of X axis (right)
def x_scale(scale: int) -> Vector2i
Scaling vector in a direction of X axis (width)
def y_axis(length: int = 1) -> Vector2i
Vector in a direction of Y axis (up)
def y_scale(scale: int) -> Vector2i
Scaling vector in a direction of Y axis (height)
def zero_init() -> Vector2i
Construct a zero vector

Methods

def dot(self, /) -> int
Dot product of the vector
def flipped(self, /) -> Vector2i
Flipped vector
def is_zero(self, /) -> bool
Whether the vector is zero
def max(self, /) -> int
Maximal value in the vector
def min(self, /) -> int
Minimal value in the vector
def minmax(self, /) -> typing.Tuple[int, int]
Minimal and maximal value in the vector
def perpendicular(self, /) -> Vector2i
Perpendicular vector
def product(self, /) -> int
Product of values in the vector
def sum(self, /) -> int
Sum of values in the vector

Special methods

def __add__(self, arg0: Vector2i, /) -> Vector2i
Add a vector
def __and__(self, arg0: Vector2i, /) -> Vector2i
Bitwise AND of two integral vectors
def __eq__(self, arg0: Vector2i, /) -> bool
Equality comparison
def __ge__(self, arg0: Vector2i, /) -> BoolVector2
Component-wise greater than or equal comparison
def __getattr__(self, arg0: str, /) -> object
Vector swizzle
def __getitem__(self, arg0: int, /) -> int
Value at given position
def __gt__(self, arg0: Vector2i, /) -> BoolVector2
Component-wise greater than comparison
def __iadd__(self, arg0: Vector2i, /) -> Vector2i
Add and assign a vector
def __iand__(self, arg0: Vector2i, /) -> Vector2i
Do bitwise AND of two integral vectors and assign
def __ilshift__(self, arg0: int, /) -> Vector2i
Do bitwise left shift of an integral vector and assign
def __imod__(self, arg0: int, /) -> Vector2i
Do modulo of an integral vector and assign
def __imod__(self, arg0: Vector2i, /) -> Vector2i
Do module of two integral vectors and assign
def __imul__(self, arg0: int, /) -> Vector2i
Multiply with a scalar and assign
def __imul__(self, arg0: Vector2i, /) -> Vector2i
Multiply a vector component-wise and assign
def __imul__(self, arg0: float, /) -> Vector2i
Multiply an integral vector with a floating-point number and assign
def __init__(self, arg0: Vector2ui, /) -> None
Construct from different underlying type
def __init__(self, arg0: Vector2, /) -> None
Construct from different underlying type
def __init__(self, arg0: Vector2d, /) -> None
Construct from different underlying type
def __init__(self, arg0: buffer, /) -> None
Construct from a buffer
def __init__(self, /) -> None
Default constructor
def __init__(self, arg0: int, /) -> None
Construct a vector with one value for all components
def __init__(self, arg0: int, arg1: int, /) -> None
Constructor
def __init__(self, arg0: typing.Tuple[int, int], /) -> None
Construct from a tuple
def __invert__(self, /) -> Vector2i
Bitwise NOT of an integral vector
def __ior__(self, arg0: Vector2i, /) -> Vector2i
Do bitwise OR of two integral vectors and assign
def __irshift__(self, arg0: int, /) -> Vector2i
Do bitwise right shift of an integral vector and assign
def __isub__(self, arg0: Vector2i, /) -> Vector2i
Subtract and assign a vector
def __itruediv__(self, arg0: int, /) -> Vector2i
Divide with a scalar and assign
def __itruediv__(self, arg0: Vector2i, /) -> Vector2i
Divide a vector component-wise and assign
def __itruediv__(self, arg0: float, /) -> Vector2i
Divide an integral vector with a floating-point number and assign
def __ixor__(self, arg0: Vector2i, /) -> Vector2i
Do bitwise XOR of two integral vectors and assign
def __le__(self, arg0: Vector2i, /) -> BoolVector2
Component-wise less than or equal comparison
def __len__() -> int
Vector size. Returns 2.
def __lshift__(self, arg0: int, /) -> Vector2i
Bitwise left shift of an integral vector
def __lt__(self, arg0: Vector2i, /) -> BoolVector2
Component-wise less than comparison
def __mod__(self, arg0: int, /) -> Vector2i
Modulo of an integral vector
def __mod__(self, arg0: Vector2i, /) -> Vector2i
Modulo of two integral vectors
def __mul__(self, arg0: int, /) -> Vector2i
Multiply with a scalar
def __mul__(self, arg0: Vector2i, /) -> Vector2i
Multiply a vector component-wise
def __mul__(self, arg0: float, /) -> Vector2i
Multiply an integral vector with a floating-point number
def __ne__(self, arg0: Vector2i, /) -> bool
Non-equality comparison
def __neg__(self, /) -> Vector2i
Negated vector
def __or__(self, arg0: Vector2i, /) -> Vector2i
Bitwise OR of two integral vectors
def __repr__(self, /) -> str
Object representation
def __rmul__(self, arg0: int, /) -> Vector2i
Multiply a scalar with a vector
def __rmul__(self, arg0: float, /) -> Vector2i
Multiply a floating-point number with an integral vector
def __rshift__(self, arg0: int, /) -> Vector2i
Bitwise right shift of an integral vector
def __rtruediv__(self, arg0: int, /) -> Vector2i
Divide a vector with a scalar and invert
def __setattr__(self, arg0: str, arg1: object, /) -> None
Vector swizzle
def __setitem__(self, arg0: int, arg1: int, /) -> None
Set a value at given position
def __sub__(self, arg0: Vector2i, /) -> Vector2i
Subtract a vector
def __truediv__(self, arg0: int, /) -> Vector2i
Divide with a scalar
def __truediv__(self, arg0: Vector2i, /) -> Vector2i
Divide a vector component-wise
def __truediv__(self, arg0: float, /) -> Vector2i
Divide an integral vector with a floating-point number
def __xor__(self, arg0: Vector2i, /) -> Vector2i
Bitwise XOR of two integral vectors

Properties

x: int get set
X component
y: int get set
Y component