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
| Improve this Doc View SourceRectangleF(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(Single, Single, Single, Single)
Initializes a new instance of the RectangleF struct.
Declaration
public RectangleF(float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
Single | x | The horizontal position of the rectangle. |
Single | y | The vertical position of the rectangle. |
Single | width | The width of the rectangle. |
Single | height | The height of the rectangle. |
Fields
| Improve this Doc View SourceEmpty
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
| Improve this Doc View SourceBottom
Gets the y-coordinate of the bottom edge of this RectangleF.
Declaration
public readonly float Bottom { get; }
Property Value
Type | Description |
---|---|
Single |
Height
Gets or sets the height of this RectangleF.
Declaration
public float Height { readonly get; set; }
Property Value
Type | Description |
---|---|
Single |
Left
Gets the x-coordinate of the left edge of this RectangleF.
Declaration
public readonly float Left { get; }
Property Value
Type | Description |
---|---|
Single |
Right
Gets the x-coordinate of the right edge of this RectangleF.
Declaration
public readonly float Right { get; }
Property Value
Type | Description |
---|---|
Single |
Top
Gets the y-coordinate of the top edge of this RectangleF.
Declaration
public readonly float Top { get; }
Property Value
Type | Description |
---|---|
Single |
Width
Gets or sets the width of this RectangleF.
Declaration
public float Width { readonly get; set; }
Property Value
Type | Description |
---|---|
Single |
X
Gets or sets the x-coordinate of this RectangleF.
Declaration
public float X { readonly get; set; }
Property Value
Type | Description |
---|---|
Single |
Y
Gets or sets the y-coordinate of this RectangleF.
Declaration
public float Y { readonly get; set; }
Property Value
Type | Description |
---|---|
Single |
Methods
| Improve this Doc View SourceCenter(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 |
---|---|
Boolean | The Boolean. |
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 |
---|---|
Boolean | The Boolean. |
Contains(Single, Single)
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 |
---|---|---|
Single | x | The x-coordinate of the given point. |
Single | y | The y-coordinate of the given point. |
Returns
Type | Description |
---|---|
Boolean | The Boolean. |
Deconstruct(out Single, out Single, out Single, out Single)
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 |
---|---|---|
Single | x | The out value for X. |
Single | y | The out value for Y. |
Single | width | The out value for the width. |
Single | height | The out value for the height. |
Equals(RectangleF)
Declaration
public bool Equals(RectangleF other)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | other |
Returns
Type | Description |
---|---|
Boolean |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceFromLTRB(Single, Single, Single, Single)
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 |
---|---|---|
Single | left | The left coordinate of the rectangle. |
Single | top | The top coordinate of the rectangle. |
Single | right | The right coordinate of the rectangle. |
Single | bottom | The bottom coordinate of the rectangle. |
Returns
Type | Description |
---|---|
RectangleF | The RectangleF. |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
| Improve this Doc View SourceInflate(RectangleF, Single, Single)
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. |
Single | x | The amount to inflate the width by. |
Single | 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(Single, Single)
Inflates this RectangleF by the specified amount.
Declaration
public void Inflate(float width, float height)
Parameters
Type | Name | Description |
---|---|---|
Single | width | The width. |
Single | 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 |
---|---|
Boolean | The Boolean. |
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(Single, Single)
Adjusts the location of this rectangle by the specified amount.
Declaration
public void Offset(float dx, float dy)
Parameters
Type | Name | Description |
---|---|---|
Single | dx | The amount to offset the x-coordinate. |
Single | dy | The amount to offset the y-coordinate. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
| Improve this Doc View SourceTransform(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
| Improve this Doc View SourceEquality(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 |
---|---|
Boolean | True if the current left is equal to the |
Explicit(RectangleF to Rectangle)
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 |
Inequality(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 |
---|---|
Boolean | True if the current left is unequal to the |