Table of Contents

Struct RectangleF

Namespace
SixLabors.ImageSharp
Assembly
SixLabors.ImageSharp.dll

Stores a set of four single precision floating points that represent the location and size of a rectangle.

public struct RectangleF : IEquatable<RectangleF>
Implements
Inherited Members

Remarks

This struct is fully mutable. This is done (against the guidelines) for the sake of performance, as it avoids the need to create new values for modification operations.

Constructors

RectangleF(PointF, SizeF)

Initializes a new instance of the RectangleF struct.

public RectangleF(PointF point, SizeF size)

Parameters

point PointF

The Point which specifies the rectangles point in a two-dimensional plane.

size SizeF

The Size which specifies the rectangles height and width.

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 horizontal position of the rectangle.

y float

The vertical position of the rectangle.

width float

The width of the rectangle.

height float

The height of the rectangle.

Fields

Empty

Represents a RectangleF that has X, Y, Width, and Height values set to zero.

public static readonly RectangleF Empty

Field Value

RectangleF

Properties

Bottom

Gets the y-coordinate of the bottom edge of this RectangleF.

public float Bottom { get; }

Property Value

float

Height

Gets or sets the height of this RectangleF.

public float Height { readonly get; set; }

Property Value

float

Left

Gets the x-coordinate of the left edge of this RectangleF.

public float Left { get; }

Property Value

float

Right

Gets the x-coordinate of the right edge of this RectangleF.

public float Right { get; }

Property Value

float

Top

Gets the y-coordinate of the top edge of this RectangleF.

public float Top { get; }

Property Value

float

Width

Gets or sets the width of this RectangleF.

public float Width { readonly get; set; }

Property Value

float

X

Gets or sets the x-coordinate of this RectangleF.

public float X { readonly get; set; }

Property Value

float

Y

Gets or sets the y-coordinate of this RectangleF.

public float Y { readonly get; set; }

Property Value

float

Methods

Center(RectangleF)

Returns the center point of the given RectangleF.

public static PointF Center(RectangleF rectangle)

Parameters

rectangle RectangleF

The rectangle.

Returns

PointF

The Point.

Contains(PointF)

Determines if the specified point is contained within the rectangular region defined by this RectangleF .

public bool Contains(PointF point)

Parameters

point PointF

The point.

Returns

bool

The bool.

Contains(RectangleF)

Determines if the rectangular region represented by rectangle is entirely contained within the rectangular region represented by this RectangleF .

public bool Contains(RectangleF rectangle)

Parameters

rectangle RectangleF

The rectangle.

Returns

bool

The bool.

Contains(float, float)

Determines if the specfied point is contained within the rectangular region defined by this RectangleF.

public bool Contains(float x, float y)

Parameters

x float

The x-coordinate of the given point.

y float

The y-coordinate of the given point.

Returns

bool

The bool.

Deconstruct(out float, out float, out float, out float)

Deconstructs this rectangle into four floats.

public void Deconstruct(out float x, out float y, out float width, out float height)

Parameters

x float

The out value for X.

y float

The out value for Y.

width float

The out value for the width.

height float

The out value for the height.

Equals(RectangleF)

public bool Equals(RectangleF other)

Parameters

other RectangleF

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

FromLTRB(float, float, float, float)

Creates a new RectangleF with the specified location and size.

public static RectangleF FromLTRB(float left, float top, float right, float bottom)

Parameters

left float

The left coordinate of the rectangle.

top float

The top coordinate of the rectangle.

right float

The right coordinate of the rectangle.

bottom float

The bottom coordinate of the rectangle.

Returns

RectangleF

The RectangleF.

GetHashCode()

public override int GetHashCode()

Returns

int

Inflate(RectangleF, float, float)

Creates a RectangleF that is inflated by the specified amount.

public static RectangleF Inflate(RectangleF rectangle, float x, float y)

Parameters

rectangle RectangleF

The rectangle.

x float

The amount to inflate the width by.

y float

The amount to inflate the height by.

Returns

RectangleF

A new RectangleF.

Inflate(SizeF)

Inflates this RectangleF by the specified amount.

public void Inflate(SizeF size)

Parameters

size SizeF

The size.

Inflate(float, float)

Inflates this RectangleF by the specified amount.

public void Inflate(float width, float height)

Parameters

width float

The width.

height float

The height.

Intersect(RectangleF)

Creates a RectangleF that represents the intersection between this RectangleF and the rectangle.

public void Intersect(RectangleF rectangle)

Parameters

rectangle RectangleF

The rectangle.

Intersect(RectangleF, RectangleF)

Creates a rectangle that represents the intersection between a and b. If there is no intersection, an empty rectangle is returned.

public static RectangleF Intersect(RectangleF a, RectangleF b)

Parameters

a RectangleF

The first rectangle.

b RectangleF

The second rectangle.

Returns

RectangleF

The RectangleF.

IntersectsWith(RectangleF)

Determines if the specfied RectangleF intersects the rectangular region defined by this RectangleF.

public bool IntersectsWith(RectangleF rectangle)

Parameters

rectangle RectangleF

The other Rectange.

Returns

bool

The bool.

Offset(PointF)

Adjusts the location of this rectangle by the specified amount.

public void Offset(PointF point)

Parameters

point PointF

The point.

Offset(float, float)

Adjusts the location of this rectangle by the specified amount.

public void Offset(float dx, float dy)

Parameters

dx float

The amount to offset the x-coordinate.

dy float

The amount to offset the y-coordinate.

ToString()

public override string ToString()

Returns

string

Transform(RectangleF, Matrix3x2)

Transforms a rectangle by the given matrix.

public static RectangleF Transform(RectangleF rectangle, Matrix3x2 matrix)

Parameters

rectangle RectangleF

The source rectangle.

matrix Matrix3x2

The transformation matrix.

Returns

RectangleF

A transformed RectangleF.

Union(RectangleF, RectangleF)

Creates a rectangle that represents the union between a and b.

public static RectangleF Union(RectangleF a, RectangleF b)

Parameters

a RectangleF

The first rectangle.

b RectangleF

The second rectangle.

Returns

RectangleF

The RectangleF.

Operators

operator ==(RectangleF, RectangleF)

Compares two RectangleF objects for equality.

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

Parameters

left RectangleF

The RectangleF on the left side of the operand.

right RectangleF

The RectangleF on the right side of the operand.

Returns

bool

True if the current left is equal to the right parameter; otherwise, false.

explicit operator Rectangle(RectangleF)

Creates a Rectangle with the coordinates of the specified RectangleF by truncating each coordinate.

public static explicit operator Rectangle(RectangleF rectangle)

Parameters

rectangle RectangleF

The rectangle.

Returns

Rectangle

operator !=(RectangleF, RectangleF)

Compares two RectangleF objects for inequality.

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

Parameters

left RectangleF

The RectangleF on the left side of the operand.

right RectangleF

The RectangleF on the right side of the operand.

Returns

bool

True if the current left is unequal to the right parameter; otherwise, false.