• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Struct RectangleF

Represents the location and size of a rectangular region, using float coordinates.

Implements
IEquatable<RectangleF>
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: DRIT.Drawing.Geometry
Assembly: DRIT.Drawing.dll
Syntax
public struct RectangleF : IEquatable<RectangleF>
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Constructors

RectangleF(PointF, SizeF)

Initializes a new RectangleF from a point and a size.

Declaration
public RectangleF(PointF location, SizeF size)
Parameters
Type Name Description
PointF location

The top-left corner.

SizeF size

The dimensions.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

RectangleF(float, float, float, float)

Initializes a new RectangleF with the specified location and size.

Declaration
public RectangleF(float x, float y, float width, float height)
Parameters
Type Name Description
float x

The x-coordinate of the top-left corner.

float y

The y-coordinate of the top-left corner.

float width

The width.

float height

The height.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Fields

Empty

Gets an empty RectangleF (0, 0, 0, 0).

Declaration
public static readonly RectangleF Empty
Field Value
Type Description
RectangleF
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Height

Gets or sets the height.

Declaration
public float Height
Field Value
Type Description
float
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Width

Gets or sets the width.

Declaration
public float Width
Field Value
Type Description
float
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

X

Gets or sets the x-coordinate of the top-left corner.

Declaration
public float X
Field Value
Type Description
float
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Y

Gets or sets the y-coordinate of the top-left corner.

Declaration
public float Y
Field Value
Type Description
float
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Properties

Bottom

Gets the y-coordinate of the bottom edge.

Declaration
public float Bottom { get; }
Property Value
Type Description
float
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

IsEmpty

Gets a value indicating whether this rectangle is empty (Width or Height less than or equal to 0).

Declaration
public bool IsEmpty { get; }
Property Value
Type Description
bool
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Left

Gets the x-coordinate of the left edge.

Declaration
public float Left { get; }
Property Value
Type Description
float
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Location

Gets or sets the top-left corner of this rectangle.

Declaration
public PointF Location { get; set; }
Property Value
Type Description
PointF
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Right

Gets the x-coordinate of the right edge.

Declaration
public float Right { get; }
Property Value
Type Description
float
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Size

Gets or sets the dimensions of this rectangle.

Declaration
public SizeF Size { get; set; }
Property Value
Type Description
SizeF
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Top

Gets the y-coordinate of the top edge.

Declaration
public float Top { get; }
Property Value
Type Description
float
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Methods

Ceiling(RectangleF)

Applies ceiling to each component and converts to a Rectangle.

Declaration
public static Rectangle Ceiling(RectangleF r)
Parameters
Type Name Description
RectangleF r

The rectangle to apply ceiling to.

Returns
Type Description
Rectangle

A new Rectangle with ceiled dimensions.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Contains(PointF)

Determines whether the specified point is contained within this rectangle.

Declaration
public bool Contains(PointF pt)
Parameters
Type Name Description
PointF pt

The point to check.

Returns
Type Description
bool

true if the point is within the rectangle; otherwise, false.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Contains(RectangleF)

Determines whether the specified rectangle is fully contained within this rectangle.

Declaration
public bool Contains(RectangleF rect)
Parameters
Type Name Description
RectangleF rect

The rectangle to check.

Returns
Type Description
bool

true if the rectangle is fully contained; otherwise, false.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Contains(float, float)

Determines whether the specified point is contained within this rectangle.

Declaration
public bool Contains(float x, float y)
Parameters
Type Name Description
float x

The x-coordinate of the point.

float y

The y-coordinate of the point.

Returns
Type Description
bool

true if the point is within the rectangle; otherwise, false.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Equals(RectangleF)

Indicates whether this rectangle is equal to another rectangle.

Declaration
public bool Equals(RectangleF other)
Parameters
Type Name Description
RectangleF other

The rectangle to compare.

Returns
Type Description
bool

true if the rectangles are equal; otherwise, false.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Equals(object?)

Indicates whether this rectangle is equal to another object.

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
object obj

The object to compare.

Returns
Type Description
bool

true if the objects are equal; otherwise, false.

Overrides
ValueType.Equals(object)
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

FromLTRB(float, float, float, float)

Creates a rectangle from left, top, right, and bottom coordinates.

Declaration
public static RectangleF FromLTRB(float left, float top, float right, float bottom)
Parameters
Type Name Description
float left

The x-coordinate of the left edge.

float top

The y-coordinate of the top edge.

float right

The x-coordinate of the right edge.

float bottom

The y-coordinate of the bottom edge.

Returns
Type Description
RectangleF

A new RectangleF.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

