Rectangle Struct
Represents a rectangle with floating-point coordinates.
public readonly struct Rectangle : System.IEquatable<Brine2D.Core.Rectangle>
Implements System.IEquatable<Rectangle>
| Properties | |
|---|---|
| Area | Gets the area of the rectangle. |
| BottomLeft | Gets the bottom-left corner as a Vector2. |
| BottomRight | Gets the bottom-right corner as a Vector2. |
| Empty | Empty rectangle at (0, 0) with zero size. |
| IsEmpty | Gets whether this rectangle is empty (zero width or height). |
| TopLeft | Gets the top-left corner as a Vector2. |
| TopRight | Gets the top-right corner as a Vector2. |
| Methods | |
|---|---|
| Contains(Rectangle) | Checks if this rectangle contains another rectangle entirely. |
| Contains(float, float) | Checks if this rectangle contains a point. |
| Contains(Vector2) | Checks if this rectangle contains a point. |
| ContainsInclusive(float, float) | Checks if this rectangle contains a point (inclusive of all edges). |
| ContainsInclusive(Vector2) | Checks if this rectangle contains a point (inclusive of all edges). |
| Deconstruct(float, float, float, float) | Deconstructs the rectangle into its components. |
| FromCenter(Vector2, float, float) | Creates a rectangle centered at the specified position. |
| FromCenter(Vector2, Vector2) | Creates a rectangle centered at the specified position. |
| FromPoints(Vector2, Vector2) | Creates a rectangle from two corner points. |
| GetPenetration(Rectangle) | Gets the penetration depth when intersecting with another rectangle. Returns zero vector if not intersecting. Useful for collision response (pushing objects apart). |
| Inflate(float, float) | Inflates the rectangle by the specified amount on all sides. The total width increases by horizontal * 2, height by vertical * 2. |
| Intersection(Rectangle) | Gets the intersection of this rectangle with another. Returns null if they don't intersect. |
| Intersects(Rectangle) | Checks if this rectangle intersects with another rectangle. |
| Offset(float, float) | Offsets the rectangle by the specified amount. |
| Offset(Vector2) | Offsets the rectangle by the specified vector. |
| ToInt() | Converts to integer coordinates by rounding. Useful for pixel-perfect rendering. |
| Union(Rectangle) | Gets the union (bounding box) of this rectangle with another. |