Table of Contents

Struct RectangleF

Namespace
HelixToolkit.Maths
Assembly
HelixToolkit.Maths.dll

Define a RectangleF. This structure is slightly different from System.Drawing.RectangleF as it is internally storing Left,Top,Right,Bottom instead of Left,Top,Width,Height.

public struct RectangleF : IEquatable<RectangleF>
Implements
Inherited Members
Extension Methods

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

Bottom

The bottom.

public float Bottom

Field Value

float

Empty

An empty rectangle.

public static readonly RectangleF Empty

Field Value

RectangleF

Infinite

An infinite rectangle. See remarks.

public static readonly RectangleF Infinite

Field Value

RectangleF

Remarks

http://msdn.microsoft.com/en-us/library/windows/desktop/dd372261%28v=vs.85%29.aspx Any properties that involve computations, like Center, Width or Height may return incorrect results - NaN.

Left

The left.

public float Left

Field Value

float

Right

The right.

public float Right

Field Value

float

Top

The top.

public float Top

Field Value

float

Properties

BottomLeft

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

public readonly 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 readonly 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 readonly Vector2 Center { get; }

Property Value

Vector2

The center.

Height

Gets or sets the height.

public float Height { readonly get; set; }

Property Value

float

The height.

IsEmpty

Gets a value that indicates whether the rectangle is empty.

public readonly bool IsEmpty { get; }

Property Value

bool

true if [is empty]; otherwise, false.

Location

Gets or sets the location.

public Vector2 Location { readonly get; set; }

Property Value

Vector2

The location.

TopLeft

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

public readonly 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 readonly Vector2 TopRight { get; }

Property Value

Vector2

The top-right corner of the rectangle.

Width

Gets or sets the width.

public float Width { readonly get; set; }

Property Value

float

The width.

X

Gets or sets the X position.

public float X { readonly get; set; }

Property Value

float

The X position.

Y

Gets or sets the Y position.

public float Y { readonly get; set; }

Property Value

float

The Y position.

Methods

Contains(Rectangle)

Determines whether this rectangle entirely contains a specified rectangle.

public readonly bool Contains(Rectangle value)

Parameters

value Rectangle

The rectangle to evaluate.

Returns

bool

Contains(ref RectangleF, out bool)

Determines whether this rectangle entirely contains a specified rectangle.

public readonly void Contains(ref 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 readonly bool Contains(Vector2 vector2D)

Parameters

vector2D Vector2

Coordinate Vector2.

Returns

bool

true if Vector2 is inside RectangleF, otherwise false.

Contains(ref Vector2, out bool)

Determines whether this rectangle contains a specified Point.

public readonly void Contains(ref 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 readonly 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)

Determines whether the specified RectangleF is equal to this instance.

public readonly bool Equals(RectangleF other)

Parameters

other RectangleF

The RectangleF to compare with this instance.

Returns

bool

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

Equals(ref RectangleF)

Determines whether the specified RectangleF is equal to this instance.

public readonly bool Equals(ref RectangleF other)

Parameters

other RectangleF

The RectangleF to compare with this instance.

Returns

bool

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

Equals(object?)

Determines whether the specified object is equal to this instance.

public override readonly 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 readonly 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 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

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 readonly bool Intersects(RectangleF value)

Parameters

value RectangleF

The rectangle to evaluate.

Returns

bool

Intersects(ref RectangleF, out bool)

Determines whether a specified rectangle intersects with this rectangle.

public readonly void Intersects(ref 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(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.

Size()

public readonly Vector2 Size()

Returns

Vector2

ToString()

Returns the fully qualified type name of this instance.

public override readonly 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 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

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.