Struct FontRectangle
Stores a set of four single precision floating points that represent the location and size of a rectangle.
public readonly struct FontRectangle : IEquatable<FontRectangle>
- Implements
- Inherited Members
Constructors
FontRectangle(Vector2, Vector2)
Initializes a new instance of the FontRectangle struct.
public FontRectangle(Vector2 point, Vector2 size)
Parameters
pointVector2The Vector2 which specifies the rectangles point in a two-dimensional plane.
sizeVector2The Vector2 which specifies the rectangles height and width.
FontRectangle(float, float, float, float)
Initializes a new instance of the FontRectangle struct.
public FontRectangle(float x, float y, float width, float height)
Parameters
xfloatThe horizontal position of the rectangle.
yfloatThe vertical position of the rectangle.
widthfloatThe width of the rectangle.
heightfloatThe height of the rectangle.
Fields
Empty
Represents a FontRectangle that has X, Y, Width, and Height values set to zero.
public static readonly FontRectangle Empty
Field Value
Properties
Bottom
Gets the y-coordinate of the bottom edge of this FontRectangle.
public float Bottom { get; }
Property Value
Height
Gets the height of this FontRectangle.
public float Height { get; }
Property Value
Left
Gets the x-coordinate of the left edge of this FontRectangle.
public float Left { get; }
Property Value
Right
Gets the x-coordinate of the right edge of this FontRectangle.
public float Right { get; }
Property Value
Top
Gets the y-coordinate of the top edge of this FontRectangle.
public float Top { get; }
Property Value
Width
Gets the width of this FontRectangle.
public float Width { get; }
Property Value
X
Gets the x-coordinate of this FontRectangle.
public float X { get; }
Property Value
Y
Gets the y-coordinate of this FontRectangle.
public float Y { get; }
Property Value
Methods
Center(in FontRectangle)
Returns the center point of the given FontRectangle.
public static Vector2 Center(in FontRectangle rectangle)
Parameters
rectangleFontRectangleThe rectangle.
Returns
Contains(in FontRectangle)
Determines if the rectangular region represented by rectangle is entirely contained
within the rectangular region represented by this FontRectangle .
public bool Contains(in FontRectangle rectangle)
Parameters
rectangleFontRectangleThe rectangle.
Returns
Contains(Vector2)
Determines if the specified point is contained within the rectangular region defined by this FontRectangle .
public bool Contains(Vector2 point)
Parameters
pointVector2The point.
Returns
Contains(float, float)
Determines if the specified point is contained within the rectangular region defined by this FontRectangle.
public bool Contains(float x, float y)
Parameters
Returns
Deconstruct(out float, out float, out float, out float)
Deconstructs this rectangle into four floats.
public void Deconstruct(out float x, out float y, out float width, out float height)
Parameters
xfloatThe out value for X.
yfloatThe out value for Y.
widthfloatThe out value for the width.
heightfloatThe out value for the height.
Equals(FontRectangle)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(FontRectangle other)
Parameters
otherFontRectangleAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
FromLTRB(float, float, float, float)
Creates a new FontRectangle with the specified location and size.
public static FontRectangle FromLTRB(float left, float top, float right, float bottom)
Parameters
leftfloatThe left coordinate of the rectangle.
topfloatThe top coordinate of the rectangle.
rightfloatThe right coordinate of the rectangle.
bottomfloatThe bottom coordinate of the rectangle.
Returns
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.
Inflate(in FontRectangle, float, float)
Creates a new FontRectangle from the given rectangle
that is inflated by the specified amount.
public static FontRectangle Inflate(in FontRectangle rectangle, float x, float y)
Parameters
rectangleFontRectangleThe rectangle.
xfloatThe amount to inflate the width by.
yfloatThe amount to inflate the height by.
Returns
- FontRectangle
A new FontRectangle.
Inflate(Vector2)
Creates a new FontRectangle inflated by the specified amount.
public FontRectangle Inflate(Vector2 size)
Parameters
sizeVector2The size.
Returns
- FontRectangle
New FontRectangle representing the inflated rectangle
Inflate(float, float)
Creates a new FontRectangle inflated by the specified amount.
public FontRectangle Inflate(float width, float height)
Parameters
Returns
- FontRectangle
New FontRectangle representing the inflated rectangle
Intersect(in FontRectangle)
Creates a FontRectangle that represents the intersection between this FontRectangle and the rectangle.
public FontRectangle Intersect(in FontRectangle rectangle)
Parameters
rectangleFontRectangleThe rectangle.
Returns
- FontRectangle
New FontRectangle representing the intersections between the two rectangles.
Intersect(in FontRectangle, in FontRectangle)
Creates a rectangle that represents the intersection between a and
b. If there is no intersection, an empty rectangle is returned.
public static FontRectangle Intersect(in FontRectangle a, in FontRectangle b)
Parameters
aFontRectangleThe first rectangle.
bFontRectangleThe second rectangle.
Returns
IntersectsWith(in FontRectangle)
Determines if the specified FontRectangle intersects the rectangular region defined by this FontRectangle.
public bool IntersectsWith(in FontRectangle rectangle)
Parameters
rectangleFontRectangleThe other rectangle.
Returns
Offset(Vector2)
Adjusts the location of this rectangle by the specified amount.
public FontRectangle Offset(Vector2 point)
Parameters
pointVector2The point.
Returns
- FontRectangle
New FontRectangle representing the offset rectangle.
Offset(float, float)
Adjusts the location of this rectangle by the specified amount.
public FontRectangle Offset(float dx, float dy)
Parameters
Returns
- FontRectangle
New FontRectangle representing the inflated rectangle.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Transform(in FontRectangle, Matrix3x2)
Creates a new FontRectangle by transforming the given rectangle by the given matrix.
public static FontRectangle Transform(in FontRectangle rectangle, Matrix3x2 matrix)
Parameters
rectangleFontRectangleThe source rectangle.
matrixMatrix3x2The transformation matrix.
Returns
- FontRectangle
A transformed FontRectangle.
Union(in FontRectangle, in FontRectangle)
Creates a rectangle that represents the union between a and b.
public static FontRectangle Union(in FontRectangle a, in FontRectangle b)
Parameters
aFontRectangleThe first rectangle.
bFontRectangleThe second rectangle.
Returns
Operators
operator ==(in FontRectangle, in FontRectangle)
Compares two FontRectangle objects for equality.
public static bool operator ==(in FontRectangle left, in FontRectangle right)
Parameters
leftFontRectangleThe FontRectangle on the left side of the operand.
rightFontRectangleThe FontRectangle on the right side of the operand.
Returns
- bool
True if the current left is equal to the
rightparameter; otherwise, false.
operator !=(in FontRectangle, in FontRectangle)
Compares two FontRectangle objects for inequality.
public static bool operator !=(in FontRectangle left, in FontRectangle right)
Parameters
leftFontRectangleThe FontRectangle on the left side of the operand.
rightFontRectangleThe FontRectangle on the right side of the operand.
Returns
- bool
True if the current left is unequal to the
rightparameter; otherwise, false.