ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
|
A 2D rectangle in space. More...
#include <geometry.h>
Public Member Functions | |
Quad () | |
Default constructor for the Quad class. | |
Quad (const Vec2< T > &position, const Vec2< T > &size) | |
Constructor for the Quad class. | |
Quad (T x, T y, T width, T height) | |
Constructor for the Quad class. | |
void | setPosition (T x, T y) |
Set the position of the rectangle. | |
void | setSize (T width, T height) |
Set the size of the rectangle. | |
Vec2< T > | getCenter () const |
Get center of the rectangle. | |
bool | contains (const Vec2< T > &point) const |
Check if a point is inside the rectangle. | |
bool | contains (T x, T y) const |
Check if coordinates are inside the rectangle. | |
bool | collides (const Quad &other) const |
Check if a rectangle is inside the rectangle. | |
bool | collidesBottom (const Quad &other) const |
bool | collidesTop (const Quad &other) const |
bool | collidesLeft (const Quad &other) const |
bool | collidesRight (const Quad &other) const |
Quad | operator+ (const Quad< T > &quad) const |
Add a vector to the rectangle. | |
Quad | operator- (const Quad< T > &quad) const |
Subtract a vector from the rectangle. | |
Quad | operator* (const T scalar) const |
Multiply the rectangle by a scalar. | |
Quad | operator/ (const T scalar) const |
Divide the rectangle by a scalar. | |
Public Attributes | |
Vec2< T > | position |
The position of the rectangle. | |
Vec2< T > | size |
The size of the rectangle. | |
A 2D rectangle in space.
This class represents a 2D rectangle in space. It is used to represent areas, sizes, and positions.
Definition at line 193 of file geometry.h.
|
inline |
Default constructor for the Quad class.
Definition at line 197 of file geometry.h.
|
inline |
Constructor for the Quad class.
position | The position of the rectangle. |
size | The size of the rectangle. |
Definition at line 204 of file geometry.h.
|
inline |
Constructor for the Quad class.
x | The x position of the rectangle. |
y | The y position of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
Definition at line 214 of file geometry.h.
Check if a rectangle is inside the rectangle.
other | The rectangle to check. |
Definition at line 264 of file geometry.h.
Definition at line 275 of file geometry.h.
Definition at line 285 of file geometry.h.
Definition at line 290 of file geometry.h.
Definition at line 280 of file geometry.h.
Check if a point is inside the rectangle.
point | The point to check. |
Definition at line 244 of file geometry.h.
|
inline |
Check if coordinates are inside the rectangle.
point | The point to check. |
Definition at line 254 of file geometry.h.
Get center of the rectangle.
Definition at line 234 of file geometry.h.
Multiply the rectangle by a scalar.
scalar | The scalar to multiply by. |
Definition at line 318 of file geometry.h.
Add a vector to the rectangle.
vec | The vector to add. |
Definition at line 300 of file geometry.h.
Subtract a vector from the rectangle.
vec | The vector to subtract. |
Definition at line 309 of file geometry.h.
Divide the rectangle by a scalar.
scalar | The scalar to divide by. |
Definition at line 327 of file geometry.h.
|
inline |
Set the position of the rectangle.
x | The x position of the rectangle. |
y | The y position of the rectangle. |
Definition at line 221 of file geometry.h.
|
inline |
Set the size of the rectangle.
width | The width of the rectangle. |
height | The height of the rectangle. |
Definition at line 228 of file geometry.h.
The position of the rectangle.
Definition at line 332 of file geometry.h.
The size of the rectangle.
Definition at line 335 of file geometry.h.