Search Results for

    Show / Hide Table of Contents

    Struct RectangleF

    Stores a set of four floating-point numbers that represent the location and size of a rectangle.

    Implements
    IEquatable<RectangleF>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Evergine.Mathematics
    Assembly: Evergine.Mathematics.dll
    Syntax
    public struct RectangleF : IEquatable<RectangleF>

    Constructors

    RectangleF(float, float, float, float)

    Initializes a new instance of the RectangleF struct with the specified location and size.

    Declaration
    public RectangleF(float x, float y, float width, float height)
    Parameters
    Type Name Description
    float x

    The x-coordinate of the upper-left corner of the rectangle.

    float y

    The y-coordinate of the upper-left corner of the rectangle.

    float width

    The width of the rectangle.

    float height

    The height of the rectangle.

    Fields

    Height

    Gets or sets the height of this RectangleF structure. The default is 0.

    Declaration
    public float Height
    Field Value
    Type Description
    float

    Width

    Gets or sets the width of this RectangleF structure. The default is 0.

    Declaration
    public float Width
    Field Value
    Type Description
    float

    X

    Gets or sets the x-coordinate of the upper-left corner of this RectangleF structure. The default is 0.

    Declaration
    public float X
    Field Value
    Type Description
    float

    Y

    Gets or sets the y-coordinate of the upper-left corner of this RectangleF structure. The default is 0.

    Declaration
    public float Y
    Field Value
    Type Description
    float

    Properties

    Bottom

    Gets the y-coordinate that is the sum of Y and Height of this RectangleF structure.

    Declaration
    public float Bottom { get; }
    Property Value
    Type Description
    float

    Center

    Gets the coordinates of the center of this RectangleF structure.

    Declaration
    public Vector2 Center { get; }
    Property Value
    Type Description
    Vector2

    A Vector2 that represents the center of this RectangleF structure.

    Empty

    Gets an instance of the RectangleF class with its members uninitialized.

    Declaration
    public static RectangleF Empty { get; }
    Property Value
    Type Description
    RectangleF
    Remarks

    The members of the new RectangleF are left uninitialized.

    IsEmpty

    Gets a value indicating whether the Width or Height property of this RectangleF has a value of zero.

    Declaration
    public bool IsEmpty { get; }
    Property Value
    Type Description
    bool

    . This property returns true if the Width or Height property of this RectangleF has a value of zero; otherwise, false.

    Left

    Gets the x-coordinate of the left edge of this RectangleF structure.

    Declaration
    public float Left { get; }
    Property Value
    Type Description
    float

    Location

    Gets or sets the coordinates of the upper-left corner of this RectangleF structure.

    Declaration
    public Vector2 Location { get; set; }
    Property Value
    Type Description
    Vector2

    A Vector2 that represents the upper-left corner of this RectangleF structure.

    Right

    Gets the x-coordinate that is the sum of X and Width of this RectangleF structure.

    Declaration
    public float Right { get; }
    Property Value
    Type Description
    float

    Top

    Gets the y-coordinate of the top edge of this RectangleF structure.

    Declaration
    public float Top { get; }
    Property Value
    Type Description
    float

    Methods

    Contains(RectangleF)

    Determines if the rectangular region represented by rect is entirely contained within this RectangleF structure.

    Declaration
    public bool Contains(RectangleF rect)
    Parameters
    Type Name Description
    RectangleF rect

    The RectangleF to test.

    Returns
    Type Description
    bool

    This method returns true if the rectangular region represented by rect is entirely contained within the rectangular region represented by this RectangleF; otherwise false.

    Contains(ref RectangleF, out bool)

    Determines if the rectangular region represented by rect is entirely contained within this RectangleF structure.

    Declaration
    public void Contains(ref RectangleF rect, out bool result)
    Parameters
    Type Name Description
    RectangleF rect

    The RectangleF to test.

    bool result

    if set to true the rectangular region represented by rect is entirely contained within this RectangleF structure.

    Contains(Vector2)

    Determines if the specified point is contained within this RectangleF structure.

    Declaration
    public bool Contains(Vector2 pt)
    Parameters
    Type Name Description
    Vector2 pt

    The Vector2 to test.

    Returns
    Type Description
    bool

    This method returns true if the point represented by the pt parameter is contained within this RectangleF structure; otherwise false.

    Contains(ref Vector2, out bool)

    Determines if the specified point is contained within this RectangleF structure.

    Declaration
    public void Contains(ref Vector2 pt, out bool result)
    Parameters
    Type Name Description
    Vector2 pt

    The Vector2 to test.

    bool result

    if set to true the point represented by the pt parameter is contained within this RectangleF structure; otherwise false.

    Contains(float, float)

    Determines if the specified point is contained within this RectangleF structure.

    Declaration
    public bool Contains(float x, float y)
    Parameters
    Type Name Description
    float x

    The x-coordinate of the point to test.

    float y

    The y-coordinate of the point to test.

    Returns
    Type Description
    bool

    This method returns true if the point defined by x and y is contained within this RectangleF structure; otherwise false.

    Equals(RectangleF)

    Tests whether other has the same location and size of this RectangleF.

    Declaration
    public bool Equals(RectangleF other)
    Parameters
    Type Name Description
    RectangleF other

    The RectangleF to test.

    Returns
    Type Description
    bool

    This method returns true if other has its X, Y, Width, and Height properties equal to the corresponding properties of this RectangleF; otherwise, false.

    Equals(ref RectangleF)

    Tests whether other has the same location and size of this RectangleF.

    Declaration
    public bool Equals(ref RectangleF other)
    Parameters
    Type Name Description
    RectangleF other

    The RectangleF to test.

    Returns
    Type Description
    bool

    This method returns true if other has its X, Y, Width, and Height properties equal to the corresponding properties of this RectangleF; otherwise, false.

    Equals(object)

    Tests whether obj is a RectangleF with the same location and size of this RectangleF.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    The object to test.

    Returns
    Type Description
    bool

    This method returns true if obj is a RectangleF and its X, Y, Width, and Height properties are equal to the corresponding properties of this RectangleF; otherwise, false.

    Overrides
    ValueType.Equals(object)

    GetHashCode()

    Gets the hash code for this RectangleF structure. For information about the use of hash codes, see GetHashCode().

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

    Overrides
    ValueType.GetHashCode()

    GetPoints()

    Gets the corner points of this RectangleF structure.

    Declaration
    public Vector2[] GetPoints()
    Returns
    Type Description
    Vector2[]

    A Vector2[] that represents the corner points of this RectangleF structure.

    Inflate(float, float)

    Enlarges this RectangleF structure by the specified amount.

    Declaration
    public void Inflate(float horizontalAmount, float verticalAmount)
    Parameters
    Type Name Description
    float horizontalAmount

    The amount to inflate this RectangleF structure horizontally.

    float verticalAmount

    The amount to inflate this RectangleF structure vertically.

    Remarks

    This method enlarges this rectangle, not a copy of it. The rectangle is enlarged in both directions along an axis. For example, if a 50 by 50 rectangle is inflated by 50 in the x-axis, the resultant rectangle will be 150 units long (the original 50, the 50 in the minus direction, and the 50 in the plus direction) maintaining the rectangle's geometric center. If either x or y is negative, the RectangleF is deflated in the corresponding direction.

    Intersect(RectangleF, RectangleF)

    Returns a RectangleF structure that represents the intersection of two rectangles. If there is no intersection, and empty RectangleF is returned.

    Declaration
    public static RectangleF Intersect(RectangleF a, RectangleF b)
    Parameters
    Type Name Description
    RectangleF a

    A rectangle to intersect.

    RectangleF b

    A second rectangle to intersect.

    Returns
    Type Description
    RectangleF

    A third RectangleF structure the size of which represents the overlapped area of the two specified rectangles.

    Intersect(ref RectangleF, ref RectangleF, out RectangleF)

    Calculates a RectangleF structure that represents the intersection of two rectangles. If there is no intersection, and empty RectangleF is returned.

    Declaration
    public static void Intersect(ref RectangleF a, ref RectangleF b, out RectangleF result)
    Parameters
    Type Name Description
    RectangleF a

    A rectangle to intersect.

    RectangleF b

    A second rectangle to intersect.

    RectangleF result

    A rectangle that represents the intersection of two rectangles.

    Intersects(RectangleF)

    Determines if this rectangle intersects with rect.

    Declaration
    public bool Intersects(RectangleF rect)
    Parameters
    Type Name Description
    RectangleF rect

    The rectangle to test.

    Returns
    Type Description
    bool

    This method returns true if there is any intersection.

    Intersects(ref RectangleF, out bool)

    Determines if this rectangle intersects with rect.

    Declaration
    public void Intersects(ref RectangleF rect, out bool result)
    Parameters
    Type Name Description
    RectangleF rect

    The rectangle to test.

    bool result

    if set to true there is any intersection.

    Offset(Vector2)

    Adjusts the location of this rectangle by the specified amount.

    Declaration
    public void Offset(Vector2 amount)
    Parameters
    Type Name Description
    Vector2 amount

    The amount to offset the location.

    Offset(float, float)

    Adjusts the location of this rectangle by the specified amount.

    Declaration
    public void Offset(float offsetX, float offsetY)
    Parameters
    Type Name Description
    float offsetX

    The amount to offset the location horizontally.

    float offsetY

    The amount to offset the location vertically.

    ToString()

    Converts the Location and Size of this RectangleF to a human-readable string.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string that contains the position, width, and height of this RectangleF structure. For example, "{X:20, Y:20, Width:100, Height:50}".

    Overrides
    ValueType.ToString()

    ToVector4()

    Converts the X, Y, Width and Height of this RectangleF to a Vector4 structure.

    Declaration
    public Vector4 ToVector4()
    Returns
    Type Description
    Vector4

    A Vector4 that contains the X, Y, Width, Height, of this RectangleF to a Vector4 structure.

    ToVector4(ref Vector4)

    Converts the X, Y, Width and Height of this RectangleF to a Vector4 structure.

    Declaration
    public void ToVector4(ref Vector4 vector)
    Parameters
    Type Name Description
    Vector4 vector

    Vector4 reference to pass RectangleF values.

    Union(RectangleF, RectangleF)

    Creates the smallest possible third rectangle that can contain both of two rectangles that form a union.

    Declaration
    public static RectangleF Union(RectangleF a, RectangleF b)
    Parameters
    Type Name Description
    RectangleF a

    A rectangle to union.

    RectangleF b

    A second rectangle to union.

    Returns
    Type Description
    RectangleF

    A third RectangleF structure that contains both of the two rectangles that form the union.

    Union(ref RectangleF, ref RectangleF, out RectangleF)

    Calculates the smallest possible third rectangle that can contain both of two rectangles that form a union.

    Declaration
    public static void Union(ref RectangleF a, ref RectangleF b, out RectangleF result)
    Parameters
    Type Name Description
    RectangleF a

    A rectangle to union.

    RectangleF b

    A second rectangle to union.

    RectangleF result

    The smallest possible third rectangle that can contain both of two rectangles that form a union.

    Operators

    operator ==(RectangleF, RectangleF)

    Tests whether two RectangleF structures have equal location and size.

    Declaration
    public static bool operator ==(RectangleF left, RectangleF right)
    Parameters
    Type Name Description
    RectangleF left

    The RectangleF structure that is to the left of the inequality operator.

    RectangleF right

    The RectangleF structure that is to the right of the inequality operator.

    Returns
    Type Description
    bool

    This operator returns true the two specified RectangleF structures have equal X , Y, Width, and Height properties; otherwise false.

    implicit operator RectangleF(Rectangle)

    Converts the specified Rectangle structure to a RectangleF structure.

    Declaration
    public static implicit operator RectangleF(Rectangle r)
    Parameters
    Type Name Description
    Rectangle r

    The rectangle.

    Returns
    Type Description
    RectangleF

    The RectangleF structure that is converted from the specified Rectangle structure.

    operator !=(RectangleF, RectangleF)

    Tests whether two RectangleF structures differ in location or size.

    Declaration
    public static bool operator !=(RectangleF left, RectangleF right)
    Parameters
    Type Name Description
    RectangleF left

    The RectangleF structure that is to the left of the inequality operator.

    RectangleF right

    The RectangleF structure that is to the right of the inequality operator.

    Returns
    Type Description
    bool

    This operator returns true if any of the X , Y, Width, or Height properties of the two RectangleF structures are unequal; otherwise false.

    Implements

    IEquatable<T>

    Extension Methods

    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In This Article
    Back to top
    Generated by DocFX