Struct Rect
Represents a rectangle defined by its left, bottom, right, and top coordinates.
public readonly struct Rect
- Inherited Members
Examples
Rect r = new Rect(20, 30, 150, 100);
Constructors
Rect(double, double, double, double)
Initializes a new instance of the Rect struct.
public Rect(double left, double bottom, double right, double top)
Parameters
left
doubleThe left coordinate of the rectangle in points.
bottom
doubleThe bottom coordinate of the rectangle in points.
right
doubleThe right coordinate of the rectangle in points.
top
doubleThe top coordinate of the rectangle in points.
Properties
Bottom
Gets the bottom coordinate of the rectangle in points.
public double Bottom { get; }
Property Value
- double
The bottom coordinate in points.
BottomMM
Gets the bottom coordinate of the rectangle in millimeters.
public double BottomMM { get; }
Property Value
- double
The bottom coordinate in millimeters.
Height
Gets the height of the rectangle in points.
public double Height { get; }
Property Value
- double
The height in points.
HeightMM
Gets the height of the rectangle in millimeters.
public double HeightMM { get; }
Property Value
- double
The height in millimeters.
Left
Gets the left coordinate of the rectangle in points.
public double Left { get; }
Property Value
- double
The left coordinate in points.
LeftMM
Gets the left coordinate of the rectangle in millimeters.
public double LeftMM { get; }
Property Value
- double
The left coordinate in millimeters.
Right
Gets the right coordinate of the rectangle in points.
public double Right { get; }
Property Value
- double
The right coordinate in points.
RightMM
Gets the right coordinate of the rectangle in millimeters.
public double RightMM { get; }
Property Value
- double
The right coordinate in millimeters.
Top
Gets the top coordinate of the rectangle in points.
public double Top { get; }
Property Value
- double
The top coordinate in points.
TopMM
Gets the top coordinate of the rectangle in millimeters.
public double TopMM { get; }
Property Value
- double
The top coordinate in millimeters.
Width
Gets the width of the rectangle in points.
public double Width { get; }
Property Value
- double
The width in points.
WidthMM
Gets the width of the rectangle in millimeters.
public double WidthMM { get; }
Property Value
- double
The width in millimeters.
Methods
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe 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.
GetHashCode()
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.
Move(double, double)
Moves the rectangle by the specified amount in the x and y directions.
public Rect Move(double x, double y)
Parameters
x
doubleThe amount to move the rectangle in the x direction.
y
doubleThe amount to move the rectangle in the y direction.
Returns
ToString()
Returns a string representation of this rectangle.
public override string ToString()
Returns
- string
A string that represents this rectangle.
Operators
operator ==(Rect, Rect)
Determines whether two rectangles are equal.
public static bool operator ==(Rect left, Rect right)
Parameters
Returns
operator !=(Rect, Rect)
Determines whether two rectangles are not equal.
public static bool operator !=(Rect left, Rect right)