Struct Point
An X and Y position, as whole numbers.
public struct Point : IEquatable<Point>
- Implements
- Inherited Members
Constructors
Point(Point)
Creates a copy of point.
public Point(Point point)
Parameters
pointPoint
Point(int, int)
Creates a point at (x, y).
public Point(int x, int y)
Parameters
Point((int x, int y))
Creates a point from a tuple.
public Point((int x, int y) tuple)
Parameters
Fields
Down
The point (0, 1), one step down.
public static readonly Point Down
Field Value
Empty
The point (0, 0), the same as Zero.
public static readonly Point Empty
Field Value
Left
The point (-1, 0), one step left.
public static readonly Point Left
Field Value
One
The point (1, 1).
public static readonly Point One
Field Value
Right
The point (1, 0), one step right.
public static readonly Point Right
Field Value
Up
The point (0, -1). Y grows downwards, so this is one step up.
public static readonly Point Up
Field Value
Zero
The origin, (0, 0).
public static readonly Point Zero
Field Value
Properties
X
The horizontal coordinate.
public int X { readonly get; set; }
Property Value
Y
The vertical coordinate.
public int Y { readonly get; set; }
Property Value
Methods
Equals(Point)
Whether other has the same coordinates.
public readonly bool Equals(Point other)
Parameters
otherPoint
Returns
Equals(object)
Whether obj is a Point with the same coordinates.
public override readonly bool Equals(object obj)
Parameters
objobject
Returns
GetHashCode()
Returns a hash code based on the coordinates, consistent with Equals(object).
public override readonly int GetHashCode()
Returns
ToString()
Returns the point as (X, Y).
public override string ToString()
Returns
Operators
operator +(Point, Point)
Adds the coordinates of the two points.
public static Point operator +(Point left, Point right)
Parameters
Returns
operator ==(Point, Point)
Whether the two points have the same coordinates.
public static bool operator ==(Point left, Point right)
Parameters
Returns
implicit operator Vector2(Point)
Converts to a Vector2 with the same coordinates.
public static implicit operator Vector2(Point point)
Parameters
pointPoint
Returns
implicit operator (double x, double y)(Point)
Converts a point to a tuple.
public static implicit operator (double x, double y)(Point point)
Parameters
pointPoint
Returns
implicit operator (int x, int y)(Point)
Converts a point to a tuple.
public static implicit operator (int x, int y)(Point point)
Parameters
pointPoint
Returns
implicit operator (long x, long y)(Point)
Converts a point to a tuple.
public static implicit operator (long x, long y)(Point point)
Parameters
pointPoint
Returns
implicit operator (float x, float y)(Point)
Converts a point to a tuple.
public static implicit operator (float x, float y)(Point point)
Parameters
pointPoint
Returns
implicit operator Point(Vector2)
Converts a vector to a point, truncating each coordinate toward zero.
public static implicit operator Point(Vector2 vector)
Parameters
vectorVector2
Returns
implicit operator Point((double x, double y))
Converts a tuple to a point, truncating each coordinate toward zero.
public static implicit operator Point((double x, double y) tuple)
Parameters
Returns
implicit operator Point((int x, int y))
Converts a tuple to a point.
public static implicit operator Point((int x, int y) tuple)
Parameters
Returns
implicit operator Point((long x, long y))
Converts a tuple to a point. Each coordinate is cast to int, so a value outside the int range wraps.
public static implicit operator Point((long x, long y) tuple)
Parameters
Returns
implicit operator Point((float x, float y))
Converts a tuple to a point, truncating each coordinate toward zero.
public static implicit operator Point((float x, float y) tuple)
Parameters
Returns
operator !=(Point, Point)
Whether the two points differ in either coordinate.
public static bool operator !=(Point left, Point right)
Parameters
Returns
operator -(Point, Point)
Subtracts the coordinates of right from those of left.
public static Point operator -(Point left, Point right)
Parameters
Returns
operator -(Point)
The point with both coordinates negated.
public static Point operator -(Point point)
Parameters
pointPoint