Struct Rectangle
Describes rectangle in 2D space defines by location of its upper-left corner and the size.
Implements
Inherited Members
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public struct Rectangle : IEquatable<Rectangle>
Constructors
Rectangle(Vector2, Vector2)
Init
Declaration
public Rectangle(Vector2 location, Vector2 size)
Parameters
Vector2
location
Location of the upper left corner |
Vector2
size
Size |
Rectangle(Vector2, Single, Single)
Init
Declaration
public Rectangle(Vector2 location, float width, float height)
Parameters
Vector2
location
Location of the upper left corner |
System.Single
width
Width |
System.Single
height
Height |
Rectangle(Single, Single, Vector2)
Init
Declaration
public Rectangle(float x, float y, Vector2 size)
Parameters
System.Single
x
X coordinate |
System.Single
y
Y coordinate |
Vector2
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 Vector2 Location
Field Value
Vector2
|
Size
Properties
Bottom
Gets Y coordinate of the bottom edge of the rectangle
Declaration
public readonly float Bottom { get; }
Property Value
System.Single
|
BottomLeft
Gets position of the bottom left corner of the rectangle
Declaration
public readonly Vector2 BottomLeft { get; }
Property Value
Vector2
|
BottomRight
Gets position of the bottom right corner of the rectangle
Declaration
public readonly Vector2 BottomRight { get; }
Property Value
Vector2
|
Center
Gets center position of the rectangle
Declaration
public readonly Vector2 Center { get; }
Property Value
Vector2
|
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 readonly float Left { get; }
Property Value
System.Single
|
Right
Gets X coordinate of the right edge of the rectangle
Declaration
public readonly float Right { get; }
Property Value
System.Single
|
Top
Gets Y coordinate of the top edge of the rectangle
Declaration
public readonly float Top { get; }
Property Value
System.Single
|
UpperLeft
Gets position of the upper left corner of the rectangle
Declaration
public readonly Vector2 UpperLeft { get; }
Property Value
Vector2
|
UpperRight
Gets position of the upper right corner of the rectangle
Declaration
public readonly Vector2 UpperRight { get; }
Property Value
Vector2
|
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(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 |
Contains(Vector2)
Checks if rectangle contains given point
Declaration
public bool Contains(Vector2 location)
Parameters
Vector2
location
Point location to check |
Returns
System.Boolean
True if point is inside rectangle's area |
Contains(ref Vector2)
Checks if rectangle contains given point
Declaration
public bool Contains(ref Vector2 location)
Parameters
Vector2
location
Point location to check |
Returns
System.Boolean
True if point is inside rectangle's area |
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 |
Distance(Rectangle, Vector2)
Computed distance between rectangle and the point.
Declaration
public static float Distance(Rectangle rect, Vector2 p)
Parameters
Rectangle
rect
The rectangle. |
Vector2
p
The point. |
Returns
System.Single
The resulting distance, 0 if point is inside the rectangle. |
Equals(Rectangle)
Declaration
public bool Equals(Rectangle other)
Parameters
Rectangle
other
|
Returns
System.Boolean
|
Implements
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
|
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
System.Object
obj
|
Returns
System.Boolean
|
Overrides
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(Vector2, Vector2)
Creates rectangle from two points.
Declaration
public static Rectangle FromPoints(Vector2 p1, Vector2 p2)
Parameters
Vector2
p1
First point |
Vector2
p2
Second point |
Returns
Rectangle
Rectangle that contains both p1 and p2 |
FromPoints(ref Vector2, ref Vector2, out Rectangle)
Creates rectangle from two points.
Declaration
public static void FromPoints(ref Vector2 p1, ref Vector2 p2, out Rectangle result)
Parameters
Vector2
p1
First point |
Vector2
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
|
Overrides
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(Vector2)
Make offseted rectangle
Declaration
public Rectangle MakeOffsetted(Vector2 offset)
Parameters
Vector2
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(Vector2)
Offset rectangle position
Declaration
public void Offset(Vector2 offset)
Parameters
Vector2
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)
Shared(ref Rectangle, ref Rectangle, out Rectangle)
ToString()
Declaration
public override string ToString()
Returns
System.String
|
Overrides
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, Vector2)
Implements the operator +.
Declaration
public static Rectangle operator +(Rectangle rectangle, Vector2 offset)
Parameters
Rectangle
rectangle
The rectangle. |
Vector2
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
|
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
|
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, Vector2)
Implements the operator -.
Declaration
public static Rectangle operator -(Rectangle rectangle, Vector2 offset)
Parameters
Rectangle
rectangle
The rectangle. |
Vector2
offset
The offset. |
Returns
Rectangle
The result of the operator. |