2D Rectangles
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.
Functions
R2D | r2d (...) |
V2D | r2d_center (...) |
bool_t | r2d_collide (...) |
bool_t | r2d_contains (...) |
bool_t | r2d_clip (...) |
void | r2d_join (...) |
Types and Constants
R2D | kZERO |
A rectangle (or frame) (R2Df
, R2Dd
) (Figure 1) is used to locate elements in user interfaces or other 2D systems through a point of origin V2Df and a size S2Df. They can also be used in clipping operations, when optimizing drawing tasks.
- Use r2d_collidef to determine if two rectangles collide.
- Use r2d_clipf to determine if a rectangle is visible within an area.
- Use r2d_joinf to join the two rectangles.
kZERO
const R2Df kR2D_ZEROf; const R2Dd kR2D_ZEROd; const R2D R2D::kZERO;
Value [0,0,0,0]
.
r2d ()
Create a rectangle from its components.
R2Df r2df(const real32_t x, const real32_t y, const real32_t width, const real32_t height); R2Dd r2dd(const real64_t x, const real64_t y, const real64_t width, const real64_t height); R2D R2D(const real x, const real y, const real width, const real height);
x | Origin x coordinate. |
y | Coordinate and origin. |
width | Width. |
height | Height. |
Return
The rectangle.
r2d_center ()
Gets the center point of the rectangle.
V2Df r2d_centerf(const R2Df *r2d); V2Dd r2d_centerd(const R2Dd *r2d); V2D R2D::center(const R2D *r2d);
r2d | Rectangle. |
Return
The center.
r2d_collide ()
Check if two rectangles collide.
bool_t r2d_collidef(const R2Df *r2d1, const R2Df *r2d2); bool_t r2d_collided(const R2Dd *r2d1, const R2Dd *r2d2); bool_t R2D::collide(const R2D *r2d1, const R2D *r2d2);
r2d1 | Rectangle 1. |
r2d2 | Rectangle 2. |
Return
TRUE
if there is collision, FALSE
if they are separated.
r2d_contains ()
Check if a point is inside the rectangle.
bool_t r2d_containsf(const R2Df *r2d, const real32_t x, const real32_t y); bool_t r2d_containsd(const R2Dd *r2d, const real64_t x, const real64_t y); bool_t R2D::contains(const R2D *r2d, const real x, const real y);
r2d | Rectangle. |
x | X coordinate of the point. |
y | Coordinate and point. |
Return
TRUE
if the point is inside.
r2d_clip ()
Check if a rectangle, or part of it, is contained in another rectangle.
bool_t r2d_clipf(const R2Df *viewport, const R2Df *r2d); bool_t r2d_clipd(const R2Dd *viewport, const R2Dd *r2d); bool_t R2D::clip(const R2D *viewport, const R2D *r2d);
viewport | Container rectangle. |
r2d | Rectangle to check. |
Return
TRUE
if the r2d
rectangle is completely outside of viewport
.
Remarks
Useful to avoid processing or drawing objects that are totally outside the viewing area.
r2d_join ()
Join two rectangles into one.
void r2d_joinf(R2Df *r2d, const R2Df *src); void r2d_joind(R2Dd *r2d, const R2Dd *src); void R2D::join(R2D *r2d, const R2D *src);
r2d | Destination rectangle. Its position and size will be modified to contain |
src | Rectangle to be added to |