Class Rect
Represents a rectangle with position and dimensions.
Inherited Members
Namespace: Genesis.Math
Assembly: Genesis.dll
Syntax
public class Rect
Constructors
Rect()
Default constructor for the Rect class.
Declaration
public Rect()
Rect(float, float, float, float)
Constructor for the Rect class that initializes the rectangle with specified position and dimensions.
Declaration
public Rect(float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
float | x | The X-coordinate of the rectangle. |
float | y | The Y-coordinate of the rectangle. |
float | width | The width of the rectangle. |
float | height | The height of the rectangle. |
Properties
Height
Gets or sets the height of the rectangle.
Declaration
public float Height { get; set; }
Property Value
Type | Description |
---|---|
float |
Width
Gets or sets the width of the rectangle.
Declaration
public float Width { get; set; }
Property Value
Type | Description |
---|---|
float |
X
Gets or sets the X-coordinate of the rectangle.
Declaration
public float X { get; set; }
Property Value
Type | Description |
---|---|
float |
Y
Gets or sets the Y-coordinate of the rectangle.
Declaration
public float Y { get; set; }
Property Value
Type | Description |
---|---|
float |
Methods
Contains(float, float)
Checks if a point with specified coordinates is contained within the rectangle.
Declaration
public bool Contains(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
float | x | The X-coordinate of the point. |
float | y | The Y-coordinate of the point. |
Returns
Type | Description |
---|---|
bool | True if the point is contained within the rectangle, otherwise false. |
Intersects(Rect)
Checks if the current rectangle intersects with another rectangle.
Declaration
public bool Intersects(Rect rect)
Parameters
Type | Name | Description |
---|---|---|
Rect | rect | The other rectangle to check for intersection. |
Returns
Type | Description |
---|---|
bool | True if the rectangles intersect, otherwise false. |
ToString()
Converts the rectangle to a string representation in the format "X;Y;Width;Height".
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string representation of the rectangle. |