RectangleF Struct
Namespace: Stride.Core.MathematicsAssembly: Stride.Core.Mathematics.dll
Define a RectangleF.
[DataContract("RectangleF")]
[DataStyle(DataStyle.Compact)]
public struct RectangleF : IEquatable<RectangleF>
Name | Description | |
---|---|---|
Constructors | ||
RectangleF(Single, Single, Single, Single) | Initializes a new instance of the RectangleF struct. |
|
Fields | ||
Empty | An empty rectangle |
|
Height | Gets or sets the height. |
|
Width | Gets or sets the width. |
|
X | Gets or sets the X position. |
|
Y | Gets or sets the Y position. |
|
Properties | ||
Bottom | Gets the bottom. |
|
BottomLeft | Gets the position of the bottom-left corner of the rectangle. |
|
BottomRight | Gets the position of the bottom-right corner of the rectangle. |
|
Center | Gets the Point that specifies the center of the rectangle. |
|
IsEmpty | Gets a value that indicates whether the rectangle is empty. |
|
Left | Gets or sets the X position of the left edge. |
|
Location | Gets or sets the location. |
|
Right | Gets the right. |
|
Size | Gets or sets the size of the rectangle. |
|
Top | Gets or sets the top. |
|
TopLeft | Gets the position of the top-left corner of the rectangle. |
|
TopRight | Gets the position of the top-right corner of the rectangle. |
|
Methods | ||
Contains(Int2) | ||
Contains(Point) | Checks, if specified Point is inside RectangleF. |
|
Contains(Rectangle) | Determines whether this rectangle entirely contains a specified rectangle. |
|
Contains(ref RectangleF, out Boolean) | Determines whether this rectangle entirely contains a specified rectangle. |
|
Contains(Vector2) | Checks, if specified Vector2 is inside RectangleF. |
|
Contains(ref Vector2, out Boolean) | Determines whether this rectangle contains a specified Point. |
|
Contains(Single, Single) | Checks, if specified point is inside RectangleF. |
|
Equals(RectangleF) | ||
Equals(Object) | Determines whether the specified System.Object is equal to this instance. |
|
GetHashCode() | Returns a hash code for this instance. |
|
Inflate(Single, Single) | Pushes the edges of the rectangle out by the horizontal and vertical values specified. |
|
Intersect(RectangleF, RectangleF) | Creates a rectangle defining the area where one rectangle overlaps with another rectangle. |
|
Intersect(ref RectangleF, ref RectangleF, out RectangleF) | Creates a rectangle defining the area where one rectangle overlaps with another rectangle. |
|
Intersects(RectangleF) | Determines whether a specified rectangle intersects with this rectangle. |
|
Intersects(ref RectangleF, out Boolean) | Determines whether a specified rectangle intersects with this rectangle. |
|
Offset(Point) | Changes the position of the rectangle. |
|
Offset(Vector2) | Changes the position of the rectangle. |
|
Offset(Single, Single) | Changes the position of the rectangle. |
|
ToString() | ||
Union(RectangleF, RectangleF) | Creates a new rectangle that exactly contains two other rectangles. |
|
Union(ref RectangleF, ref RectangleF, out RectangleF) | Creates a new rectangle that exactly contains two other rectangles. |
|
Operators | ||
Equality(RectangleF, RectangleF) | Implements the operator ==. |
|
Explicit(RectangleF to Rectangle) | Performs an explicit conversion to Rectangle structure. |
|
Inequality(RectangleF, RectangleF) | Implements the operator !=. |
Constructors
RectangleF(Single, Single, Single, Single)
Initializes a new instance of the RectangleF struct.
public RectangleF(float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | The left. |
System.Single | y | The top. |
System.Single | width | The width. |
System.Single | height | The height. |
Fields
Empty
An empty rectangle
public static readonly RectangleF Empty
Field Value
Type | Description |
---|---|
RectangleF |
Height
Gets or sets the height.
[DataMember(3)]
public float Height
Field Value
Type | Description |
---|---|
System.Single | The height. |
Width
Gets or sets the width.
[DataMember(2)]
public float Width
Field Value
Type | Description |
---|---|
System.Single | The width. |
X
Gets or sets the X position.
[DataMember(0)]
public float X
Field Value
Type | Description |
---|---|
System.Single | The X position. |
Y
Gets or sets the Y position.
[DataMember(1)]
public float Y
Field Value
Type | Description |
---|---|
System.Single | The Y position. |
Properties
Bottom
Gets the bottom.
public readonly float Bottom { get; }
Property Value
Type | Description |
---|---|
System.Single | The bottom. |
BottomLeft
Gets the position of the bottom-left corner of the rectangle.
public readonly Vector2 BottomLeft { get; }
Property Value
Type | Description |
---|---|
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
Type | Description |
---|---|
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
Type | Description |
---|---|
Vector2 | The center. |
IsEmpty
Gets a value that indicates whether the rectangle is empty.
public readonly bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Left
Gets or sets the X position of the left edge.
public float Left { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The left. |
Location
Gets or sets the location.
public Vector2 Location { get; set; }
Property Value
Type | Description |
---|---|
Vector2 | The location. |
Right
Gets the right.
public readonly float Right { get; }
Property Value
Type | Description |
---|---|
System.Single | The right. |
Size
Gets or sets the size of the rectangle.
public Size2F Size { get; set; }
Property Value
Type | Description |
---|---|
Size2F | The size of the rectangle. |
Top
Gets or sets the top.
public float Top { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The top. |
TopLeft
Gets the position of the top-left corner of the rectangle.
public readonly Vector2 TopLeft { get; }
Property Value
Type | Description |
---|---|
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
Type | Description |
---|---|
Vector2 | The top-right corner of the rectangle. |
Methods
Contains(Int2)
public bool Contains(Int2 int2)
Parameters
Type | Name | Description |
---|---|---|
Int2 | int2 | Coordinate Int2. |
Returns
Type | Description |
---|---|
System.Boolean |
Contains(Point)
Checks, if specified Point is inside RectangleF.
public bool Contains(Point point)
Parameters
Type | Name | Description |
---|---|---|
Point | point | Coordinate Point. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Contains(Rectangle)
Determines whether this rectangle entirely contains a specified rectangle.
public bool Contains(Rectangle value)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | value | The rectangle to evaluate. |
Returns
Type | Description |
---|---|
System.Boolean |
Contains(ref RectangleF, out Boolean)
Determines whether this rectangle entirely contains a specified rectangle.
public void Contains(ref RectangleF value, out bool result)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | value | The rectangle to evaluate. |
System.Boolean | result | [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
Type | Name | Description |
---|---|---|
Vector2 | vector2D | Coordinate Vector2. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Contains(ref Vector2, out Boolean)
Determines whether this rectangle contains a specified Point.
public void Contains(ref Vector2 value, out bool result)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | value | The Point to evaluate. |
System.Boolean | result | [OutAttribute] true if the specified Point is contained within this rectangle; false otherwise. |
Contains(Single, Single)
Checks, if specified point is inside RectangleF.
public bool Contains(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | X point coordinate. |
System.Single | y | Y point coordinate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Equals(RectangleF)
public bool Equals(RectangleF other)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | other |
Returns
Type | Description |
---|---|
System.Boolean |
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The System.Object to compare with this instance. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
Inflate(Single, Single)
Pushes the edges of the rectangle out by the horizontal and vertical values specified.
public void Inflate(float horizontalAmount, float verticalAmount)
Parameters
Type | Name | Description |
---|---|---|
System.Single | horizontalAmount | Value to push the sides out by. |
System.Single | verticalAmount | Value 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
Type | Name | Description |
---|---|---|
RectangleF | value1 | The first Rectangle to compare. |
RectangleF | value2 | The second Rectangle to compare. |
Returns
Type | Description |
---|---|
RectangleF | The intersection rectangle. |
Intersect(ref RectangleF, ref RectangleF, out RectangleF)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
public static void Intersect(ref RectangleF value1, ref RectangleF value2, out RectangleF result)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | value1 | The first rectangle to compare. |
RectangleF | value2 | The second rectangle to compare. |
RectangleF | result | [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
Type | Name | Description |
---|---|---|
RectangleF | value | The rectangle to evaluate. |
Returns
Type | Description |
---|---|
System.Boolean |
Intersects(ref RectangleF, out Boolean)
Determines whether a specified rectangle intersects with this rectangle.
public void Intersects(ref RectangleF value, out bool result)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | value | The rectangle to evaluate |
System.Boolean | result | [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
Type | Name | Description |
---|---|---|
Point | amount | The values to adjust the position of the rectangle by. |
Offset(Vector2)
Changes the position of the rectangle.
public void Offset(Vector2 amount)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | amount | The values to adjust the position of the rectangle by. |
Offset(Single, Single)
Changes the position of the rectangle.
public void Offset(float offsetX, float offsetY)
Parameters
Type | Name | Description |
---|---|---|
System.Single | offsetX | Change in the x-position. |
System.Single | offsetY | Change in the y-position. |
ToString()
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
Union(RectangleF, RectangleF)
Creates a new rectangle that exactly contains two other rectangles.
public static RectangleF Union(RectangleF value1, RectangleF value2)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | value1 | The first rectangle to contain. |
RectangleF | value2 | The second rectangle to contain. |
Returns
Type | Description |
---|---|
RectangleF | The union rectangle. |
Union(ref RectangleF, ref RectangleF, out RectangleF)
Creates a new rectangle that exactly contains two other rectangles.
public static void Union(ref RectangleF value1, ref RectangleF value2, out RectangleF result)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | value1 | The first rectangle to contain. |
RectangleF | value2 | The second rectangle to contain. |
RectangleF | result | [OutAttribute] The rectangle that must be the union of the first two rectangles. |
Operators
Equality(RectangleF, RectangleF)
Implements the operator ==.
public static bool operator ==(RectangleF left, RectangleF right)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | left | The left. |
RectangleF | right | The right. |
Returns
Type | Description |
---|---|
System.Boolean | The result of the operator. |
Explicit(RectangleF to Rectangle)
Performs an explicit conversion to Rectangle structure.
public static explicit operator Rectangle(RectangleF value)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | value | The source RectangleF value. |
Returns
Type | Description |
---|---|
Rectangle | A converted Rectangle structure. |
Remarks
Performs direct float to int conversion, any fractional data is truncated.
Inequality(RectangleF, RectangleF)
Implements the operator !=.
public static bool operator !=(RectangleF left, RectangleF right)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | left | The left. |
RectangleF | right | The right. |
Returns
Type | Description |
---|---|
System.Boolean | The result of the operator. |