Struct RectangleF
Stores a set of four single precision floating points that represent the location and size of a rectangle.
Implements
Inherited Members
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public struct RectangleF : IEquatable<RectangleF>
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.
Declaration
public RectangleF(PointF point, SizeF size)
Parameters
| Type | Name | Description |
|---|---|---|
| PointF | point | The Point which specifies the rectangles point in a two-dimensional plane. |
| SizeF | size | The SixLabors.ImageSharp.RectangleF.Size which specifies the rectangles height and width. |
RectangleF(float, float, float, float)
Initializes a new instance of the RectangleF struct.
Declaration
public RectangleF(float x, float y, float width, float height)
Parameters
| Type | Name | Description |
|---|---|---|
| float | x | The horizontal position of the rectangle. |
| float | y | The vertical position of the rectangle. |
| float | width | The width of the rectangle. |
| float | height | The height of the rectangle. |
Fields
Empty
Represents a RectangleF that has X, Y, Width, and Height values set to zero.
Declaration
public static readonly RectangleF Empty
Field Value
| Type | Description |
|---|---|
| RectangleF |
Properties
Bottom
Gets the y-coordinate of the bottom edge of this RectangleF.
Declaration
public float Bottom { get; }
Property Value
| Type | Description |
|---|---|
| float |
Height
Gets or sets the height of this RectangleF.
Declaration
public float Height { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Left
Gets the x-coordinate of the left edge of this RectangleF.
Declaration
public float Left { get; }
Property Value
| Type | Description |
|---|---|
| float |
Right
Gets the x-coordinate of the right edge of this RectangleF.
Declaration
public float Right { get; }
Property Value
| Type | Description |
|---|---|
| float |
Top
Gets the y-coordinate of the top edge of this RectangleF.
Declaration
public float Top { get; }
Property Value
| Type | Description |
|---|---|
| float |
Width
Gets or sets the width of this RectangleF.
Declaration
public float Width { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| float |
X
Gets or sets the x-coordinate of this RectangleF.
Declaration
public float X { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Y
Gets or sets the y-coordinate of this RectangleF.
Declaration
public float Y { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
Center(RectangleF)
Returns the center point of the given RectangleF.
Declaration
public static PointF Center(RectangleF rectangle)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | rectangle | The rectangle. |
Returns
| Type | Description |
|---|---|
| PointF | The Point. |
Contains(PointF)
Determines if the specified point is contained within the rectangular region defined by this RectangleF .
Declaration
public bool Contains(PointF point)
Parameters
| Type | Name | Description |
|---|---|---|
| PointF | point | The point. |
Returns
| Type | Description |
|---|---|
| bool | The bool. |
Contains(RectangleF)
Determines if the rectangular region represented by rectangle is entirely contained
within the rectangular region represented by this RectangleF .
Declaration
public bool Contains(RectangleF rectangle)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | rectangle | The rectangle. |
Returns
| Type | Description |
|---|---|
| bool | The bool. |
Contains(float, float)
Determines if the specfied point is contained within the rectangular region defined by this RectangleF.
Declaration
public bool Contains(float x, float y)
Parameters
| Type | Name | Description |
|---|---|---|
| float | x | The x-coordinate of the given point. |
| float | y | The y-coordinate of the given point. |
Returns
| Type | Description |
|---|---|
| bool | The bool. |
Deconstruct(out float, out float, out float, out float)
Deconstructs this rectangle into four floats.
Declaration
public void Deconstruct(out float x, out float y, out float width, out float height)
Parameters
| Type | Name | Description |
|---|---|---|
| float | x | The out value for X. |
| float | y | The out value for Y. |
| float | width | The out value for the width. |
| float | height | The out value for the height. |
Equals(RectangleF)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(RectangleF other)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | other | An object to compare with this object. |
Returns
| Type | Description |
|---|---|
| bool | true if the current object is equal to the |
Equals(object?)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool | true if |
Overrides
FromLTRB(float, float, float, float)
Creates a new RectangleF with the specified location and size.
Declaration
public static RectangleF FromLTRB(float left, float top, float right, float bottom)
Parameters
| Type | Name | Description |
|---|---|---|
| float | left | The left coordinate of the rectangle. |
| float | top | The top coordinate of the rectangle. |
| float | right | The right coordinate of the rectangle. |
| float | bottom | The bottom coordinate of the rectangle. |
Returns
| Type | Description |
|---|---|
| RectangleF | The RectangleF. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
Inflate(RectangleF, float, float)
Creates a RectangleF that is inflated by the specified amount.
Declaration
public static RectangleF Inflate(RectangleF rectangle, float x, float y)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | rectangle | The rectangle. |
| float | x | The amount to inflate the width by. |
| float | y | The amount to inflate the height by. |
Returns
| Type | Description |
|---|---|
| RectangleF | A new RectangleF. |
Inflate(SizeF)
Inflates this RectangleF by the specified amount.
Declaration
public void Inflate(SizeF size)
Parameters
| Type | Name | Description |
|---|---|---|
| SizeF | size | The size. |
Inflate(float, float)
Inflates this RectangleF by the specified amount.
Declaration
public void Inflate(float width, float height)
Parameters
| Type | Name | Description |
|---|---|---|
| float | width | The width. |
| float | height | The height. |
Intersect(RectangleF)
Creates a RectangleF that represents the intersection between this RectangleF and the rectangle.
Declaration
public void Intersect(RectangleF rectangle)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | rectangle | 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.
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 RectangleF. |
IntersectsWith(RectangleF)
Determines if the specfied RectangleF intersects the rectangular region defined by this RectangleF.
Declaration
public bool IntersectsWith(RectangleF rectangle)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | rectangle | The other Rectange. |
Returns
| Type | Description |
|---|---|
| bool | The bool. |
Offset(PointF)
Adjusts the location of this rectangle by the specified amount.
Declaration
public void Offset(PointF point)
Parameters
| Type | Name | Description |
|---|---|---|
| PointF | point | The point. |
Offset(float, float)
Adjusts the location of this rectangle by the specified amount.
Declaration
public void Offset(float dx, float dy)
Parameters
| Type | Name | Description |
|---|---|---|
| float | dx | The amount to offset the x-coordinate. |
| float | dy | The amount to offset the y-coordinate. |
ToString()
Returns the fully qualified type name of this instance.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The fully qualified type name. |
Overrides
Transform(RectangleF, Matrix3x2)
Transforms a rectangle by the given matrix.
Declaration
public static RectangleF Transform(RectangleF rectangle, Matrix3x2 matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | rectangle | The source rectangle. |
| Matrix3x2 | matrix | The transformation matrix. |
Returns
| Type | Description |
|---|---|
| RectangleF | A transformed RectangleF. |
Union(RectangleF, RectangleF)
Creates a rectangle that represents the union between a and b.
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 RectangleF. |
Operators
operator ==(RectangleF, RectangleF)
Compares two RectangleF objects for equality.
Declaration
public static bool operator ==(RectangleF left, RectangleF right)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | left | The RectangleF on the left side of the operand. |
| RectangleF | right | The RectangleF on the right side of the operand. |
Returns
| Type | Description |
|---|---|
| bool | True if the current left is equal to the |
explicit operator Rectangle(RectangleF)
Creates a Rectangle with the coordinates of the specified RectangleF by truncating each coordinate.
Declaration
public static explicit operator Rectangle(RectangleF rectangle)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | rectangle | The rectangle. |
Returns
| Type | Description |
|---|---|
| Rectangle |
operator !=(RectangleF, RectangleF)
Compares two RectangleF objects for inequality.
Declaration
public static bool operator !=(RectangleF left, RectangleF right)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | left | The RectangleF on the left side of the operand. |
| RectangleF | right | The RectangleF on the right side of the operand. |
Returns
| Type | Description |
|---|---|
| bool | True if the current left is unequal to the |