Table of Contents

Struct RectangleF

Namespace
MLEM.Maths
Assembly
MLEM.dll

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 Vector2

The top left corner of the rectangle

size Vector2

The 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 float

The x coordinate of the top left corner of the rectangle

y float

The y coordinate of the top left corner of the rectangle

width float

The width of the rectangle

height float

The height of the rectangle

Fields

Height

The height of this rectangle.

[DataMember]
public float Height

Field Value

float

Width

The width of this rectangle.

[DataMember]
public float Width

Field Value

float

X

The x position of the top left corner of this rectangle.

[DataMember]
public float X

Field Value

float

Y

The y position of the top left corner of this rectangle.

[DataMember]
public float Y

Field Value

float

Properties

Bottom

The y position of the bottom right corner of this rectangle.

public float Bottom { get; }

Property Value

float

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

RectangleF

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

bool

Left

The x position of the top left corner of this rectangle.

public float Left { get; }

Property Value

float

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

float

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

float

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 RectangleF

The 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 Vector2

The 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 float

The x coordinate of the point to check for containment.

y float

The 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

x float
y float
width float
height float

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 RectangleF

The 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 RectangleF

The 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 RectangleF

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object obj)

Parameters

obj object

The 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 Point

The first corner to use

corner2 Point

The 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 Vector2

The first corner to use

corner2 Vector2

The 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 float

Value to adjust the left and right edges.

verticalAmount float

Value 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 RectangleF

The first Microsoft.Xna.Framework.Rectangle.

value2 RectangleF

The 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 RectangleF

The 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 Vector2

The 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 float

The x coordinate to add to this Microsoft.Xna.Framework.Rectangle.

offsetY float

The 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 RectangleF

The first Microsoft.Xna.Framework.Rectangle.

value2 RectangleF

The 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 RectangleF
b RectangleF

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

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 RectangleF

The 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 Rectangle

The 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 RectangleF
b RectangleF

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.