Struct RectangleF
Represents a float-based version of Microsoft.Xna.Framework.Rectangle
[DataContract]
public struct RectangleF : IEquatable<RectangleF>
- Implements
- Inherited Members
- Extension Methods
Constructors
RectangleF(Vector2, Vector2)
Creates a new rectangle with the specified location and size vectors
public RectangleF(Vector2 location, Vector2 size)
Parameters
location
Vector2The top left corner of the rectangle
size
Vector2The size of the rectangle, where x represents width and the y represents height
RectangleF(float, float, float, float)
Creates a new rectangle with the specified location and size
public RectangleF(float x, float y, float width, float height)
Parameters
x
floatThe x coordinate of the top left corner of the rectangle
y
floatThe y coordinate of the top left corner of the rectangle
width
floatThe width of the rectangle
height
floatThe height of the rectangle
Fields
Height
The height of this rectangle.
[DataMember]
public float Height
Field Value
Width
The width of this rectangle.
[DataMember]
public float Width
Field Value
X
The x position of the top left corner of this rectangle.
[DataMember]
public float X
Field Value
Y
The y position of the top left corner of this rectangle.
[DataMember]
public float Y
Field Value
Properties
Bottom
The y position of the bottom right corner of this rectangle.
public float Bottom { get; }
Property Value
Center
The center of this rectangle, based on the top left corner and the size.
public Vector2 Center { get; }
Property Value
- Vector2
Empty
The empty rectangle, with an x, y, width and height of 0.
public static RectangleF Empty { get; }
Property Value
IsEmpty
A boolean that is true if this rectangle is empty. A rectangle is considered empty if the width or height is 0.
public bool IsEmpty { get; }
Property Value
Left
The x position of the top left corner of this rectangle.
public float Left { get; }
Property Value
Location
The top left corner of this rectangle
public Vector2 Location { get; set; }
Property Value
- Vector2
Right
The x position of the bottom right corner of this rectangle.
public float Right { get; }
Property Value
Size
The size, that is, the width and height of this rectangle.
public Vector2 Size { get; set; }
Property Value
- Vector2
Top
The y position of the top left corner of this rectangle.
public float Top { get; }
Property Value
Methods
Contains(RectangleF)
Gets whether or not the provided Microsoft.Xna.Framework.Rectangle lies within the bounds of this Microsoft.Xna.Framework.Rectangle.
public bool Contains(RectangleF value)
Parameters
value
RectangleFThe Microsoft.Xna.Framework.Rectangle to check for inclusion in this Microsoft.Xna.Framework.Rectangle.
Returns
- bool
true
if the provided Microsoft.Xna.Framework.Rectangle's bounds lie entirely inside this Microsoft.Xna.Framework.Rectangle;false
otherwise.
Contains(Vector2)
Gets whether or not the provided Microsoft.Xna.Framework.Point lies within the bounds of this Microsoft.Xna.Framework.Rectangle.
public bool Contains(Vector2 value)
Parameters
value
Vector2The coordinates to check for inclusion in this Microsoft.Xna.Framework.Rectangle.
Returns
- bool
true
if the provided Microsoft.Xna.Framework.Point lies inside this Microsoft.Xna.Framework.Rectangle;false
otherwise.
Contains(float, float)
Gets whether or not the provided coordinates lie within the bounds of this Microsoft.Xna.Framework.Rectangle.
public bool Contains(float x, float y)
Parameters
x
floatThe x coordinate of the point to check for containment.
y
floatThe y coordinate of the point to check for containment.
Returns
- bool
true
if the provided coordinates lie inside this Microsoft.Xna.Framework.Rectangle;false
otherwise.
Deconstruct(out float, out float, out float, out float)
Deconstruction method for RectangleF.
public void Deconstruct(out float x, out float y, out float width, out float height)
Parameters
Distance(RectangleF)
Calculates the distance between this rectangle and the value
.
The returned value is the smallest distance between any two edges or corners of the two rectangles.
public float Distance(RectangleF value)
Parameters
value
RectangleFThe rectangle to calculate the distance to.
Returns
- float
The distance between the two rectangles.
DistanceSquared(RectangleF)
Calculates the suqared distance between this rectangle and the value
.
The returned value is the smallest squared distance between any two edges or corners of the two rectangles.
public float DistanceSquared(RectangleF value)
Parameters
value
RectangleFThe rectangle to calculate the squared distance to.
Returns
- float
The squared distance between the two rectangles.
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)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
FromCorners(Point, Point)
Creates a new rectangle based on two corners that form a bounding box. The resulting rectangle will encompass both corners as well as all of the space between them.
public static RectangleF FromCorners(Point corner1, Point corner2)
Parameters
corner1
PointThe first corner to use
corner2
PointThe second corner to use
Returns
- RectangleF
The created rectangle.
FromCorners(Vector2, Vector2)
Creates a new rectangle based on two corners that form a bounding box. The resulting rectangle will encompass both corners as well as all of the space between them.
public static RectangleF FromCorners(Vector2 corner1, Vector2 corner2)
Parameters
corner1
Vector2The first corner to use
corner2
Vector2The second corner to use
Returns
- RectangleF
The created rectangle.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Inflate(float, float)
Adjusts the edges of this Microsoft.Xna.Framework.Rectangle by specified horizontal and vertical amounts.
public void Inflate(float horizontalAmount, float verticalAmount)
Parameters
horizontalAmount
floatValue to adjust the left and right edges.
verticalAmount
floatValue to adjust the top and bottom edges.
Intersect(RectangleF, RectangleF)
Creates a new Microsoft.Xna.Framework.Rectangle that contains overlapping region of two other rectangles.
public static RectangleF Intersect(RectangleF value1, RectangleF value2)
Parameters
value1
RectangleFThe first Microsoft.Xna.Framework.Rectangle.
value2
RectangleFThe second Microsoft.Xna.Framework.Rectangle.
Returns
- RectangleF
Overlapping region of the two rectangles.
Intersects(RectangleF)
Gets whether or not the other Microsoft.Xna.Framework.Rectangle intersects with this rectangle.
public bool Intersects(RectangleF value)
Parameters
value
RectangleFThe other rectangle for testing.
Returns
- bool
true
if other Microsoft.Xna.Framework.Rectangle intersects with this rectangle;false
otherwise.
Offset(Vector2)
Changes the Microsoft.Xna.Framework.Rectangle.Location of this Microsoft.Xna.Framework.Rectangle.
public void Offset(Vector2 amount)
Parameters
amount
Vector2The x and y components to add to this Microsoft.Xna.Framework.Rectangle.
Offset(float, float)
Changes the Microsoft.Xna.Framework.Rectangle.Location of this Microsoft.Xna.Framework.Rectangle.
public void Offset(float offsetX, float offsetY)
Parameters
offsetX
floatThe x coordinate to add to this Microsoft.Xna.Framework.Rectangle.
offsetY
floatThe y coordinate to add to this Microsoft.Xna.Framework.Rectangle.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Union(RectangleF, RectangleF)
Creates a new Microsoft.Xna.Framework.Rectangle that completely contains two other rectangles.
public static RectangleF Union(RectangleF value1, RectangleF value2)
Parameters
value1
RectangleFThe first Microsoft.Xna.Framework.Rectangle.
value2
RectangleFThe second Microsoft.Xna.Framework.Rectangle.
Returns
- RectangleF
The union of the two rectangles.
Operators
operator ==(RectangleF, RectangleF)
Indicates whether the current object is equal to another object of the same type.
public static bool operator ==(RectangleF a, RectangleF b)
Parameters
a
RectangleFb
RectangleF
Returns
explicit operator Rectangle(RectangleF)
Converts a float-based rectangle to an int-based rectangle, flooring each value in the process.
public static explicit operator Rectangle(RectangleF rect)
Parameters
rect
RectangleFThe rectangle to convert
Returns
- Rectangle
The resulting rectangle
explicit operator RectangleF(Rectangle)
Converts an int-based rectangle to a float-based rectangle.
public static explicit operator RectangleF(Rectangle rect)
Parameters
rect
RectangleThe rectangle to convert
Returns
- RectangleF
The resulting rectangle
operator !=(RectangleF, RectangleF)
Indicates whether the current object is equal to another object of the same type.
public static bool operator !=(RectangleF a, RectangleF b)
Parameters
a
RectangleFb
RectangleF