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
PointFThe Point which specifies the rectangles point in a two-dimensional plane.
size
SizeFThe 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
floatThe horizontal position of the rectangle.
y
floatThe vertical position of the rectangle.
width
floatThe width of the rectangle.
height
floatThe 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
rectangle
RectangleFThe 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
point
PointFThe 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
rectangle
RectangleFThe 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
x
floatThe out value for X.
y
floatThe out value for Y.
width
floatThe out value for the width.
height
floatThe out value for the height.
Equals(RectangleF)
public bool Equals(RectangleF other)
Parameters
other
RectangleF
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj
object
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
left
floatThe left coordinate of the rectangle.
top
floatThe top coordinate of the rectangle.
right
floatThe right coordinate of the rectangle.
bottom
floatThe 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
rectangle
RectangleFThe rectangle.
x
floatThe amount to inflate the width by.
y
floatThe 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
SizeFThe 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
rectangle
RectangleFThe 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
RectangleFThe first rectangle.
b
RectangleFThe 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
RectangleFThe other Rectange.
Returns
Offset(PointF)
Adjusts the location of this rectangle by the specified amount.
public void Offset(PointF point)
Parameters
point
PointFThe 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
rectangle
RectangleFThe source rectangle.
matrix
Matrix3x2The 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
RectangleFThe first rectangle.
b
RectangleFThe 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
RectangleFThe RectangleF on the left side of the operand.
right
RectangleFThe 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
RectangleFThe rectangle.
Returns
operator !=(RectangleF, RectangleF)
Compares two RectangleF objects for inequality.
public static bool operator !=(RectangleF left, RectangleF right)
Parameters
left
RectangleFThe RectangleF on the left side of the operand.
right
RectangleFThe RectangleF on the right side of the operand.
Returns
- bool
True if the current left is unequal to the
right
parameter; otherwise, false.