Struct RectangleF
- Namespace
 - Stride.Core.Mathematics
 
- Assembly
 - Stride.Core.Mathematics.dll
 
Define a RectangleF.
[DataContract("RectangleF")]
[DataStyle(DataStyle.Compact)]
public struct RectangleF : IEquatable<RectangleF>, ISpanFormattable, IFormattable
  - Implements
 
Constructors
RectangleF(float, float, float, float)
Initializes a new instance of the RectangleF struct.
public RectangleF(float x, float y, float width, float height)
  Parameters
Fields
Empty
An empty rectangle
public static readonly RectangleF Empty
  Field Value
Height
Gets or sets the height.
[DataMember(3)]
public float Height
  Field Value
- float
 The height.
Width
Gets or sets the width.
[DataMember(2)]
public float Width
  Field Value
- float
 The width.
X
Gets or sets the X position.
[DataMember(0)]
public float X
  Field Value
- float
 The X position.
Y
Gets or sets the Y position.
[DataMember(1)]
public float Y
  Field Value
- float
 The Y position.
Properties
Bottom
Gets the bottom.
public readonly float Bottom { get; }
  Property Value
- float
 The bottom.
BottomLeft
Gets the position of the bottom-left corner of the rectangle.
public readonly Vector2 BottomLeft { get; }
  Property Value
- Vector2
 The bottom-left corner of the rectangle.
BottomRight
Gets the position of the bottom-right corner of the rectangle.
public readonly Vector2 BottomRight { get; }
  Property Value
- Vector2
 The bottom-right corner of the rectangle.
Center
Gets the Point that specifies the center of the rectangle.
public readonly Vector2 Center { get; }
  Property Value
- Vector2
 The center.
IsEmpty
Gets a value that indicates whether the rectangle is empty.
public readonly bool IsEmpty { get; }
  Property Value
- bool
 trueif [is empty]; otherwise,false.
Left
Gets or sets the X position of the left edge.
public float Left { readonly get; set; }
  Property Value
- float
 The left.
Location
Gets or sets the location.
public Vector2 Location { readonly get; set; }
  Property Value
- Vector2
 The location.
Right
Gets the right.
public readonly float Right { get; }
  Property Value
- float
 The right.
Size
Gets or sets the size of the rectangle.
public Size2F Size { readonly get; set; }
  Property Value
- Size2F
 The size of the rectangle.
Top
Gets or sets the top.
public float Top { readonly get; set; }
  Property Value
- float
 The top.
TopLeft
Gets the position of the top-left corner of the rectangle.
public readonly Vector2 TopLeft { get; }
  Property Value
- Vector2
 The top-left corner of the rectangle.
TopRight
Gets the position of the top-right corner of the rectangle.
public readonly Vector2 TopRight { get; }
  Property Value
- Vector2
 The top-right corner of the rectangle.
Methods
Contains(Int2)
public readonly bool Contains(Int2 int2)
  Parameters
Returns
Contains(Point)
Checks, if specified Point is inside RectangleF.
public readonly bool Contains(Point point)
  Parameters
Returns
- bool
 trueif Point is inside RectangleF, otherwisefalse.
Contains(Rectangle)
Determines whether this rectangle entirely contains a specified rectangle.
public readonly bool Contains(Rectangle value)
  Parameters
valueRectangleThe rectangle to evaluate.
Returns
Contains(ref readonly RectangleF, out bool)
Determines whether this rectangle entirely contains a specified rectangle.
public readonly void Contains(ref readonly RectangleF value, out bool result)
  Parameters
valueRectangleFThe rectangle to evaluate.
resultbool[OutAttribute] On exit, is true if this rectangle entirely contains the specified rectangle, or false if not.
Contains(Vector2)
Checks, if specified Vector2 is inside RectangleF.
public readonly bool Contains(Vector2 vector2D)
  Parameters
Returns
- bool
 trueif Vector2 is inside RectangleF, otherwisefalse.
Contains(ref readonly Vector2, out bool)
Determines whether this rectangle contains a specified Point.
public readonly void Contains(ref readonly Vector2 value, out bool result)
  Parameters
valueVector2The Point to evaluate.
resultbool[OutAttribute] true if the specified Point is contained within this rectangle; false otherwise.
Contains(float, float)
Checks, if specified point is inside RectangleF.
public readonly bool Contains(float x, float y)
  Parameters
Returns
- bool
 trueif point is inside RectangleF, otherwisefalse.
Equals(RectangleF)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(RectangleF other)
  Parameters
otherRectangleFAn object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to this instance.
public override readonly bool Equals(object? obj)
  Parameters
objobjectThe object to compare with this instance.
Returns
- bool
 trueif the specified object is equal to this instance; otherwise,false.
GetHashCode()
Returns a hash code for this instance.
public override readonly int GetHashCode()
  Returns
- int
 A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Inflate(float, float)
Pushes the edges of the rectangle out by the horizontal and vertical values specified.
public void Inflate(float horizontalAmount, float verticalAmount)
  Parameters
horizontalAmountfloatValue to push the sides out by.
verticalAmountfloatValue to push the top and bottom out by.
Intersect(RectangleF, RectangleF)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
public static RectangleF Intersect(RectangleF value1, RectangleF value2)
  Parameters
value1RectangleFThe first Rectangle to compare.
value2RectangleFThe second Rectangle to compare.
Returns
- RectangleF
 The intersection rectangle.
Intersect(ref readonly RectangleF, ref readonly RectangleF, out RectangleF)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
public static void Intersect(ref readonly RectangleF value1, ref readonly RectangleF value2, out RectangleF result)
  Parameters
value1RectangleFThe first rectangle to compare.
value2RectangleFThe second rectangle to compare.
resultRectangleF[OutAttribute] The area where the two first parameters overlap.
Intersects(RectangleF)
Determines whether a specified rectangle intersects with this rectangle.
public readonly bool Intersects(RectangleF value)
  Parameters
valueRectangleFThe rectangle to evaluate.
Returns
Intersects(ref readonly RectangleF, out bool)
Determines whether a specified rectangle intersects with this rectangle.
public readonly void Intersects(ref readonly RectangleF value, out bool result)
  Parameters
valueRectangleFThe rectangle to evaluate
resultbool[OutAttribute] true if the specified rectangle intersects with this one; false otherwise.
Offset(Point)
Changes the position of the rectangle.
public void Offset(Point amount)
  Parameters
amountPointThe values to adjust the position of the rectangle by.
Offset(Vector2)
Changes the position of the rectangle.
public void Offset(Vector2 amount)
  Parameters
amountVector2The values to adjust the position of the rectangle by.
Offset(float, float)
Changes the position of the rectangle.
public void Offset(float offsetX, float offsetY)
  Parameters
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
  Returns
- string
 The fully qualified type name.
ToString(string?, IFormatProvider?)
Returns a string that represents this instance.
public readonly string ToString(string? format, IFormatProvider? formatProvider)
  Parameters
formatstringThe format.
formatProviderIFormatProviderThe format provider.
Returns
Union(RectangleF, RectangleF)
Creates a new rectangle that exactly contains two other rectangles.
public static RectangleF Union(RectangleF value1, RectangleF value2)
  Parameters
value1RectangleFThe first rectangle to contain.
value2RectangleFThe second rectangle to contain.
Returns
- RectangleF
 The union rectangle.
Union(ref readonly RectangleF, ref readonly RectangleF, out RectangleF)
Creates a new rectangle that exactly contains two other rectangles.
public static void Union(ref readonly RectangleF value1, ref readonly RectangleF value2, out RectangleF result)
  Parameters
value1RectangleFThe first rectangle to contain.
value2RectangleFThe second rectangle to contain.
resultRectangleF[OutAttribute] The rectangle that must be the union of the first two rectangles.
Operators
operator ==(RectangleF, RectangleF)
Implements the operator ==.
public static bool operator ==(RectangleF left, RectangleF right)
  Parameters
leftRectangleFThe left.
rightRectangleFThe right.
Returns
- bool
 The result of the operator.
explicit operator Rectangle(RectangleF)
Performs an explicit conversion to Rectangle structure.
public static explicit operator Rectangle(RectangleF value)
  Parameters
valueRectangleFThe source RectangleF value.
Returns
Remarks
Performs direct float to int conversion, any fractional data is truncated.
operator !=(RectangleF, RectangleF)
Implements the operator !=.
public static bool operator !=(RectangleF left, RectangleF right)
  Parameters
leftRectangleFThe left.
rightRectangleFThe right.
Returns
- bool
 The result of the operator.