cangine
Loading...
Searching...
No Matches
Static Public Member Functions | Public Attributes | List of all members
cangine::Rectangle Struct Reference

An axis-aligned rectangle with a position, size and color. More...

#include <rectangle.hpp>

Collaboration diagram for cangine::Rectangle:
Collaboration graph
[legend]

Static Public Member Functions

static bool containsPoint (const Rectangle &rect, const Transform &transform, const Vector2 &point)
 Tests whether a point lies inside a (possibly transformed) rectangle.
 
static bool overlaps (const Rectangle &r1, const Transform &t1, const Rectangle &r2, const Transform &t2)
 Tests whether two (possibly transformed) rectangles overlap.
 

Public Attributes

Vector3 pos
 Center position (z is the layer).
 
float width
 Width before scaling.
 
float height
 Height before scaling.
 
Color color
 Fill color.
 

Detailed Description

An axis-aligned rectangle with a position, size and color.

The geometry is axis-aligned in its own space, but the static helpers accept a Transform so they can perform rotated/scaled hit-tests and collision checks via the Separating Axis Theorem.

Member Function Documentation

◆ containsPoint()

static bool cangine::Rectangle::containsPoint ( const Rectangle &  rect,
const Transform &  transform,
const Vector2 &  point 
)
inlinestatic

Tests whether a point lies inside a (possibly transformed) rectangle.

Parameters
rectRectangle whose width/height define the bounds.
transformTransform supplying position, rotation and scale.
pointPoint to test, in world/screen space.
Returns
true if the point is inside the rectangle, false otherwise.

◆ overlaps()

static bool cangine::Rectangle::overlaps ( const Rectangle &  r1,
const Transform &  t1,
const Rectangle &  r2,
const Transform &  t2 
)
inlinestatic

Tests whether two (possibly transformed) rectangles overlap.

Uses the Separating Axis Theorem over the four edge normals of the two rectangles, so rotation and scale are respected.

Parameters
r1First rectangle (provides width/height).
t1Transform for the first rectangle.
r2Second rectangle (provides width/height).
t2Transform for the second rectangle.
Returns
true if the rectangles intersect, false otherwise.

Member Data Documentation

◆ color

Color cangine::Rectangle::color

Fill color.

◆ height

float cangine::Rectangle::height

Height before scaling.

◆ pos

Vector3 cangine::Rectangle::pos

Center position (z is the layer).

◆ width

float cangine::Rectangle::width

Width before scaling.


The documentation for this struct was generated from the following file: