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
pointPointFThe Point which specifies the rectangles point in a two-dimensional plane.
sizeSizeFThe 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
xfloatThe horizontal position of the rectangle.
yfloatThe vertical position of the rectangle.
widthfloatThe width of the rectangle.
heightfloatThe 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
Properties
Bottom
Gets the y-coordinate of the bottom edge of this RectangleF.
public float Bottom { get; }
Property Value
Height
Gets or sets the height of this RectangleF.
public float Height { readonly get; set; }
Property Value
Left
Gets the x-coordinate of the left edge of this RectangleF.
public float Left { get; }
Property Value
Right
Gets the x-coordinate of the right edge of this RectangleF.
public float Right { get; }
Property Value
Top
Gets the y-coordinate of the top edge of this RectangleF.
public float Top { get; }
Property Value
Width
Gets or sets the width of this RectangleF.
public float Width { readonly get; set; }
Property Value
X
Gets or sets the x-coordinate of this RectangleF.
public float X { readonly get; set; }
Property Value
Y
Gets or sets the y-coordinate of this RectangleF.
public float Y { readonly get; set; }
Property Value
Methods
Center(RectangleF)
Returns the center point of the given RectangleF.
public static PointF Center(RectangleF rectangle)
Parameters
rectangleRectangleFThe rectangle.
Returns
Contains(PointF)
Determines if the specified point is contained within the rectangular region defined by this RectangleF .
public bool Contains(PointF point)
Parameters
pointPointFThe point.
Returns
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
rectangleRectangleFThe rectangle.
Returns
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
Returns
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
xfloatThe out value for X.
yfloatThe out value for Y.
widthfloatThe out value for the width.
heightfloatThe out value for the height.
Equals(RectangleF)
public bool Equals(RectangleF other)
Parameters
otherRectangleF
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
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
leftfloatThe left coordinate of the rectangle.
topfloatThe top coordinate of the rectangle.
rightfloatThe right coordinate of the rectangle.
bottomfloatThe bottom coordinate of the rectangle.
Returns
- RectangleF
The RectangleF.
GetHashCode()
public override int GetHashCode()
Returns
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
rectangleRectangleFThe rectangle.
xfloatThe amount to inflate the width by.
yfloatThe 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
sizeSizeFThe size.
Inflate(float, float)
Inflates this RectangleF by the specified amount.
public void Inflate(float width, float height)
Parameters
Intersect(RectangleF)
Creates a RectangleF that represents the intersection between this RectangleF and the rectangle.
public void Intersect(RectangleF rectangle)
Parameters
rectangleRectangleFThe 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
aRectangleFThe first rectangle.
bRectangleFThe 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
rectangleRectangleFThe other Rectange.
Returns
Offset(PointF)
Adjusts the location of this rectangle by the specified amount.
public void Offset(PointF point)
Parameters
pointPointFThe point.
Offset(float, float)
Adjusts the location of this rectangle by the specified amount.
public void Offset(float dx, float dy)
Parameters
ToString()
public override string ToString()
Returns
Transform(RectangleF, Matrix3x2)
Transforms a rectangle by the given matrix.
public static RectangleF Transform(RectangleF rectangle, Matrix3x2 matrix)
Parameters
rectangleRectangleFThe source rectangle.
matrixMatrix3x2The 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
aRectangleFThe first rectangle.
bRectangleFThe 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
leftRectangleFThe RectangleF on the left side of the operand.
rightRectangleFThe RectangleF on the right side of the operand.
Returns
- bool
True if the current left is equal to the
rightparameter; 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
rectangleRectangleFThe rectangle.
Returns
operator !=(RectangleF, RectangleF)
Compares two RectangleF objects for inequality.
public static bool operator !=(RectangleF left, RectangleF right)
Parameters
leftRectangleFThe RectangleF on the left side of the operand.
rightRectangleFThe RectangleF on the right side of the operand.
Returns
- bool
True if the current left is unequal to the
rightparameter; otherwise, false.