Vec class

A two-dimensional point with integer coordinates.

Mixed in types

Constructors

Vec(int x, int y)
const

Properties

area int
Gets the area of a Rect whose corners are (0, 0) and this Vec.
no setterinherited
cardinalNeighbors List<Vec>
The four Vecs surrounding this one to the north, south, east, and west.
no setterinherited
hashCode int
The hash code for this object.
no setteroverride
intercardinalNeighbors List<Vec>
The four Vecs surrounding this one to the northeast, southeast, southwest, and northwest.
no setterinherited
kingLength int
Gets the king length of the Vec, which is the number of squares a king on a chessboard would need to move from (0, 0) to reach the endpoint of the Vec. Also known as Chebyshev distance.
no setterinherited
length num
The Cartesian length of the vector.
no setterinherited
lengthSquared int
no setterinherited
nearestDirection Direction
The Direction that most closely approximates the angle of this Vec.
no setterinherited
neighbors List<Vec>
The eight Vecs surrounding this one to the north, south, east, and west and points in between.
no setterinherited
rookLength int
Gets the rook length of the Vec, which is the number of squares a rook on a chessboard would need to move from (0, 0) to reach the endpoint of the Vec. Also known as Manhattan or taxicab distance.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
x int
final
y int
final

Methods

abs() Vec
Returns a new Vec with the absolute value of the coordinates of this one.
inherited
contains(Vec pos) bool
Returns true if pos is within a rectangle from (0,0) to this vector (half-inclusive).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
offset(int x, int y) Vec
Returns a new Vec whose coordinates are this one's translated by x and y.
inherited
offsetX(int x) Vec
Returns a new Vec whose coordinates are this one's but with the X coordinate translated by x.
inherited
offsetY(int y) Vec
Returns a new Vec whose coordinates are this one's but with the Y coordinate translated by y.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator *(int other) Vec
Scales this Vec by other.
inherited
operator +(Object other) Vec
Adds other to this Vec.
inherited
operator -(Object other) Vec
Substracts other from this Vec.
inherited
operator <(Object other) bool
Returns true if the magnitude of this vector is less than other.
inherited
operator <=(Object other) bool
Returns true if the magnitude of this vector is less than or equal to other.
inherited
operator ==(Object other) bool
The equality operator.
override
operator >(Object other) bool
Returns true if the magnitude of this vector is greater than other.
inherited
operator >=(Object other) bool
Returns true if the magnitude of this vector is greater than or equal to other.
inherited
operator ~/(int other) Vec
Scales this Vec by other.
inherited

Constants

zero → const Vec