Struct RectangleF
- Namespace
- HelixToolkit.Maths
- Assembly
- HelixToolkit.Maths.dll
Define a RectangleF. This structure is slightly different from System.Drawing.RectangleF as it is internally storing Left,Top,Right,Bottom instead of Left,Top,Width,Height.
public struct RectangleF : IEquatable<RectangleF>
- Implements
- Inherited Members
- Extension Methods
Constructors
RectangleF(float, float, float, float)
Initializes a new instance of the RectangleF struct.
public RectangleF(float x, float y, float width, float height)
Parameters
Fields
Bottom
The bottom.
public float Bottom
Field Value
Empty
An empty rectangle.
public static readonly RectangleF Empty
Field Value
Infinite
An infinite rectangle. See remarks.
public static readonly RectangleF Infinite
Field Value
Remarks
http://msdn.microsoft.com/en-us/library/windows/desktop/dd372261%28v=vs.85%29.aspx Any properties that involve computations, like Center, Width or Height may return incorrect results - NaN.
Left
The left.
public float Left
Field Value
Right
The right.
public float Right
Field Value
Top
The top.
public float Top
Field Value
Properties
BottomLeft
Gets the position of the bottom-left corner of the rectangle.
public readonly Vector2 BottomLeft { get; }
Property Value
- Vector2
The bottom-left corner of the rectangle.
BottomRight
Gets the position of the bottom-right corner of the rectangle.
public readonly Vector2 BottomRight { get; }
Property Value
- Vector2
The bottom-right corner of the rectangle.
Center
Gets the Point that specifies the center of the rectangle.
public readonly Vector2 Center { get; }
Property Value
- Vector2
The center.
Height
Gets or sets the height.
public float Height { readonly get; set; }
Property Value
- float
The height.
IsEmpty
Gets a value that indicates whether the rectangle is empty.
public readonly bool IsEmpty { get; }
Property Value
- bool
trueif [is empty]; otherwise,false.
Location
Gets or sets the location.
public Vector2 Location { readonly get; set; }
Property Value
- Vector2
The location.
TopLeft
Gets the position of the top-left corner of the rectangle.
public readonly Vector2 TopLeft { get; }
Property Value
- Vector2
The top-left corner of the rectangle.
TopRight
Gets the position of the top-right corner of the rectangle.
public readonly Vector2 TopRight { get; }
Property Value
- Vector2
The top-right corner of the rectangle.
Width
Gets or sets the width.
public float Width { readonly get; set; }
Property Value
- float
The width.
X
Gets or sets the X position.
public float X { readonly get; set; }
Property Value
- float
The X position.
Y
Gets or sets the Y position.
public float Y { readonly get; set; }
Property Value
- float
The Y position.
Methods
Contains(Rectangle)
Determines whether this rectangle entirely contains a specified rectangle.
public readonly bool Contains(Rectangle value)
Parameters
valueRectangleThe rectangle to evaluate.
Returns
Contains(ref RectangleF, out bool)
Determines whether this rectangle entirely contains a specified rectangle.
public readonly void Contains(ref RectangleF value, out bool result)
Parameters
valueRectangleFThe rectangle to evaluate.
resultbool[OutAttribute] On exit, is true if this rectangle entirely contains the specified rectangle, or false if not.
Contains(Vector2)
Checks, if specified Vector2 is inside RectangleF.
public readonly bool Contains(Vector2 vector2D)
Parameters
Returns
- bool
trueif Vector2 is inside RectangleF, otherwisefalse.
Contains(ref Vector2, out bool)
Determines whether this rectangle contains a specified Point.
public readonly void Contains(ref Vector2 value, out bool result)
Parameters
valueVector2The Point to evaluate.
resultbool[OutAttribute] true if the specified Point is contained within this rectangle; false otherwise.
Contains(float, float)
Checks, if specified point is inside RectangleF.
public readonly bool Contains(float x, float y)
Parameters
Returns
- bool
trueif point is inside RectangleF, otherwisefalse.
Equals(RectangleF)
Determines whether the specified RectangleF is equal to this instance.
public readonly bool Equals(RectangleF other)
Parameters
otherRectangleFThe RectangleF to compare with this instance.
Returns
- bool
trueif the specified RectangleF is equal to this instance; otherwise,false.
Equals(ref RectangleF)
Determines whether the specified RectangleF is equal to this instance.
public readonly bool Equals(ref RectangleF other)
Parameters
otherRectangleFThe RectangleF to compare with this instance.
Returns
- bool
trueif the specified RectangleF is equal to this instance; otherwise,false.
Equals(object?)
Determines whether the specified object is equal to this instance.
public override readonly bool Equals(object? obj)
Parameters
Returns
GetHashCode()
Returns a hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Inflate(float, float)
Pushes the edges of the rectangle out by the horizontal and vertical values specified.
public void Inflate(float horizontalAmount, float verticalAmount)
Parameters
horizontalAmountfloatValue to push the sides out by.
verticalAmountfloatValue to push the top and bottom out by.
Intersect(RectangleF, RectangleF)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
public static RectangleF Intersect(RectangleF value1, RectangleF value2)
Parameters
value1RectangleFThe first Rectangle to compare.
value2RectangleFThe second Rectangle to compare.
Returns
- RectangleF
The intersection rectangle.
Intersect(ref RectangleF, ref RectangleF, out RectangleF)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
public static void Intersect(ref RectangleF value1, ref RectangleF value2, out RectangleF result)
Parameters
value1RectangleFThe first rectangle to compare.
value2RectangleFThe second rectangle to compare.
resultRectangleF[OutAttribute] The area where the two first parameters overlap.
Intersects(RectangleF)
Determines whether a specified rectangle intersects with this rectangle.
public readonly bool Intersects(RectangleF value)
Parameters
valueRectangleFThe rectangle to evaluate.
Returns
Intersects(ref RectangleF, out bool)
Determines whether a specified rectangle intersects with this rectangle.
public readonly void Intersects(ref RectangleF value, out bool result)
Parameters
valueRectangleFThe rectangle to evaluate
resultbool[OutAttribute] true if the specified rectangle intersects with this one; false otherwise.
Offset(Vector2)
Changes the position of the rectangle.
public void Offset(Vector2 amount)
Parameters
amountVector2The values to adjust the position of the rectangle by.
Offset(float, float)
Changes the position of the rectangle.
public void Offset(float offsetX, float offsetY)
Parameters
Size()
public readonly Vector2 Size()
Returns
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
The fully qualified type name.
Union(RectangleF, RectangleF)
Creates a new rectangle that exactly contains two other rectangles.
public static RectangleF Union(RectangleF value1, RectangleF value2)
Parameters
value1RectangleFThe first rectangle to contain.
value2RectangleFThe second rectangle to contain.
Returns
- RectangleF
The union rectangle.
Union(ref RectangleF, ref RectangleF, out RectangleF)
Creates a new rectangle that exactly contains two other rectangles.
public static void Union(ref RectangleF value1, ref RectangleF value2, out RectangleF result)
Parameters
value1RectangleFThe first rectangle to contain.
value2RectangleFThe second rectangle to contain.
resultRectangleF[OutAttribute] The rectangle that must be the union of the first two rectangles.
Operators
operator ==(RectangleF, RectangleF)
Implements the operator ==.
public static bool operator ==(RectangleF left, RectangleF right)
Parameters
leftRectangleFThe left.
rightRectangleFThe right.
Returns
- bool
The result of the operator.
explicit operator Rectangle(RectangleF)
Performs an explicit conversion to Rectangle structure.
public static explicit operator Rectangle(RectangleF value)
Parameters
valueRectangleFThe source RectangleF value.
Returns
Remarks
Performs direct float to int conversion, any fractional data is truncated.
operator !=(RectangleF, RectangleF)
Implements the operator !=.
public static bool operator !=(RectangleF left, RectangleF right)
Parameters
leftRectangleFThe left.
rightRectangleFThe right.
Returns
- bool
The result of the operator.