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.
public Rectangle(int x, int y, int width, int height)
Parameters
Fields
Empty
An empty rectangle.
public static readonly Rectangle Empty
Field Value
Height
Gets or sets the height.
[DataMember(3)]
public int Height
Field Value
- int
The height.
Width
Gets or sets the width.
[DataMember(2)]
public int Width
Field Value
- int
The width.
X
Gets or sets the X position.
[DataMember(0)]
public int X
Field Value
- int
The X position.
Y
Gets or sets the Y position.
[DataMember(1)]
public int Y
Field Value
- int
The Y position.
Properties
Bottom
Gets or sets the bottom.
public int Bottom { get; }
Property Value
- int
The bottom.
BottomLeft
Gets the position of the bottom-left corner of the rectangle.
public Point BottomLeft { get; }
Property Value
- Point
The bottom-left corner of the rectangle.
BottomRight
Gets the position of the bottom-right corner of the rectangle.
public Point BottomRight { get; }
Property Value
- Point
The bottom-right corner of the rectangle.
Center
Gets the Point that specifies the center of the rectangle.
public Point Center { get; }
Property Value
- Point
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 left.
public int Left { get; set; }
Property Value
- int
The left.
Location
Gets or sets the location.
public Point Location { get; set; }
Property Value
- Point
The location.
Right
Gets or sets the right.
public int Right { get; }
Property Value
- int
The right.
Size
Gets or sets the size of the rectangle.
public Size2 Size { get; set; }
Property Value
- Size2
The size of the rectangle.
Top
Gets or sets the top.
public int Top { get; set; }
Property Value
- int
The top.
TopLeft
Gets the position of the top-left corner of the rectangle.
public Point TopLeft { get; }
Property Value
- Point
The top-left corner of the rectangle.
TopRight
Gets the position of the top-right corner of the rectangle.
public Point TopRight { get; }
Property Value
- Point
The top-right corner of the rectangle.
Methods
Contains(Int2)
public bool Contains(Int2 int2)
Parameters
Returns
Contains(Point)
Determines whether this rectangle contains a specified Point.
public bool Contains(Point value)
Parameters
value
PointThe Point to evaluate.
Returns
Contains(ref Point, out bool)
Determines whether this rectangle contains a specified Point.
public void Contains(ref Point value, out bool result)
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.
public bool Contains(Rectangle value)
Parameters
value
RectangleThe rectangle to evaluate.
Returns
Contains(ref Rectangle, out bool)
Determines whether this rectangle entirely contains a specified rectangle.
public void Contains(ref Rectangle value, out bool result)
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)
public bool Contains(Vector2 vector2D)
Parameters
Returns
Contains(int, int)
Determines whether this rectangle contains a specified point represented by its x- and y-coordinates.
public bool Contains(int x, int y)
Parameters
Returns
Contains(float, float)
Checks, if specified point is inside Rectangle.
public bool Contains(float x, float y)
Parameters
Returns
Equals(Rectangle)
Determines whether the specified Rectangle is equal to this instance.
public bool Equals(Rectangle other)
Parameters
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(int, int)
Pushes the edges of the rectangle out by the horizontal and vertical values specified.
public void Inflate(int horizontalAmount, int verticalAmount)
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.
public static Rectangle Intersect(Rectangle value1, Rectangle value2)
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.
public static void Intersect(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
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.
public bool Intersects(Rectangle value)
Parameters
value
RectangleThe rectangle to evaluate.
Returns
Intersects(ref Rectangle, out bool)
Determines whether a specified rectangle intersects with this rectangle.
public void Intersects(ref Rectangle value, out bool result)
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.
public void Offset(Point amount)
Parameters
amount
PointThe values to adjust the position of the rectangle by.
Offset(int, int)
Changes the position of the rectangle.
public void Offset(int offsetX, int offsetY)
Parameters
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Union(Rectangle, Int2)
Creates a new rectangle that incorporate the provided point to the given rectangle.
public static Rectangle Union(Rectangle rectangle, Int2 point)
Parameters
Returns
- Rectangle
The union rectangle.
Union(Rectangle, Rectangle)
Creates a new rectangle that exactly contains two other rectangles.
public static Rectangle Union(Rectangle value1, Rectangle value2)
Parameters
Returns
- Rectangle
The union rectangle.
Union(ref Rectangle, ref Rectangle, out Rectangle)
Creates a new rectangle that exactly contains two other rectangles.
public static void Union(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
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 ==.
public static bool operator ==(Rectangle left, Rectangle right)
Parameters
Returns
- bool
The result of the operator.
implicit operator RectangleF(Rectangle)
Performs an implicit conversion to the RectangleF structure.
public static implicit operator RectangleF(Rectangle value)
Parameters
Returns
- RectangleF
The converted structure.
Remarks
Performs direct converstion from int to float.
operator !=(Rectangle, Rectangle)
Implements the operator !=.
public static bool operator !=(Rectangle left, Rectangle right)
Parameters
Returns
- bool
The result of the operator.