Coordinate class

A screen position, measured in rows and columns from the top-left origin of the screen. Coordinates are zero-based, and converted as necessary for the underlying system representation (e.g. one-based for VT-style displays).

Note on coordinate ordering: This class uses row-first ordering, which is conventional for terminal operations. The constructor takes (row, col), where:

  • row is the vertical position (0 = top of screen)
  • col is the horizontal position (0 = left of screen)

This differs from the parent Point class which uses (x, y) where x is horizontal. Here, row maps to Point.x and col maps to Point.y for internal storage, but you should use row and col getters for clarity.

Example:

final pos = Coordinate(5, 10); // Row 5, Column 10
print(pos.row); // 5
print(pos.col); // 10
Inheritance

Constructors

Coordinate(int row, int col)
Creates a coordinate with the given row and col.
const

Properties

col → int
The horizontal position (column number), zero-based from the left.
no setter
hashCode → int
The hash code for this object.
no setterinherited
magnitude → double
Get the straight line (Euclidean) distance between the origin (0, 0) and this point.
no setterinherited
row → int
The vertical position (row number), zero-based from the top.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
x → int
finalinherited
y → int
finalinherited

Methods

distanceTo(Point<int> other) → double
Returns the distance between this and other.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
squaredDistanceTo(Point<int> other) → int
Returns the squared distance between this and other.
inherited
toString() → String
A string representation of this object.
override

Operators

operator *(num factor) → Point<int>
Scale this point by factor as if it were a vector.
inherited
operator +(Point<int> other) → Point<int>
Add other to this, as if both points were vectors.
inherited
operator -(Point<int> other) → Point<int>
Subtract other from this, as if both points were vectors.
inherited
operator ==(Object other) → bool
Whether other is a point with the same coordinates as this point.
inherited