|
Data Structures |
struct | Rect |
| Rectangle structure. More...
|
struct | XY |
Defines |
#define | RectAutoXYWH(x, y, w, h) { (x), (y), (x) + (w), (y) + (h) } |
| Define rect data for auto/global using x,y,w,h.
|
#define | RectSetXYWH(r, x, y, w, h) { (r).left = (x); (r).top = (y); (r).right = (x) + (w); (r).bottom = (y) + (h); } |
| Set rect data using x,y,w,h.
|
#define | RectAutoLTRB(l, t, r, b) { (l), (t), (r), (b) } |
| Define rect data for auto/global using l,t,r,b.
|
#define | RectSetLTRB(rc, l, t, r, b) { (rc).left = (l); (rc).top = (t); (rc).right = (r); (rc).bottom = (b); } |
| Set rect data using l,t,r,b.
|
#define | RectAutoClear() { 0,0,0,0 } |
| Define rect data as 'empty'.
|
#define | RectClear(r) { (r).left = (r).top = (r).right = (r).bottom = 0; } |
| Clear rectangle to "empty" state.
|
#define | RectAutoMax() { (-(int)(~0u>>2)),(-(int)(~0u>>2)), ((int)(~0u>>2)),((int)(~0u>>2)) } |
| Define rect data as 'biggest possible' without wrapping wide/high Useful in "no clipping" parameter situations.
|
#define | RectSetMax(r) { (r).left = (r).top = (-(int)(~0u>>2)); (r).right = (r).bottom = (int)(~0u>>2); } |
| Make the 'biggest possible' rectangle without wrapping wide/high Useful in "no clipping" parameter situations.
|
#define | RectEmpty(r) ( RectWide(r) < 1 || RectHigh(r) < 1 ) |
| Determine if rectangle is in "empty" state.
|
#define | RectWide(r) ((r).right - (r).left) |
| Get rectangle width in pixels.
|
#define | RectHigh(r) ((r).bottom - (r).top) |
| Get rectangle height in pixels.
|
#define | RectPtInRect(r, x, y) ( (x)>=(r).left && (x)<(r).right && (y)>=(r).top && (y)<(r).bottom ) |
| See if {x,y} is inside of a rectangle.
|
#define | RectEqual(r1, r2) ((r1).left == (r2).left && (r1).top == (r2).top && (r1).right == (r2).right && (r1).bottom == (r2).bottom ) |
| See if two rectangles intersect.
|
#define | RectInRect(r, r2) (!RectOutside(r,r2)) |
| See if two rectangles intersect.
|
#define | RectOutside(r, r2) ( ((r).left>=(r2).right) || ((r).right<=(r2).left) || ((r).top>=(r2).bottom) || ((r).bottom<=(r2).top) ) |
| See if two rectangles DO NOT intersect.
|
#define | RectContainsRect(r, r2) ( ((r2).left>=(r).left) && ((r2).top>=(r).top) && ((r2).right<=(r).right) && ((r2).bottom<=(r).bottom) ) |
| See if 'r2' is completely inside 'r'.
|
#define | RectCenterX(r) (((r).left+(r).right)/2) |
| Get the center X coordinate of 'r'.
|
#define | RectCenterY(r) (((r).top+(r).bottom)/2) |
| Get the center Y coordinate of 'r'.
|
#define | RectCenterPt(r, x, y) { (x)=RectCenterX(r); (y)=RectCenterY(r); } |
| Get the center X,Y coordinates of 'r'.
|
#define | RectSetWide(r, w) ((r).right=(r).left+(w)) |
| Change the width of a Rect.
|
#define | RectSetHigh(r, h) ((r).bottom=(r).top+(h)) |
| Change the height of a Rect.
|
#define | RectLeftTo(r, x) {int _m_x = (x); int _m_tmp=RectWide(r); (r).left=_m_x; (r).right=_m_x+_m_tmp; } |
| Move 'r' so left edge is on 'x'.
|
#define | RectTopTo(r, y) {int _m_y = (y); int _m_tmp=RectHigh(r); (r).top=_m_y; (r).bottom=_m_y+_m_tmp; } |
| Move 'r' so top edge is on 'y'.
|
#define | RectRightTo(r, x) {int _m_x = (x); int _m_tmp=RectWide(r); (r).left=_m_x-_m_tmp;(r).right=_m_x;} |
| * Move 'r' so right edge (+1) is on 'x'
|
#define | RectBottomTo(r, y) {int _m_y = (y); int _m_tmp=RectHigh(r); (r).top=_m_y-_m_tmp;(r).bottom=_m_y;} |
| Move 'r' so bottom edge (+1) is on 'y'.
|
#define | RectMove(r, x, y) {RectLeftTo(r,x); RectTopTo(r,y);} |
| Set 'r' upper, left corner to {x,y}.
|
#define | RectMoveBy(r, x, y) { (r).left += (x); (r).right += (x); (r).top += (y); (r).bottom += (y); } |
| Add x,y to each rectangle coordinate.
|
#define | RectGrow(r, x, y) { (r).left -= (x); (r).right += (x); (r).top -= (y); (r).bottom += (y); } |
| Grow rectangle by x,y.
|
#define | RectShrink(r, x, y) { (r).left += (x); (r).right -= (x); (r).top += (y); (r).bottom -= (y); } |
| Shrink rectangle by x,y.
|
#define | RectHAlign(r, pow2) { const int rha_mask=~((pow2)-1); (r).left &= rha_mask; (r).right = ((r).right+~rha_mask) & rha_mask; } |
| Align rectangle horizontal edges with power of 2 (2,4,8,16...).
|
#define | RectVAlign(r, pow2) { const int rha_mask=~((pow2)-1); (r).top &= rha_mask; (r).bottom = ((r).bottom+~rha_mask) & rha_mask; } |
| Align rectangle vertical edges with power of 2.
|
#define | RectUnionRect(r, r2) |
| Grow 'r' to the union or 'r' and 'r2'.
|
#define | RectUnionPt(r, x, y) |
| Grow 'r' to include {x,y}.
|
#define | RectCenterOnX(r, x) RectLeftTo(r,(x)-(RectWide(r)/2)) |
| Center 'r' on x coordinate.
|
#define | RectCenterOnY(r, y) RectTopTo(r,(y)-(RectHigh(r)/2)) |
| Center 'r' on y coordinate.
|
#define | RectCenterOnPt(r, x, y) { int _m_mx = (x)-(RectWide(r)/2); int _m_my = (y)-(RectHigh(r)/2); RectMove(r,_m_mx,_m_my); } |
| Center 'r' on {x,y} coordinate.
|
#define | RectCenterOnRect(r, r2) { int _m_x,_m_y; RectCenterPt(r2,_m_x,_m_y); RectCenterOnPt((r),_m_x,_m_y); } |
| Center 'r' on 'r2'.
|
#define | RectIntRect(r, r2) |
| Clip 'r' so none of it is outside 'r2' RectEmpty will return non-zero on 'r' if it was completely outside.
|
#define | RectBoundtoRect(r, rb) |
| Position 'r' so it's inside 'rb' If 'r' is bigger, it will be aligned to 'rb' upper, left corner.
|
#define | IXY_X(decl) IXY_X_##decl |
#define | ILTRB_L(decl) ILTRB_L_##decl |
#define | ILTRB_WIDE(ir) (ir(ILTRB_R)-ir(ILTRB_L)) |
| Get width of ILTRB.
|
#define | ILTRB_HIGH(ir) (ir(ILTRB_B)-ir(ILTRB_T)) |
| Get height of ILTRB.
|
#define | ILTRB_CX(ir) ((ir(ILTRB_L)+ir(ILTRB_R))/2) |
| Get center X ILTRB.
|
#define | ILTRB_CY(ir) ((ir(ILTRB_T)+ir(ILTRB_B))/2) |
| Get center Y ILTRB.
|
#define | ILTRB_SCALEX(ir, e, d) (ir(ILTRB_L)+((e)*ILTRB_WIDE(ir))/(d))) |
| Get scaled X coordinate within ir; e enumerator, d denominator.
|
#define | ILTRB_SCALEY(ir, e, d) (ir(ILTRB_T)+((e)*ILTRB_HIGH(ir)/(d))) |
| Get scaled Y coordinate within ir; e enumerator, d denominator.
|
#define | XYIn_LTRB(xy, ir) ( (xy).x >= ir(ILTRB_L) && (xy).x < ir(ILTRB_R) && (xy).y >= ir(ILTRB_T) && (xy).y < ir(ILTRB_B) ) |
| Test to see if an XY structure is inside ILTRB.
|
#define | PtIn_LTRB(x, y, ir) ( (x) >= ir(ILTRB_L) && (x) < ir(ILTRB_R) && (y) >= ir(ILTRB_T) && (y) < ir(ILTRB_B) ) |
| Test to see if an x,y is inside ILTRB.
|
#define | RectOutside_LTRB(r, ir) ( ((r).left>=ir(ILTRB_R)) || ((r).right<=ir(ILTRB_L)) || ((r).top>=ir(ILTRB_B)) || ((r).bottom<=ir(ILTRB_T)) ) |
| Test to see if Rect is outside ILTRB.
|
#define | RectIn_LTRB(r, ir) ( !RectOutside_LTRB( r, ir ) ) |
| Test to see if Rect is inside ILTRB.
|
#define | XY_AUTO_LT(ir) { ir(ILTRB_L), ir(ILTRB_T) } |