PointD Struct

Represents a position with sub-pixel precision. The origin is the top-left corner of the stored pixels; Y grows downward. Integer coordinates are pixel boundaries: the pixel (x, y) covers the square from (x, y) to (x + 1, y + 1).

public readonly struct PointD : IEquatable<PointD>
Implements

Constructors

NameDescription
PointD(double, double)Initializes a new instance of the PointD struct.

PointD(double, double)

PointD.cs

Initializes a new instance of the PointD struct.

public PointD(double x, double y)

Parameters

x double
The horizontal coordinate.
y double
The vertical coordinate.

Properties

NameDescription
EmptyGets the point whose coordinates are zero.
XGets the horizontal coordinate.
YGets the vertical coordinate.

Gets the point whose coordinates are zero.

public static PointD Empty { get; }

Property value

PointD

Gets the horizontal coordinate.

public double X { get; }

Property value

double

Gets the vertical coordinate.

public double Y { get; }

Property value

double

Methods

NameDescription
Add(PointD, PointD)Adds the coordinates of two points.
Deconstruct(double, double)Deconstructs the point into its coordinates.
DistanceTo(PointD)Gets the distance to another point.
Divide(PointD, double)Divides the coordinates of a point by a divisor.
Equals(PointD)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Indicates whether this instance and a specified object are equal.
FromPoint(Point)Converts a pixel coordinate to the position of the top-left corner of that pixel.
GetHashCode()Returns the hash code for this instance.
Multiply(PointD, double)Multiplies the coordinates of a point by a factor.
Negate(PointD)Negates the coordinates of a point.
Offset(double, double)Moves the point.
Subtract(PointD, PointD)Subtracts the coordinates of a point from those of another.
ToString()Returns the point formatted as ({X}, {Y}).

Add(PointD, PointD)

PointD.cs

Adds the coordinates of two points.

public static PointD Add(PointD left, PointD right)

Parameters

left PointD
The first point.
right PointD
The second point.

Returns

PointD The sum.

Deconstruct(double, double)

PointD.cs

Deconstructs the point into its coordinates.

public void Deconstruct(out double x, out double y)

Parameters

x double
The horizontal coordinate.
y double
The vertical coordinate.

DistanceTo(PointD)

PointD.cs

Gets the distance to another point.

public double DistanceTo(PointD other)

Parameters

other PointD
The other point.

Returns

double The length of the segment between both points.

Divide(PointD, double)

PointD.cs

Divides the coordinates of a point by a divisor.

public static PointD Divide(PointD left, double right)

Parameters

left PointD
The point.
right double
The divisor.

Returns

PointD The scaled point.

Equals overloads

Equals(PointD)

PointD.cs

Indicates whether the current object is equal to another object of the same type.

public bool Equals(PointD other)
Parameters
other PointD
An object to compare with this object.
Returns

bool true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

PointD.cs

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)
Parameters
obj object?
The object to compare with the current instance.
Returns

bool true if obj and this instance are the same type and represent the same value; otherwise, false.

FromPoint(Point)

PointD.cs

Converts a pixel coordinate to the position of the top-left corner of that pixel.

public static PointD FromPoint(Point point)

Parameters

point Point
The pixel coordinate.

Returns

PointD The position.

GetHashCode()

PointD.cs

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int A 32-bit signed integer that is the hash code for this instance.

Multiply(PointD, double)

PointD.cs

Multiplies the coordinates of a point by a factor.

public static PointD Multiply(PointD left, double right)

Parameters

left PointD
The point.
right double
The factor.

Returns

PointD The scaled point.

Negate(PointD)

PointD.cs

Negates the coordinates of a point.

public static PointD Negate(PointD value)

Parameters

value PointD
The point.

Returns

PointD The opposite point.

Offset(double, double)

PointD.cs

Moves the point.

public PointD Offset(double dx, double dy)

Parameters

dx double
The horizontal distance.
dy double
The vertical distance.

Returns

PointD The moved point.

Subtract(PointD, PointD)

PointD.cs

Subtracts the coordinates of a point from those of another.

public static PointD Subtract(PointD left, PointD right)

Parameters

left PointD
The point to subtract from.
right PointD
The point to subtract.

Returns

PointD The difference: the vector from right to left.

ToString()

PointD.cs

Returns the point formatted as ({X}, {Y}).

public override string ToString()

Returns

string A string representation of the point.

Operators

NameDescription
operator +(PointD, PointD)Adds the coordinates of two points.
operator /(PointD, double)Divides the coordinates of a point by a divisor.
operator ==(PointD, PointD)Compares two points for equality.
implicit operator PointD(Point)Converts a pixel coordinate to the position of the top-left corner of that pixel. The conversion is lossless.
operator !=(PointD, PointD)Compares two points for inequality.
operator *(PointD, double)Multiplies the coordinates of a point by a factor.
operator *(double, PointD)Multiplies the coordinates of a point by a factor.
operator -(PointD, PointD)Subtracts the coordinates of a point from those of another.
operator -(PointD)Negates the coordinates of a point.

operator +(PointD, PointD)

PointD.cs

Adds the coordinates of two points.

public static PointD operator +(PointD left, PointD right)

Parameters

left PointD
The first point.
right PointD
The second point.

Returns

PointD The sum.

operator /(PointD, double)

PointD.cs

Divides the coordinates of a point by a divisor.

public static PointD operator /(PointD left, double right)

Parameters

left PointD
The point.
right double
The divisor.

Returns

PointD The scaled point.

operator ==(PointD, PointD)

PointD.cs

Compares two points for equality.

public static bool operator ==(PointD left, PointD right)

Parameters

left PointD
The first point.
right PointD
The second point.

Returns

bool true if both points are equal; otherwise false.

implicit operator PointD(Point)

PointD.cs

Converts a pixel coordinate to the position of the top-left corner of that pixel. The conversion is lossless.

public static implicit operator PointD(Point point)

Parameters

point Point
The pixel coordinate.

Returns

PointD

operator !=(PointD, PointD)

PointD.cs

Compares two points for inequality.

public static bool operator !=(PointD left, PointD right)

Parameters

left PointD
The first point.
right PointD
The second point.

Returns

bool true if the points differ; otherwise false.

op_Multiply overloads

operator *(PointD, double)

PointD.cs

Multiplies the coordinates of a point by a factor.

public static PointD operator *(PointD left, double right)
Parameters
left PointD
The point.
right double
The factor.
Returns

PointD The scaled point.

operator *(double, PointD)

PointD.cs

Multiplies the coordinates of a point by a factor.

public static PointD operator *(double left, PointD right)
Parameters
left double
The factor.
right PointD
The point.
Returns

PointD The scaled point.

operator -(PointD, PointD)

PointD.cs

Subtracts the coordinates of a point from those of another.

public static PointD operator -(PointD left, PointD right)

Parameters

left PointD
The point to subtract from.
right PointD
The point to subtract.

Returns

PointD The difference: the vector from right to left.

operator -(PointD)

PointD.cs

Negates the coordinates of a point.

public static PointD operator -(PointD value)

Parameters

value PointD
The point.

Returns

PointD The opposite point.