Search Results for

    Show / Hide Table of Contents

    Class Rectangle

    Describes rectangle in 2D space defines by location of its upper-left corner and the size.

    Inheritance
    System.Object
    Rectangle
    Implements
    System.IEquatable<Rectangle>
    Namespace: FlaxEngine
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [Unmanaged]
    public sealed class Rectangle : ValueType, IEquatable<Rectangle>

    Constructors

    Rectangle(Float2, Float2)

    Init

    Declaration
    public Rectangle(Float2 location, Float2 size)
    Parameters
    Float2 location

    Location of the upper left corner

    Float2 size

    Size

    Rectangle(Float2, Single, Single)

    Init

    Declaration
    public Rectangle(Float2 location, float width, float height)
    Parameters
    Float2 location

    Location of the upper left corner

    System.Single width

    Width

    System.Single height

    Height

    Rectangle(Single, Single, Float2)

    Init

    Declaration
    public Rectangle(float x, float y, Float2 size)
    Parameters
    System.Single x

    X coordinate

    System.Single y

    Y coordinate

    Float2 size

    Size

    Rectangle(Single, Single, Single, Single)

    Init

    Declaration
    public Rectangle(float x, float y, float width, float height)
    Parameters
    System.Single x

    X coordinate

    System.Single y

    Y coordinate

    System.Single width

    Width

    System.Single height

    Height

    Fields

    Empty

    A Rectangle which represents an empty space.

    Declaration
    public static readonly Rectangle Empty
    Field Value
    Rectangle

    Location

    Rectangle location (coordinates of the upper-left corner)

    Declaration
    public Float2 Location
    Field Value
    Float2

    Size

    Rectangle size

    Declaration
    public Float2 Size
    Field Value
    Float2

    Properties

    Bottom

    Gets Y coordinate of the bottom edge of the rectangle

    Declaration
    public float Bottom { get; }
    Property Value
    System.Single

    BottomLeft

    Gets position of the bottom left corner of the rectangle

    Declaration
    public Float2 BottomLeft { get; }
    Property Value
    Float2

    BottomRight

    Gets position of the bottom right corner of the rectangle

    Declaration
    public Float2 BottomRight { get; }
    Property Value
    Float2

    Center

    Gets center position of the rectangle

    Declaration
    public Float2 Center { get; }
    Property Value
    Float2

    Default

    The default Rectangle.

    Declaration
    public static Rectangle Default { get; }
    Property Value
    Rectangle

    Height

    Gets or sets height of the rectangle

    Declaration
    public float Height { get; set; }
    Property Value
    System.Single

    Left

    Gets X coordinate of the left edge of the rectangle

    Declaration
    public float Left { get; }
    Property Value
    System.Single

    LowerLeft

    Gets position of the bottom left corner of the rectangle

    Declaration
    public Float2 LowerLeft { get; }
    Property Value
    Float2

    LowerRight

    Gets position of the bottom right corner of the rectangle

    Declaration
    public Float2 LowerRight { get; }
    Property Value
    Float2

    Right

    Gets X coordinate of the right edge of the rectangle

    Declaration
    public float Right { get; }
    Property Value
    System.Single

    Top

    Gets Y coordinate of the top edge of the rectangle

    Declaration
    public float Top { get; }
    Property Value
    System.Single

    TopLeft

    Gets position of the upper left corner of the rectangle

    Declaration
    public Float2 TopLeft { get; }
    Property Value
    Float2

    TopRight

    Gets position of the upper right corner of the rectangle

    Declaration
    public Float2 TopRight { get; }
    Property Value
    Float2

    UpperLeft

    Gets position of the upper left corner of the rectangle

    Declaration
    public Float2 UpperLeft { get; }
    Property Value
    Float2

    UpperRight

    Gets position of the upper right corner of the rectangle

    Declaration
    public Float2 UpperRight { get; }
    Property Value
    Float2

    Width

    Gets or sets width of the rectangle

    Declaration
    public float Width { get; set; }
    Property Value
    System.Single

    X

    Gets or sets X coordinate of the left edge of the rectangle

    Declaration
    public float X { get; set; }
    Property Value
    System.Single

    Y

    Gets or sets Y coordinate of the left edge of the rectangle

    Declaration
    public float Y { get; set; }
    Property Value
    System.Single

    Methods

    Contains(Float2)

    Checks if rectangle contains given point

    Declaration
    public bool Contains(Float2 location)
    Parameters
    Float2 location

    Point location to check

    Returns
    System.Boolean

    True if point is inside rectangle's area

    Contains(ref Float2)

    Checks if rectangle contains given point

    Declaration
    public bool Contains(ref Float2 location)
    Parameters
    Float2 location

    Point location to check

    Returns
    System.Boolean

    True if point is inside rectangle's area

    Contains(Rectangle)

    Determines whether this rectangle entirely contains a specified rectangle

    Declaration
    public bool Contains(Rectangle value)
    Parameters
    Rectangle value

    The rectangle to evaluate

    Returns
    System.Boolean

    True if this rectangle entirely contains the specified rectangle, or false if not

    Contains(ref Rectangle)

    Determines whether this rectangle entirely contains a specified rectangle

    Declaration
    public bool Contains(ref Rectangle value)
    Parameters
    Rectangle value

    The rectangle to evaluate

    Returns
    System.Boolean

    True if this rectangle entirely contains the specified rectangle, or false if not

    Distance(Rectangle, Float2)

    Computed distance between rectangle and the point.

    Declaration
    public static float Distance(Rectangle rect, Float2 p)
    Parameters
    Rectangle rect

    The rectangle.

    Float2 p

    The point.

    Returns
    System.Single

    The resulting distance, 0 if point is inside the rectangle.

    Distance(Rectangle, Rectangle)

    Computed nearest distance between 2 rectangles.

    Declaration
    public static float Distance(Rectangle a, Rectangle b)
    Parameters
    Rectangle a

    First rectangle

    Rectangle b

    Second rectangle

    Returns
    System.Single

    Resulting distance, 0 if overlapping

    Equals(Rectangle)

    Declaration
    public bool Equals(Rectangle other)
    Parameters
    Rectangle other

    Returns
    System.Boolean

    Equals(ref Rectangle)

    Determines whether the specified Rectangle is equal to this instance.

    Declaration
    public bool Equals(ref Rectangle other)
    Parameters
    Rectangle other

    The Rectangle to compare with this instance.

    Returns
    System.Boolean

    true if the specified Rectangle is equal to this instance; otherwise, false.

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    System.Object obj

    Returns
    System.Boolean

    Expand(Single)

    Expand rectangle area in all directions by given amount

    Declaration
    public void Expand(float toExpand)
    Parameters
    System.Single toExpand

    Amount of units to expand a rectangle

    FromPoints(Float2, Float2)

    Creates rectangle from two points.

    Declaration
    public static Rectangle FromPoints(Float2 p1, Float2 p2)
    Parameters
    Float2 p1

    First point

    Float2 p2

    Second point

    Returns
    Rectangle

    Rectangle that contains both p1 and p2

    FromPoints(ref Float2, ref Float2, out Rectangle)

    Creates rectangle from two points.

    Declaration
    public static void FromPoints(ref Float2 p1, ref Float2 p2, out Rectangle result)
    Parameters
    Float2 p1

    First point

    Float2 p2

    Second point

    Rectangle result

    When the method completes, contains the rectangle that contains both p1 and p2 points.

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    System.Int32

    Intersects(Rectangle)

    Determines whether a specified rectangle intersects with this rectangle

    Declaration
    public bool Intersects(Rectangle value)
    Parameters
    Rectangle value

    The rectangle to evaluate

    Returns
    System.Boolean

    True if the specified rectangle intersects with this one, otherwise false

    Intersects(ref Rectangle)

    Determines whether a specified rectangle intersects with this rectangle

    Declaration
    public bool Intersects(ref Rectangle value)
    Parameters
    Rectangle value

    The rectangle to evaluate

    Returns
    System.Boolean

    True if the specified rectangle intersects with this one, otherwise false

    MakeExpanded(Single)

    Make expanded rectangle area in all directions by given amount

    Declaration
    public Rectangle MakeExpanded(float toExpand)
    Parameters
    System.Single toExpand

    Amount of units to expand a rectangle

    Returns
    Rectangle

    Expanded rectangle

    MakeOffsetted(Float2)

    Make offseted rectangle

    Declaration
    public Rectangle MakeOffsetted(Float2 offset)
    Parameters
    Float2 offset

    X and Y coordinate offset

    Returns
    Rectangle

    Offseted rectangle

    MakeOffsetted(Single, Single)

    Make offseted rectangle

    Declaration
    public Rectangle MakeOffsetted(float x, float y)
    Parameters
    System.Single x

    X coordinate offset

    System.Single y

    Y coordinate offset

    Returns
    Rectangle

    Offseted rectangle

    MakeScaled(Single)

    Make scaled rectangle area in all directions by given amount

    Declaration
    public Rectangle MakeScaled(float scale)
    Parameters
    System.Single scale

    Scale value to expand a rectangle

    Returns
    Rectangle

    Scaled rectangle

    Margin(Rectangle, Margin)

    Calculates a rectangle that includes the margins (inside).

    Declaration
    public static Rectangle Margin(Rectangle value, Margin margin)
    Parameters
    Rectangle value

    The rectangle.

    Margin margin

    The margin to apply to the rectangle.

    Returns
    Rectangle

    Rectangle inside the given rectangle after applying margins inside it.

    Offset(Float2)

    Offset rectangle position

    Declaration
    public void Offset(Float2 offset)
    Parameters
    Float2 offset

    X and Y coordinate offset

    Offset(Single, Single)

    Offset rectangle position

    Declaration
    public void Offset(float x, float y)
    Parameters
    System.Single x

    X coordinate offset

    System.Single y

    Y coordinate offset

    Scale(Single)

    Scale rectangle area in all directions by given amount

    Declaration
    public void Scale(float scale)
    Parameters
    System.Single scale

    Scale value to expand a rectangle

    Shared(Rectangle, Rectangle)

    Calculates a rectangle that contains the shared part of a and b rectangles.

    Declaration
    public static Rectangle Shared(Rectangle a, Rectangle b)
    Parameters
    Rectangle a

    The first rectangle.

    Rectangle b

    The second rectangle.

    Returns
    Rectangle

    Rectangle that contains shared part of a and b rectangles.

    Shared(ref Rectangle, ref Rectangle, out Rectangle)

    Calculates a rectangle that contains the shared part of a and b rectangles.

    Declaration
    public static void Shared(ref Rectangle a, ref Rectangle b, out Rectangle result)
    Parameters
    Rectangle a

    The first rectangle.

    Rectangle b

    The second rectangle.

    Rectangle result

    When the method completes, contains the rectangle that shared part of a and b rectangles.

    ToString()

    Declaration
    public override string ToString()
    Returns
    System.String

    Union(Rectangle, Rectangle)

    Calculates a rectangle that contains the union of a and b rectangles

    Declaration
    public static Rectangle Union(Rectangle a, Rectangle b)
    Parameters
    Rectangle a

    The first rectangle.

    Rectangle b

    The second rectangle.

    Returns
    Rectangle

    Rectangle that contains both a and b rectangles

    Union(ref Rectangle, ref Rectangle, out Rectangle)

    Calculates a rectangle that contains the union of a and b rectangles

    Declaration
    public static void Union(ref Rectangle a, ref Rectangle b, out Rectangle result)
    Parameters
    Rectangle a

    First rectangle

    Rectangle b

    Second rectangle

    Rectangle result

    When the method completes, contains the rectangle that both a and b rectangles.

    Operators

    Addition(Rectangle, Float2)

    Implements the operator +.

    Declaration
    public static Rectangle operator +(Rectangle rectangle, Float2 offset)
    Parameters
    Rectangle rectangle

    The rectangle.

    Float2 offset

    The offset.

    Returns
    Rectangle

    The result of the operator.

    Equality(Rectangle, Rectangle)

    Tests for equality between two objects.

    Declaration
    public static bool operator ==(Rectangle left, Rectangle right)
    Parameters
    Rectangle left

    The first value to compare.

    Rectangle right

    The second value to compare.

    Returns
    System.Boolean

    true if left has the same value as right; otherwise, false.

    Inequality(Rectangle, Rectangle)

    Tests for inequality between two objects.

    Declaration
    public static bool operator !=(Rectangle left, Rectangle right)
    Parameters
    Rectangle left

    The first value to compare.

    Rectangle right

    The second value to compare.

    Returns
    System.Boolean

    true if left has a different value than right; otherwise, false.

    Multiply(Rectangle, Single)

    Implements the operator *.

    Declaration
    public static Rectangle operator *(Rectangle rectangle, float scale)
    Parameters
    Rectangle rectangle

    The rectangle.

    System.Single scale

    The scale.

    Returns
    Rectangle

    The result of the operator.

    Subtraction(Rectangle, Float2)

    Implements the operator -.

    Declaration
    public static Rectangle operator -(Rectangle rectangle, Float2 offset)
    Parameters
    Rectangle rectangle

    The rectangle.

    Float2 offset

    The offset.

    Returns
    Rectangle

    The result of the operator.

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.RawClone<T>(T)
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat