Table of Contents

Struct RectangleF

Namespace
Stride.Core.Mathematics
Assembly
Stride.Core.Mathematics.dll

Define a RectangleF.

[DataContract("RectangleF")]
[DataStyle(DataStyle.Compact)]
public struct RectangleF : IEquatable<RectangleF>
Implements

Constructors

RectangleF(float, float, float, float)

Initializes a new instance of the RectangleF struct.

public RectangleF(float x, float y, float width, float height)

Parameters

x float

The left.

y float

The top.

width float

The width.

height float

The height.

Fields

Empty

An empty rectangle

public static readonly RectangleF Empty

Field Value

RectangleF

Height

Gets or sets the height.

[DataMember(3)]
public float Height

Field Value

float

The height.

Width

Gets or sets the width.

[DataMember(2)]
public float Width

Field Value

float

The width.

X

Gets or sets the X position.

[DataMember(0)]
public float X

Field Value

float

The X position.

Y

Gets or sets the Y position.

[DataMember(1)]
public float Y

Field Value

float

The Y position.

Properties

Bottom

Gets the bottom.

public float Bottom { get; }

Property Value

float

The bottom.

BottomLeft

Gets the position of the bottom-left corner of the rectangle.

public Vector2 BottomLeft { get; }

Property Value

Vector2

The bottom-left corner of the rectangle.

BottomRight

Gets the position of the bottom-right corner of the rectangle.

public Vector2 BottomRight { get; }

Property Value

Vector2

The bottom-right corner of the rectangle.

Center

Gets the Point that specifies the center of the rectangle.

public Vector2 Center { get; }

Property Value

Vector2

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 X position of the left edge.

public float Left { get; set; }

Property Value

float

The left.

Location

Gets or sets the location.

public Vector2 Location { get; set; }

Property Value

Vector2

The location.

Right

Gets the right.

public float Right { get; }

Property Value

float

The right.

Size

Gets or sets the size of the rectangle.

public Size2F Size { get; set; }

Property Value

Size2F

The size of the rectangle.

Top

Gets or sets the top.

public float Top { get; set; }

Property Value

float

The top.

TopLeft

Gets the position of the top-left corner of the rectangle.

public Vector2 TopLeft { get; }

Property Value

Vector2

The top-left corner of the rectangle.

TopRight

Gets the position of the top-right corner of the rectangle.

public Vector2 TopRight { get; }

Property Value

Vector2

The top-right corner of the rectangle.

Methods

Contains(Int2)

Checks, if specified Int2 is inside Rectangle.

public bool Contains(Int2 int2)

Parameters

int2 Int2

Coordinate Int2.

Returns

bool

true if Int2 is inside Rectangle, otherwise false.

Contains(Point)

Checks, if specified Point is inside RectangleF.

public bool Contains(Point point)

Parameters

point Point

Coordinate Point.

Returns

bool

true if Point is inside RectangleF, otherwise false.

Contains(Rectangle)

Determines whether this rectangle entirely contains a specified rectangle.

public bool Contains(Rectangle value)

Parameters

value Rectangle

The rectangle to evaluate.

Returns

bool

Contains(ref readonly RectangleF, out bool)

Determines whether this rectangle entirely contains a specified rectangle.

public void Contains(ref readonly RectangleF value, out bool result)

Parameters

value RectangleF

The rectangle to evaluate.

result bool

[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

vector2D Vector2

Coordinate Vector2.

Returns

bool

true if Vector2 is inside RectangleF, otherwise false.

Contains(ref readonly Vector2, out bool)

Determines whether this rectangle contains a specified Point.

public void Contains(ref readonly Vector2 value, out bool result)

Parameters

value Vector2

The Point to evaluate.

result bool

[OutAttribute] true if the specified Point is contained within this rectangle; false otherwise.

Contains(float, float)

Checks, if specified point is inside RectangleF.

public bool Contains(float x, float y)

Parameters

x float

X point coordinate.

y float

Y point coordinate.

Returns

bool

true if point is inside RectangleF, otherwise false.

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)

Determines whether the specified object is equal to this instance.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

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(float, float)

Pushes the edges of the rectangle out by the horizontal and vertical values specified.

public void Inflate(float horizontalAmount, float verticalAmount)

Parameters

horizontalAmount float

Value to push the sides out by.

verticalAmount float

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

value1 RectangleF

The first Rectangle to compare.

value2 RectangleF

The second Rectangle to compare.

Returns

RectangleF

The intersection rectangle.

Intersect(ref readonly RectangleF, ref readonly RectangleF, out RectangleF)

Creates a rectangle defining the area where one rectangle overlaps with another rectangle.

public static void Intersect(ref readonly RectangleF value1, ref readonly RectangleF value2, out RectangleF result)

Parameters

value1 RectangleF

The first rectangle to compare.

value2 RectangleF

The second rectangle to compare.

result RectangleF

[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

value RectangleF

The rectangle to evaluate.

Returns

bool

Intersects(ref readonly RectangleF, out bool)

Determines whether a specified rectangle intersects with this rectangle.

public void Intersects(ref readonly RectangleF value, out bool result)

Parameters

value RectangleF

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

The values to adjust the position of the rectangle by.

Offset(Vector2)

Changes the position of the rectangle.

public void Offset(Vector2 amount)

Parameters

amount Vector2

The values to adjust the position of the rectangle by.

Offset(float, float)

Changes the position of the rectangle.

public void Offset(float offsetX, float offsetY)

Parameters

offsetX float

Change in the x-position.

offsetY float

Change in the y-position.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Union(RectangleF, RectangleF)

Creates a new rectangle that exactly contains two other rectangles.

public static RectangleF Union(RectangleF value1, RectangleF value2)

Parameters

value1 RectangleF

The first rectangle to contain.

value2 RectangleF

The second rectangle to contain.

Returns

RectangleF

The union rectangle.

Union(ref readonly RectangleF, ref readonly RectangleF, out RectangleF)

Creates a new rectangle that exactly contains two other rectangles.

public static void Union(ref readonly RectangleF value1, ref readonly RectangleF value2, out RectangleF result)

Parameters

value1 RectangleF

The first rectangle to contain.

value2 RectangleF

The second rectangle to contain.

result RectangleF

[OutAttribute] The rectangle that must be the union of the first two rectangles.

Operators

operator ==(RectangleF, RectangleF)

Implements the operator ==.

public static bool operator ==(RectangleF left, RectangleF right)

Parameters

left RectangleF

The left.

right RectangleF

The right.

Returns

bool

The result of the operator.

explicit operator Rectangle(RectangleF)

Performs an explicit conversion to Rectangle structure.

public static explicit operator Rectangle(RectangleF value)

Parameters

value RectangleF

The source RectangleF value.

Returns

Rectangle

A converted Rectangle structure.

Remarks

Performs direct float to int conversion, any fractional data is truncated.

operator !=(RectangleF, RectangleF)

Implements the operator !=.

public static bool operator !=(RectangleF left, RectangleF right)

Parameters

left RectangleF

The left.

right RectangleF

The right.

Returns

bool

The result of the operator.