GetHashCode()

Returns a hash code for this rectangle.

Declaration
public override int GetHashCode()
Returns
Type Description
int

The hash code.

Overrides
ValueType.GetHashCode()
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Inflate(RectangleF, float, float)

Returns an inflated copy of the specified rectangle.

Declaration
public static RectangleF Inflate(RectangleF rect, float x, float y)
Parameters
Type Name Description
RectangleF rect

The rectangle to inflate.

float x

The horizontal inflation amount.

float y

The vertical inflation amount.

Returns
Type Description
RectangleF

The inflated rectangle.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Inflate(SizeF)

Inflates this rectangle by the specified size.

Declaration
public void Inflate(SizeF size)
Parameters
Type Name Description
SizeF size

The size to inflate by.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Inflate(float, float)

Inflates this rectangle by the specified width and height.

Declaration
public void Inflate(float width, float height)
Parameters
Type Name Description
float width

The horizontal inflation amount.

float height

The vertical inflation amount.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Intersect(RectangleF)

Intersects this rectangle with another, modifying this rectangle to the result.

Declaration
public void Intersect(RectangleF rect)
Parameters
Type Name Description
RectangleF rect

The rectangle to intersect with.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Intersect(RectangleF, RectangleF)

Returns the intersection of two rectangles.

Declaration
public static RectangleF Intersect(RectangleF a, RectangleF b)
Parameters
Type Name Description
RectangleF a

The first rectangle.

RectangleF b

The second rectangle.

Returns
Type Description
RectangleF

The intersection rectangle, or Empty if they don't intersect.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

IntersectsWith(RectangleF)

Determines whether this rectangle intersects with another rectangle.

Declaration
public bool IntersectsWith(RectangleF rect)
Parameters
Type Name Description
RectangleF rect

The rectangle to check.

Returns
Type Description
bool

true if the rectangles intersect; otherwise, false.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Offset(PointF)

Offsets this rectangle by the specified point.

Declaration
public void Offset(PointF pos)
Parameters
Type Name Description
PointF pos

The point containing the offsets.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Offset(float, float)

Offsets this rectangle by the specified horizontal and vertical amounts.

Declaration
public void Offset(float dx, float dy)
Parameters
Type Name Description
float dx

The horizontal offset.

float dy

The vertical offset.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Round(RectangleF)

Rounds each component to the nearest integer and converts to a Rectangle.

Declaration
public static Rectangle Round(RectangleF r)
Parameters
Type Name Description
RectangleF r

The rectangle to round.

Returns
Type Description
Rectangle

A new Rectangle with rounded dimensions.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

ToRectangle()

Truncates each component toward zero and converts to a Rectangle.

Declaration
public Rectangle ToRectangle()
Returns
Type Description
Rectangle

A new Rectangle with truncated dimensions.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

ToString()

Returns a string representation of this rectangle.

Declaration
public override string ToString()
Returns
Type Description
string

A string in the format "{X=value, Y=value, Width=value, Height=value}".

Overrides
ValueType.ToString()
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Truncate(RectangleF)

Truncates each component toward negative infinity and converts to a Rectangle.

Declaration
public static Rectangle Truncate(RectangleF r)
Parameters
Type Name Description
RectangleF r

The rectangle to truncate.

Returns
Type Description
Rectangle

A new Rectangle with truncated dimensions.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Union(RectangleF, RectangleF)

Returns the union of two rectangles.

Declaration
public static RectangleF Union(RectangleF a, RectangleF b)
Parameters
Type Name Description
RectangleF a

The first rectangle.

RectangleF b

The second rectangle.

Returns
Type Description
RectangleF

The smallest rectangle containing both input rectangles.

Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Operators

operator ==(RectangleF, RectangleF)

Compares two rectangles for equality.

Declaration
public static bool operator ==(RectangleF left, RectangleF right)
Parameters
Type Name Description
RectangleF left
RectangleF right
Returns
Type Description
bool
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

implicit operator RectangleF(Rectangle)

Implicitly converts a Rectangle to a RectangleF.

Declaration
public static implicit operator RectangleF(Rectangle r)
Parameters
Type Name Description
Rectangle r
Returns
Type Description
RectangleF
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

operator !=(RectangleF, RectangleF)

Compares two rectangles for inequality.

Declaration
public static bool operator !=(RectangleF left, RectangleF right)
Parameters
Type Name Description
RectangleF left
RectangleF right
Returns
Type Description
bool
Remarks

A RectangleF defines a region with X, Y, Width, and Height. X and Y represent the top-left corner; Width and Height represent the dimensions.

Implements

IEquatable<T>
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX