Struct Rectangle
- Namespace
- Stride.Core.Mathematics
- Assembly
- Stride.Core.Mathematics.dll
A rectangle structure defining X,Y,Width,Height.
[DataContract("Rectangle")]
[DataStyle(DataStyle.Compact)]
public struct Rectangle : IEquatable<Rectangle>
- Implements
Constructors
Rectangle(int, int, int, int)
Initializes a new instance of the Rectangle struct.
Parameters
Fields
Empty
An empty rectangle.
Field Value
Height
Gets or sets the height.
Field Value
- int
The height.
Width
Gets or sets the width.
Field Value
- int
The width.
X
Gets or sets the X position.
Field Value
- int
The X position.
Y
Gets or sets the Y position.
Field Value
- int
The Y position.
Properties
Bottom
Gets or sets the bottom.
Property Value
- int
The bottom.
BottomLeft
Gets the position of the bottom-left corner of the rectangle.
Property Value
- Point
The bottom-left corner of the rectangle.
BottomRight
Gets the position of the bottom-right corner of the rectangle.
Property Value
- Point
The bottom-right corner of the rectangle.
Center
Gets the Point that specifies the center of the rectangle.
Property Value
- Point
The center.
IsEmpty
Gets a value that indicates whether the rectangle is empty.
Property Value
- bool
true
if [is empty]; otherwise,false
.
Left
Gets or sets the left.
Property Value
- int
The left.
Location
Gets or sets the location.
Property Value
- Point
The location.
Right
Gets or sets the right.
Property Value
- int
The right.
Size
Gets or sets the size of the rectangle.
Property Value
- Size2
The size of the rectangle.
Top
Gets or sets the top.
Property Value
- int
The top.
TopLeft
Gets the position of the top-left corner of the rectangle.
Property Value
- Point
The top-left corner of the rectangle.
TopRight
Gets the position of the top-right corner of the rectangle.
Property Value
- Point
The top-right corner of the rectangle.
Methods
Contains(Int2)
Parameters
Returns
Contains(Point)
Determines whether this rectangle contains a specified Point.
Parameters
value
PointThe Point to evaluate.
Returns
Contains(ref Point, out bool)
Determines whether this rectangle contains a specified Point.
Parameters
value
PointThe Point to evaluate.
result
bool[OutAttribute] true if the specified Point is contained within this rectangle; false otherwise.
Contains(Rectangle)
Determines whether this rectangle entirely contains a specified rectangle.
Parameters
value
RectangleThe rectangle to evaluate.
Returns
Contains(ref Rectangle, out bool)
Determines whether this rectangle entirely contains a specified rectangle.
Parameters
value
RectangleThe rectangle to evaluate.
result
bool[OutAttribute] On exit, is true if this rectangle entirely contains the specified rectangle, or false if not.
Contains(Vector2)
Parameters
Returns
Contains(int, int)
Determines whether this rectangle contains a specified point represented by its x- and y-coordinates.
Parameters
Returns
Contains(float, float)
Checks, if specified point is inside Rectangle.
Parameters
Returns
Equals(Rectangle)
Determines whether the specified Rectangle is equal to this instance.
Parameters
Returns
Equals(object)
Determines whether the specified object is equal to this instance.
Parameters
Returns
GetHashCode()
Returns a hash code for this instance.
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Inflate(int, int)
Pushes the edges of the rectangle out by the horizontal and vertical values specified.
Parameters
horizontalAmount
intValue to push the sides out by.
verticalAmount
intValue to push the top and bottom out by.
Intersect(Rectangle, Rectangle)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
Parameters
Returns
- Rectangle
The intersection rectangle.
Intersect(ref Rectangle, ref Rectangle, out Rectangle)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
Parameters
value1
RectangleThe first rectangle to compare.
value2
RectangleThe second rectangle to compare.
result
Rectangle[OutAttribute] The area where the two first parameters overlap.
Intersects(Rectangle)
Determines whether a specified rectangle intersects with this rectangle.
Parameters
value
RectangleThe rectangle to evaluate.
Returns
Intersects(ref Rectangle, out bool)
Determines whether a specified rectangle intersects with this rectangle.
Parameters
value
RectangleThe 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.
Parameters
amount
PointThe values to adjust the position of the rectangle by.
Offset(int, int)
Changes the position of the rectangle.
Parameters
ToString()
Returns the fully qualified type name of this instance.
Returns
- string
The fully qualified type name.
Union(Rectangle, Int2)
Creates a new rectangle that incorporate the provided point to the given rectangle.
Parameters
Returns
- Rectangle
The union rectangle.
Union(Rectangle, Rectangle)
Creates a new rectangle that exactly contains two other rectangles.
Parameters
Returns
- Rectangle
The union rectangle.
Union(ref Rectangle, ref Rectangle, out Rectangle)
Creates a new rectangle that exactly contains two other rectangles.
Parameters
value1
RectangleThe first rectangle to contain.
value2
RectangleThe second rectangle to contain.
result
Rectangle[OutAttribute] The rectangle that must be the union of the first two rectangles.
Operators
operator ==(Rectangle, Rectangle)
Implements the operator ==.
Parameters
Returns
- bool
The result of the operator.
implicit operator RectangleF(Rectangle)
Performs an implicit conversion to the RectangleF structure.
Parameters
Returns
- RectangleF
The converted structure.
Remarks
Performs direct converstion from int to float.
operator !=(Rectangle, Rectangle)
Implements the operator !=.
Parameters
Returns
- bool
The result of the operator.