Struct RectangleF
- Namespace
- Stride.Core.Mathematics
- Assembly
- Stride.Core.Mathematics.dll
Define a RectangleF.
[DataContract("RectangleF")]
[DataStyle(DataStyle.Compact)]
public struct RectangleF : IEquatable<RectangleF>
- 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 float Bottom { get; }
Property Value
- float
The bottom.
BottomLeft
Gets the position of the bottom-left corner of the rectangle.
public 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 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 Vector2 Center { get; }
Property Value
- Vector2
The center.
IsEmpty
Gets a value that indicates whether the rectangle is empty.
public bool IsEmpty { get; }
Property Value
- bool
true
if [is empty]; otherwise,false
.
Left
Gets or sets the X position of the left edge.
public float Left { get; set; }
Property Value
- float
The left.
Location
Gets or sets the location.
public Vector2 Location { get; set; }
Property Value
- Vector2
The location.
Right
Gets the right.
public float Right { get; }
Property Value
- float
The right.
Size
Gets or sets the size of the rectangle.
public Size2F Size { get; set; }
Property Value
- Size2F
The size of the rectangle.
Top
Gets or sets the top.
public float Top { get; set; }
Property Value
- float
The top.
TopLeft
Gets the position of the top-left corner of the rectangle.
public 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 Vector2 TopRight { get; }
Property Value
- Vector2
The top-right corner of the rectangle.
Methods
Contains(Int2)
public bool Contains(Int2 int2)
Parameters
Returns
Contains(Point)
Checks, if specified Point is inside RectangleF.
public bool Contains(Point point)
Parameters
Returns
- bool
true
if Point is inside RectangleF, otherwisefalse
.
Contains(Rectangle)
Determines whether this rectangle entirely contains a specified rectangle.
public bool Contains(Rectangle value)
Parameters
value
RectangleThe rectangle to evaluate.
Returns
Contains(ref readonly RectangleF, out bool)
Determines whether this rectangle entirely contains a specified rectangle.
public void Contains(ref readonly RectangleF value, out bool result)
Parameters
value
RectangleFThe rectangle to evaluate.
result
bool[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 bool Contains(Vector2 vector2D)
Parameters
Returns
- bool
true
if Vector2 is inside RectangleF, otherwisefalse
.
Contains(ref readonly Vector2, out bool)
Determines whether this rectangle contains a specified Point.
public void Contains(ref readonly Vector2 value, out bool result)
Parameters
value
Vector2The Point to evaluate.
result
bool[OutAttribute] true if the specified Point is contained within this rectangle; false otherwise.
Contains(float, float)
Checks, if specified point is inside RectangleF.
public bool Contains(float x, float y)
Parameters
Returns
- bool
true
if point is inside RectangleF, otherwisefalse
.
Equals(RectangleF)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(RectangleF other)
Parameters
other
RectangleFAn object to compare with this object.
Returns
Equals(object)
Determines whether the specified object is equal to this instance.
public override bool Equals(object obj)
Parameters
Returns
GetHashCode()
Returns a hash code for this instance.
public override 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
horizontalAmount
floatValue to push the sides out by.
verticalAmount
floatValue 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
value1
RectangleFThe first Rectangle to compare.
value2
RectangleFThe 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
value1
RectangleFThe first rectangle to compare.
value2
RectangleFThe second rectangle to compare.
result
RectangleF[OutAttribute] The area where the two first parameters overlap.
Intersects(RectangleF)
Determines whether a specified rectangle intersects with this rectangle.
public bool Intersects(RectangleF value)
Parameters
value
RectangleFThe rectangle to evaluate.
Returns
Intersects(ref readonly RectangleF, out bool)
Determines whether a specified rectangle intersects with this rectangle.
public void Intersects(ref readonly RectangleF value, out bool result)
Parameters
value
RectangleFThe rectangle to evaluate
result
bool[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
amount
PointThe values to adjust the position of the rectangle by.
Offset(Vector2)
Changes the position of the rectangle.
public void Offset(Vector2 amount)
Parameters
amount
Vector2The 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 string ToString()
Returns
- string
The fully qualified type name.
Union(RectangleF, RectangleF)
Creates a new rectangle that exactly contains two other rectangles.
public static RectangleF Union(RectangleF value1, RectangleF value2)
Parameters
value1
RectangleFThe first rectangle to contain.
value2
RectangleFThe 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
value1
RectangleFThe first rectangle to contain.
value2
RectangleFThe second rectangle to contain.
result
RectangleF[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
left
RectangleFThe left.
right
RectangleFThe 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
value
RectangleFThe 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
left
RectangleFThe left.
right
RectangleFThe right.
Returns
- bool
The result of the operator.