[TypeConverter(PointConverterInternal)] public struct Point : IEquatable<Point>
A struct representing X and Y co-ordinates as integer values
Remarks: The point struct is used for drawing and positioning of elements and widgets

Constructors

Point

#
public Point(int x, int y)
Initializes a new instance of a Point class with specified x and y values
x (int)Initial X value for the point
y (int)Initial Y value for the point

Point

#
public Point(PointF point)
Initializes a new instance of a Point class with truncated values of the specified floating-point point
point (PointF)PointF to initialize the X and Y values of the new instance with

Point

#
public Point(Size size)
Initializes a new instance of a Point class with X and Y values corresponding to the Size.Width and Size.Height values of the specified size, respecitively
size (Size)Size to initialize the X and Y values of the new instance with

Fields

Empty

#
public static readonly Point Empty
Gets an empty point with an X and Y value of zero

Properties

IsZero

#
public bool IsZero { get; }
Gets a value indicating that both the X and Y co-ordinates of this point are zero

Length

#
public float Length { get; }
Gets the length of the point as a vector from origin 0,0

LengthSquared

#
public int LengthSquared { get; }
Gets the squared length of the point as a vector from origin 0,0.

Normal

#
public Point Normal { get; }
Gets the point as a normal vector (perpendicular) to the current point from the origin

UnitVector

#
public PointF UnitVector { get; }
Gets the current point as a unit vector (a point with a Length of 1.0 from origin 0,0)
The unit vector equivalent of this point's X and Y coordinates

Methods

Abs

#
public static Point Abs(Point point)
Returns the absolute X and Y components of the specified point
point (Point)Point with positive or negative X and/or Y values
A new point with absolute (positive) X and Y values of the specified point

Distance

#
public float Distance(Point point)
Gets the distance between this point and the specified point

Distance

#
public static float Distance(Point point1, Point point2)
Gets the distance between two points using pythagoras theorem
point1 (Point)First point to calculate the distance from
point2 (Point)Second point to calculate the distance to
The distance between the two points

DotProduct

#
public int DotProduct(Point point)
Gets the dot product of this instance and the specified point
point (Point)Point to get the dot product for
The dot product (X * point.X + Y * point.Y) between this point and the specified point

DotProduct

#
public static int DotProduct(Point point1, Point point2)
Gets the dot product between two points
point1 (Point)First point to get the dot product
point2 (Point)Second point to get the dot product
The dot product (point1.X * point2.X + poin1.Y * point2.Y) between the two points

Equals

#
public override bool Equals(object obj)
Returns a value indicating that the specified obj is equal to this point
obj (object)Object to compare
True if the specified obj is a Point and is equal to this instance, false otherwise
ValueType.Equals

Equals

#
public bool Equals(Point other)
Returns a value indicating that the specified other point is equal to this point
other (Point)Other point to compare
True if the other point is equal to this point, otherwise false

GetHashCode

#
public override int GetHashCode()
Gets the hash code of this point

Max

#
public static Point Max(Point point1, Point point2)
Returns the maximum X and Y components of two points
point1 (Point)First point
point2 (Point)Second point
A new point with the maximum X and Y values of the two points

Min

#
public static Point Min(Point point1, Point point2)
Returns the minimum X and Y components of two points
point1 (Point)First point
point2 (Point)Second point
A new point with the minimum X and Y values of the two points

Offset

#
public static Point Offset(Point point, int x, int y)
Offsets the X and Y co-ordinates of the point by the specified x and y values
point (Point)Point to offset
x (int)Value to add to the X co-ordinate of this point
y (int)Value to add to the Y co-ordinate of this point
A new point with the offset X and Y values

Offset

#
public static Point Offset(Point point, Point offset)
Offsets the X and Y co-ordinates of the point by the values from the specified offset
point (Point)Point to offset
offset (Point)Point with X and Y values to add to this point
A new point offset by the specified value

Offset

#
public void Offset(int x, int y)
Offsets the X and Y co-ordinates of this point by the specified x and y values
x (int)Value to add to the X co-ordinate of this point
y (int)Value to add to the Y co-ordinate of this point

Offset

#
public void Offset(Point point)
Offsets the X and Y co-ordinates of this point by the values from the specified point

Restrict

#
public static Point Restrict(Point point, Rectangle rectangle)
Restricts the X and Y co-ordinates of the specified point within the rectangle
point (Point)Point to restrict
rectangle (Rectangle)Rectangle to restrict the point within
A new point that falls within the rectangle

Restrict

#
public void Restrict(Rectangle rectangle)
Restricts the X and Y co-ordinates within the specified rectangle
Remarks: This will update the X and Y co-ordinates to be within the specified rectangle's bounds. The updated co-ordinates will be the closest to the original value as possible. E.g. if the X co-ordinate is greater than the Rectangle.Right of the rectangle, it will be set to be Rectangle.Right minus one, to be within the rectangle's bounds.
rectangle (Rectangle)Rectangle to restrict the X and Y co-ordinates in

Round

#
public static Point Round(PointF point)
Rounds the X and Y components of the specified point to a Point
point (PointF)Floating point value to round
A new instance of a Point with rounded X and Y values of the specified point

ToString

#
public override string ToString()
Converts this point to a string

Truncate

#
public static Point Truncate(PointF point)
Truncates the X and Y components of the specified point to a Point
point (PointF)Floating point value to truncate
A new instance of a Point with truncated X and Y values of the specified point

UnitVectorAtAngle

#
public static PointF UnitVectorAtAngle(float angle)
Creates a unit vector PointF (a point with a Length of 1.0 from origin 0,0) with the specified angle, in degrees
angle (float)Angle in degrees of the unit vector
A new instance of a PointF with the x,y co-ordinates set at a distance of 1.0 from the origin

Operators

OperationResultDescription
Point+intPointOperator to add a value to both the X and Y co-ordinates of a point
Point+SizePointOperator to add a size to a point
Point+PointPointOperator to return the addition of two points as a Point
Point/intPointDivides the X and Y co-ordinates of the specified point with a given value
Point/SizePointDivides the specified point with a size
Point==PointboolDetermines equality between two points
Point!=PointboolDetermines the inequality between two points
int*PointPointMultiplies the X and Y co-ordinates of the specified point with a given factor
Point*intPointMultiplies the X and Y co-ordinates of the specified point with a given factor
Point*SizePointMultiplies the specified point with a size
Point*PointPointMultiplies the X and Y co-ordinates of the two specified point values
Point*floatPointFMultiplies the X and Y of a point by the specified floating point factor
Point-intPointOperator to subtract a value from both the X and Y co-ordinates of a point
Point-SizePointOperator to subtract a size from a point
Point-PointPointOperator to return the difference between two points as a Size
-PointPointReturns a new Point with negative x and y values of the specified point

Convertors

OperationResultDescription
explicitPointFPointExplicit conversion from a PointF to a Point by truncating values
explicitSizePointExplicit conversion from a size to a Point with a X and Y of the Width and Height values of the size, respectively