// // G A M E.O.N.E - LOW LEVEL LIB V1.0 // Copyright (C) 2001 LEVEL ONE ENTERTAINMENT, // Licensed under the terms of LGPL. //:--------------------------------------------------------------------------- //:Description //**************************************************************************** // Rect Clipping Functions: //**************************************************************************** // void ClipRect(llgfx_sRECT &dst, const llgfx_sRECT &cliprect) // void ClipRect(llgfx_sRECT *dst, const llgfx_sRECT &cliprect) // void ClipRect(llgfx_sRECT &dst, const llgfx_sRECT *cliprect) // void ClipRect(llgfx_sRECT *dst, const llgfx_sRECT *cliprect) // bool ClipRectB(llgfx_sRECT &dst, const llgfx_sRECT &cliprect) // bool ClipRectB(llgfx_sRECT *dst, const llgfx_sRECT &cliprect) // bool ClipRectB(llgfx_sRECT &dst, const llgfx_sRECT *cliprect) // bool ClipRectB(llgfx_sRECT *dst, const llgfx_sRECT *cliprect) // void ClipPointToRect(llgfx_sRECT &dst, int &pointx, int &pointy ); //**************************************************************************** // Copy Rect Functions: //**************************************************************************** // CopyRect(llgfx_sRECT &dst,llgfx_sRECT &) // CopyRect(llgfx_sRECT &dst,llgfx_sRECT *) // CopyRect(llgfx_sRECT *dst,llgfx_sRECT &) // CopyRect(llgfx_sRECT *dst,llgfx_sRECT *) //**************************************************************************** // Set Rect Functions: //**************************************************************************** // SetRect(llgfx_sRECT &dst,int x1,int y1, int x2, int y2); // SetRect(llgfx_sRECT *dst,int x1,int y1, int x2, int y2); // SetRectEmpty(llgfx_sRECT &dst); // SetRectEmpty(llgfx_sRECT *dst); // OffsetRect(llgfx_sRECT *dst, int x1, int y1); // OffsetRect(llgfx_sRECT *dst, llgfx_sRect *src); // OffsetRect(llgfx_sRECT &dst, int x1, int y1); // OffsetRect(llgfx_sRECT &dst, llgfx_sRect &src); // MoveRect(llgfx_sRECT *dst); // MoveRect(llgfx_sRECT &dst); // ExpandRect(llgfx_sRECT *dest, int xoffset, int yoffset ) // ExpandRect(llgfx_sRECT &dest, int xoffset, int yoffset ) // ExpandRect(llgfx_sRECT *dest, float xfaktor, float xfaktor ) // ExpandRect(llgfx_sRECT &dest, float xfaktor, float yfaktor ) //**************************************************************************** // INFO Rect Functions: //**************************************************************************** // int WIDTH(const llgfx_sRECT &src) // int WIDTH(const llgfx_sRECT *src) // int HEIGHT(const llgfx_sRECT &src) // int HEIGHT(const llgfx_sRECT *src) // int MIDX(const llgfx_sRECT &src) // int MIDX(const llgfx_sRECT *src) // int MIDY(const llgfx_sRECT &src) // int MIDY(const llgfx_sRECT *src) // bool GetPointPosQ(int x, int y, const llgfx_sRECT *reference_rect); // bool GetPointPosQ(int x, int y, const llgfx_sRECT &reference_rect); // bool IsPointInRect(const llgfx_sRECT &rect, int x, int y) // bool IsPointInRect(const llgfx_sRECT *rect, int y, int y) // bool IsRectEqual(const llgfx_sRECT &rect1, const llgfx_sRECT &rect2) // bool IsRectEqual(const llgfx_sRECT *rect1, const llgfx_sRECT &rect2) // bool IsRectEqual(const llgfx_sRECT &rect1, const llgfx_sRECT *rect2) // bool IsRectEqual(const llgfx_sRECT *rect1, const llgfx_sRECT *rect2) // bool IsRectValid(const llgfx_sRECT &rect) // bool IsRectValid(const llgfx_sRECT *rect) // bool IsRectIntersectingRect(const llgfx_sRECT &rect,const llgfx_sRECT &reference_rect) // bool IsRectIntersectingRect(const llgfx_sRECT *rect,const llgfx_sRECT &reference_rect) // bool IsRectIntersectingRect(const llgfx_sRECT &rect,const llgfx_sRECT *reference_rect) // bool IsRectIntersectingRect(const llgfx_sRECT *rect,const llgfx_sRECT *reference_rect) // bool IsRectEmpty(const llgfx_sRECT *rect); // bool IsRectEmpty(const llgfx_sRECT &rect); // bool IsRectInRect(const llgfx_sRECT &rect, const llgfx_sRECT &reference_rect); // bool IsRectInRect(const llgfx_sRECT *rect, const llgfx_sRECT &reference_rect); // bool IsRectInRect(const llgfx_sRECT &rect, const llgfx_sRECT *reference_rect); // bool IsRectInRect(const llgfx_sRECT *rect, const llgfx_sRECT *reference_rect); //**************************************************************************** // Boundingrect Functions: //**************************************************************************** // llgfx_sRECT GetBoundingRect(const llgfx_sRECT &re1, const llgfx_sRECT &re2); // llgfx_sRECT GetBoundingRect(const llgfx_sRECT &re1, const llgfx_sRECT *re2); // llgfx_sRECT GetBoundingRect(const llgfx_sRECT *re1, const llgfx_sRECT &re2); // llgfx_sRECT GetBoundingRect(const llgfx_sRECT *re1, const llgfx_sRECT *re2); //**************************************************************************** // Intersection rect Functions: //**************************************************************************** // llgfx_sRECT GetIntersectRect(const llgfx_sRECT &re1, const llgfx_sRECT &re2); // llgfx_sRECT GetIntersectRect(const llgfx_sRECT &re1, const llgfx_sRECT *re2); // llgfx_sRECT GetIntersectRect(const llgfx_sRECT *re1, const llgfx_sRECT &re2); // llgfx_sRECT GetIntersectRect(const llgfx_sRECT *re1, const llgfx_sRECT *re2); // //:----------------------------------------------------------------------------- #if !defined(LL2D_RECT_INCLUDED) #define LL2D_RECT_INCLUDED #ifndef GTOR_BEGIN_NAMESPACE #define GTOR_BEGIN_NAMESPACE(x) namespace x { #define GTOR_END_NAMESPACE() }// end namespace #endif //:End Custom //:Include #if !defined(_LL2D_RECT_H) #include "ll2d_srect.h" #endif //:Namespace GTOR_BEGIN_NAMESPACE(ll2d) //:> +------------------------------------+ //:>-------------------| Global Function Declarations |------------------- //:> +------------------------------------+ //::37 // +--------------+ // | ClipRect() | // +--------------+ inline void ClipRect( llgfx_sRECT &dst, const llgfx_sRECT &cliprect); //::38 // +--------------+ // | ClipRect() | // +--------------+ inline void ClipRect( llgfx_sRECT *dst, const llgfx_sRECT &cliprect); //::39 // +--------------+ // | ClipRect() | // +--------------+ inline void ClipRect( llgfx_sRECT &dst, const llgfx_sRECT *cliprect); //::40 // +--------------+ // | ClipRect() | // +--------------+ inline void ClipRect( llgfx_sRECT *dst, const llgfx_sRECT *cliprect); //::41 // +---------------+ // | ClipRectB() | // +---------------+ inline bool ClipRectB( llgfx_sRECT &dst, const llgfx_sRECT &cliprect); //::42 // +---------------+ // | ClipRectB() | // +---------------+ inline bool ClipRectB( llgfx_sRECT *dst, const llgfx_sRECT &cliprect); //::43 // +---------------+ // | ClipRectB() | // +---------------+ inline bool ClipRectB( llgfx_sRECT &dst, const llgfx_sRECT *cliprect); //::44 // +---------------+ // | ClipRectB() | // +---------------+ inline bool ClipRectB( llgfx_sRECT *dst, const llgfx_sRECT *cliprect); //::1 // +--------------+ // | CopyRect() | // +--------------+ inline void CopyRect( llgfx_sRECT &dst, const llgfx_sRECT &src); //::2 // +--------------+ // | CopyRect() | // +--------------+ inline void CopyRect( llgfx_sRECT *dst, const llgfx_sRECT &src); //::3 // +--------------+ // | CopyRect() | // +--------------+ inline void CopyRect( llgfx_sRECT &dst, const llgfx_sRECT *src); //::4 // +--------------+ // | CopyRect() | // +--------------+ inline void CopyRect( llgfx_sRECT *dst, const llgfx_sRECT *src); //::45 // +---------------------+ // | GetBoundingRect() | // +---------------------+ inline llgfx_sRECT GetBoundingRect( const llgfx_sRECT &re1, const llgfx_sRECT &re2); //::46 // +---------------------+ // | GetBoundingRect() | // +---------------------+ inline llgfx_sRECT GetBoundingRect( const llgfx_sRECT &re1, const llgfx_sRECT *re2); //::47 // +---------------------+ // | GetBoundingRect() | // +---------------------+ inline llgfx_sRECT GetBoundingRect( const llgfx_sRECT *re1, const llgfx_sRECT *re2); //::48 // +---------------------+ // | GetBoundingRect() | // +---------------------+ inline llgfx_sRECT GetBoundingRect( const llgfx_sRECT *re1, const llgfx_sRECT &re2); //::49 // +----------------------+ // | GetIntersectRect() | // +----------------------+ inline llgfx_sRECT GetIntersectRect( const llgfx_sRECT &rect1, const llgfx_sRECT &rect2); //::50 // +----------------------+ // | GetIntersectRect() | // +----------------------+ inline llgfx_sRECT GetIntersectRect( const llgfx_sRECT *rect1, const llgfx_sRECT &rect2); //::51 // +----------------------+ // | GetIntersectRect() | // +----------------------+ inline llgfx_sRECT GetIntersectRect( const llgfx_sRECT &rect1, const llgfx_sRECT *rect2); //::52 // +----------------------+ // | GetIntersectRect() | // +----------------------+ inline llgfx_sRECT GetIntersectRect( const llgfx_sRECT *rect1, const llgfx_sRECT *rect2); //::53 // +------------------+ // | GetPointPosQ() | // +------------------+ //:Description // // Qualifiziert die Position von Punkt(x,y) zum Rechteck. // Return: // // Bit 0-3 x qualifizierer // Bit 4-7 y qualifizierer // // 0x20 P(x) liegt rechts ausserhalb des Rechtecks // 0x10 P(x) liegt innerhalb des Rechtecks // 0x00 P(x) liegt links ausserhalb des Rechtecks // // 0x02 P(y) liegt unten ausserhalb des Rechtecks // 0x01 P(y) liegt innerhalb des Rechtecks // 0x00 P(y) liegt oben ausserhalb des Rechtecks // inline int GetPointPosQ( int tx, int ty, const llgfx_sRECT *R); //::54 // +------------------+ // | GetPointPosQ() | // +------------------+ //:Description // // Qualifiziert die Position von Punkt(x,y) zum Rechteck. // Return: // // Bit 0-3 x qualifizierer // Bit 4-7 y qualifizierer // // 0x20 P(x) liegt rechts ausserhalb des Rechtecks // 0x10 P(x) liegt innerhalb des Rechtecks // 0x00 P(x) liegt links ausserhalb des Rechtecks // // 0x02 P(y) liegt unten ausserhalb des Rechtecks // 0x01 P(y) liegt innerhalb des Rechtecks // 0x00 P(y) liegt oben ausserhalb des Rechtecks // inline int GetPointPosQ( int tx, int ty, const llgfx_sRECT &R); //::17 // +------------+ // | HEIGHT() | // +------------+ inline int HEIGHT( const llgfx_sRECT &src); //::18 // +------------+ // | HEIGHT() | // +------------+ inline int HEIGHT( const llgfx_sRECT *src); //::23 // +-------------------+ // | IsPointInRect() | // +-------------------+ inline bool IsPointInRect( const llgfx_sRECT &rect, int x, int y); //::24 // +-------------------+ // | IsPointInRect() | // +-------------------+ inline bool IsPointInRect( const llgfx_sRECT *rect, int x, int y); //::35 // +-----------------+ // | IsRectEmpty() | // +-----------------+ inline bool IsRectEmpty( const llgfx_sRECT *rect); //::36 // +-----------------+ // | IsRectEmpty() | // +-----------------+ inline bool IsRectEmpty( const llgfx_sRECT &rect); //::25 // +-----------------+ // | IsRectEqual() | // +-----------------+ inline bool IsRectEqual( const llgfx_sRECT &rect1, const llgfx_sRECT &rect2); //::26 // +-----------------+ // | IsRectEqual() | // +-----------------+ inline bool IsRectEqual( const llgfx_sRECT *rect1, const llgfx_sRECT &rect2); //::27 // +-----------------+ // | IsRectEqual() | // +-----------------+ inline bool IsRectEqual( const llgfx_sRECT &rect1, const llgfx_sRECT *rect2); //::28 // +-----------------+ // | IsRectEqual() | // +-----------------+ inline bool IsRectEqual( const llgfx_sRECT *rect1, const llgfx_sRECT *rect2); //::55 // +------------------+ // | IsRectInRect() | // +------------------+ inline bool IsRectInRect( const llgfx_sRECT &rect, const llgfx_sRECT &reference_rect); //::56 // +------------------+ // | IsRectInRect() | // +------------------+ inline bool IsRectInRect( const llgfx_sRECT *rect, const llgfx_sRECT &reference_rect); //::57 // +------------------+ // | IsRectInRect() | // +------------------+ inline bool IsRectInRect( const llgfx_sRECT &rect, const llgfx_sRECT *reference_rect); //::58 // +------------------+ // | IsRectInRect() | // +------------------+ inline bool IsRectInRect( const llgfx_sRECT *rect, const llgfx_sRECT *reference_rect); //::31 // +----------------------------+ // | IsRectIntersectingRect() | // +----------------------------+ inline bool IsRectIntersectingRect( const llgfx_sRECT &rect, const llgfx_sRECT &reference_rect); //::32 // +----------------------------+ // | IsRectIntersectingRect() | // +----------------------------+ inline bool IsRectIntersectingRect( const llgfx_sRECT *rect, const llgfx_sRECT &reference_rect); //::33 // +----------------------------+ // | IsRectIntersectingRect() | // +----------------------------+ inline bool IsRectIntersectingRect( const llgfx_sRECT &rect, const llgfx_sRECT *reference_rect); //::34 // +----------------------------+ // | IsRectIntersectingRect() | // +----------------------------+ inline bool IsRectIntersectingRect( const llgfx_sRECT *rect, const llgfx_sRECT *reference_rect); //::29 // +-----------------+ // | IsRectValid() | // +-----------------+ inline bool IsRectValid( const llgfx_sRECT &rect); //::30 // +-----------------+ // | IsRectValid() | // +-----------------+ inline bool IsRectValid( const llgfx_sRECT *rect); //::19 // +----------+ // | MIDX() | // +----------+ inline int MIDX( const llgfx_sRECT &rect); //::20 // +----------+ // | MIDX() | // +----------+ inline int MIDX( const llgfx_sRECT *rect); //::21 // +----------+ // | MIDY() | // +----------+ inline int MIDY( const llgfx_sRECT &rect); //::22 // +----------+ // | MIDY() | // +----------+ inline int MIDY( const llgfx_sRECT *rect); //::13 // +--------------+ // | MoveRect() | // +--------------+ inline void MoveRect( llgfx_sRECT *dst, int x, int y); //::14 // +--------------+ // | MoveRect() | // +--------------+ inline void MoveRect( llgfx_sRECT &dst, int x, int y); //::9 // +----------------+ // | OffsetRect() | // +----------------+ inline void OffsetRect( llgfx_sRECT *dst, int x1, int y1); //::10 // +----------------+ // | OffsetRect() | // +----------------+ inline void OffsetRect( llgfx_sRECT *dst, llgfx_sRECT *src); //::11 // +----------------+ // | OffsetRect() | // +----------------+ inline void OffsetRect( llgfx_sRECT &dst, int x1, int y1); //::12 // +----------------+ // | OffsetRect() | // +----------------+ inline void OffsetRect( llgfx_sRECT &dst, llgfx_sRECT &src); //::5 // +-------------+ // | SetRect() | // +-------------+ inline void SetRect( llgfx_sRECT &dst, int x1, int y1, int x2, int y2); //::6 // +-------------+ // | SetRect() | // +-------------+ inline void SetRect( llgfx_sRECT *dst, int x1, int y1, int x2, int y2); //::7 // +------------------+ // | SetRectEmpty() | // +------------------+ inline void SetRectEmpty( llgfx_sRECT &dst); //::8 // +------------------+ // | SetRectEmpty() | // +------------------+ inline void SetRectEmpty( llgfx_sRECT *dst); // +----------------+ // | ExpandRect() | // +----------------+ inline void ExpandRect( llgfx_sRECT *dest, int xoffset, int yoffset ); // +----------------+ // | ExpandRect() | // +----------------+ inline void ExpandRect( llgfx_sRECT &dest, int xoffset, int yoffset ); // +----------------+ // | ExpandRect() | // +----------------+ inline void ExpandRect( llgfx_sRECT *dest, float xfaktor, float yfaktor ); // +----------------+ // | ExpandRect() | // +----------------+ inline void ExpandRect( llgfx_sRECT &dest, float xfaktor, float yfaktor ); //::15 // +-----------+ // | WIDTH() | // +-----------+ inline int WIDTH( const llgfx_sRECT &src); //::16 // +-----------+ // | WIDTH() | // +-----------+ //:Description // // namespace ll2d // inline int WIDTH( const llgfx_sRECT *src); //:> +-----------------------------------+ //:>-------------------| Global Function Definitions |-------------------- //:> +-----------------------------------+ //::37 // +--------------+ // | ClipRect() | // +--------------+ inline void ClipRect( llgfx_sRECT &dst, const llgfx_sRECT &cliprect) { if( dst.x1 < cliprect.x1 ) dst.x1=cliprect.x1; if( dst.x2 > cliprect.x2 ) dst.x2=cliprect.x2; if( dst.y1 < cliprect.y1 ) dst.y1=cliprect.y1; if( dst.y2 > cliprect.y2 ) dst.y2=cliprect.y2; if( dst.x2 <= dst.x1 || dst.y2 <= dst.y1 ) SetRectEmpty(dst); } //::38 // +--------------+ // | ClipRect() | // +--------------+ inline void ClipRect( llgfx_sRECT *dst, const llgfx_sRECT &cliprect) { if( dst->x1 < cliprect.x1 ) dst->x1=cliprect.x1; if( dst->y1 < cliprect.y1 ) dst->y1=cliprect.y1; if( dst->x2 > cliprect.x2 ) dst->x2=cliprect.x2; if( dst->y2 > cliprect.y2 ) dst->y2=cliprect.y2; if( dst->x2 <= dst->x1 || dst->y2 <= dst->y1 ) SetRectEmpty(dst); } //::39 // +--------------+ // | ClipRect() | // +--------------+ inline void ClipRect( llgfx_sRECT &dst, const llgfx_sRECT *cliprect) { if( dst.x1 < cliprect->x1 ) dst.x1=cliprect->x1; if( dst.y1 < cliprect->y1 ) dst.y1=cliprect->y1; if( dst.x2 > cliprect->x2 ) dst.x2=cliprect->x2; if( dst.y2 > cliprect->y2 ) dst.y2=cliprect->y2; if( dst.x2 <= dst.x1 || dst.y2 <= dst.y1 ) SetRectEmpty(dst); } //::40 // +--------------+ // | ClipRect() | // +--------------+ inline void ClipRect( llgfx_sRECT *dst, const llgfx_sRECT *cliprect) { if( dst->x1 < cliprect->x1 ) dst->x1=cliprect->x1; if( dst->y1 < cliprect->y1 ) dst->y1=cliprect->y1; if( dst->x2 > cliprect->x2 ) dst->x2=cliprect->x2; if( dst->y2 > cliprect->y2 ) dst->y2=cliprect->y2; if( dst->x2 <= dst->x1 || dst->y2 <= dst->y1 ) SetRectEmpty(dst); } //::41 // +---------------+ // | ClipRectB() | // +---------------+ inline bool ClipRectB( llgfx_sRECT &dst, const llgfx_sRECT &cliprect) { bool bclipped=false; if( dst.x1 < cliprect.x1 ) dst.x1=cliprect.x1,bclipped=true; if( dst.y1 < cliprect.y1 ) dst.y1=cliprect.y1,bclipped=true; if( dst.x2 > cliprect.x2 ) dst.x2=cliprect.x2,bclipped=true; if( dst.y2 > cliprect.y2 ) dst.y2=cliprect.y2,bclipped=true; if( dst.x2 <= dst.x1 || dst.y2 <= dst.y1 ) SetRectEmpty(dst),bclipped=false; return bclipped; } //::42 // +---------------+ // | ClipRectB() | // +---------------+ inline bool ClipRectB( llgfx_sRECT *dst, const llgfx_sRECT &cliprect) { bool bclipped=false; if( dst->x1 < cliprect.x1 ) dst->x1=cliprect.x1,bclipped=true; if( dst->y1 < cliprect.y1 ) dst->y1=cliprect.y1,bclipped=true; if( dst->x2 > cliprect.x2 ) dst->x2=cliprect.x2,bclipped=true; if( dst->y2 > cliprect.y2 ) dst->y2=cliprect.y2,bclipped=true; if( dst->x2 <= dst->x1 || dst->y2 <= dst->y1 ) SetRectEmpty(dst),bclipped=false; return bclipped; } //::43 // +---------------+ // | ClipRectB() | // +---------------+ inline bool ClipRectB( llgfx_sRECT &dst, const llgfx_sRECT *cliprect) { bool bclipped=false; if( dst.x1 < cliprect->x1 ) dst.x1=cliprect->x1,bclipped=true; if( dst.y1 < cliprect->y1 ) dst.y1=cliprect->y1,bclipped=true; if( dst.x2 > cliprect->x2 ) dst.x2=cliprect->x2,bclipped=true; if( dst.y2 > cliprect->y2 ) dst.y2=cliprect->y2,bclipped=true; if( dst.x2 <= dst.x1 || dst.y2 <= dst.y1 ) SetRectEmpty(dst),bclipped=false; return bclipped; } //::44 // +---------------+ // | ClipRectB() | // +---------------+ inline bool ClipRectB( llgfx_sRECT *dst, const llgfx_sRECT *cliprect) { bool bclipped=false; if( dst->x1 < cliprect->x1 ) dst->x1=cliprect->x1,bclipped=true; if( dst->y1 < cliprect->y1 ) dst->y1=cliprect->y1,bclipped=true; if( dst->x2 > cliprect->x2 ) dst->x2=cliprect->x2,bclipped=true; if( dst->y2 > cliprect->y2 ) dst->y2=cliprect->y2,bclipped=true; if( dst->x2 <= dst->x1 || dst->y2 <= dst->y1 ) SetRectEmpty(dst),bclipped=false; return bclipped; } //::1 // +--------------+ // | CopyRect() | // +--------------+ inline void CopyRect( llgfx_sRECT &dst, const llgfx_sRECT &src) { #ifdef _LIB_ASM_ENABLED _asm { MOV EDI, dst MOV ESI, src MOV ECX, 4 REP MOVSD } #else dst.x1 = src.x1; dst.y1 = src.y1; dst.x2 = src.x2; dst.y2 = src.y2; #endif } //::2 // +--------------+ // | CopyRect() | // +--------------+ inline void CopyRect( llgfx_sRECT *dst, const llgfx_sRECT &src) { #ifdef _LIB_ASM_ENABLED _asm { MOV EDI, dst MOV ESI, src MOV ECX, 4 REP MOVSD } #else dst->x1 = src.x1; dst->y1 = src.y1; dst->x2 = src.x2; dst->y2 = src.y2; #endif } //::3 // +--------------+ // | CopyRect() | // +--------------+ inline void CopyRect( llgfx_sRECT &dst, const llgfx_sRECT *src) { #ifdef _LIB_ASM_ENABLED _asm { MOV EDI, dst MOV ESI, src MOV ECX, 4 REP MOVSD } #else dst.x1 = src->x1; dst.y1 = src->y1; dst.x2 = src->x2; dst.y2 = src->y2; #endif } //::4 // +--------------+ // | CopyRect() | // +--------------+ inline void CopyRect( llgfx_sRECT *dst, const llgfx_sRECT *src) { #ifdef _LIB_ASM_ENABLED _asm { MOV EDI, dst MOV ESI, src MOV ECX, 4 REP MOVSD } #else dst->x1 = src->x1; dst->y1 = src->y1; dst->x2 = src->x2; dst->y2 = src->y2; #endif } //::45 // +---------------------+ // | GetBoundingRect() | // +---------------------+ inline llgfx_sRECT GetBoundingRect( const llgfx_sRECT &re1, const llgfx_sRECT &re2) { llgfx_sRECT result; result.x1 = re1.x1 < re2.x1 ? re1.x1 : re2.x1; result.x2 = re1.x2 > re2.x2 ? re1.x2 : re2.x2; result.y1 = re1.y1 < re2.y1 ? re1.y1 : re2.y1; result.y2 = re1.y2 > re2.y2 ? re1.y2 : re2.y2; return result; } //::46 // +---------------------+ // | GetBoundingRect() | // +---------------------+ inline llgfx_sRECT GetBoundingRect( const llgfx_sRECT &re1, const llgfx_sRECT *re2) { llgfx_sRECT result; result.x1 = re1.x1 < re2->x1 ? re1.x1 : re2->x1; result.x2 = re1.x2 > re2->x2 ? re1.x2 : re2->x2; result.y1 = re1.y1 < re2->y1 ? re1.y1 : re2->y1; result.y2 = re1.y2 > re2->y2 ? re1.y2 : re2->y2; return result; } //::47 // +---------------------+ // | GetBoundingRect() | // +---------------------+ inline llgfx_sRECT GetBoundingRect( const llgfx_sRECT *re1, const llgfx_sRECT *re2) { llgfx_sRECT result; result.x1 = re1->x1 < re2->x1 ? re1->x1 : re2->x1; result.x2 = re1->x2 > re2->x2 ? re1->x2 : re2->x2; result.y1 = re1->y1 < re2->y1 ? re1->y1 : re2->y1; result.y2 = re1->y2 > re2->y2 ? re1->y2 : re2->y2; return result; } //::48 // +---------------------+ // | GetBoundingRect() | // +---------------------+ inline llgfx_sRECT GetBoundingRect( const llgfx_sRECT *re1, const llgfx_sRECT &re2) { llgfx_sRECT result; result.x1 = re1->x1 < re2.x1 ? re1->x1 : re2.x1; result.x2 = re1->x2 > re2.x2 ? re1->x2 : re2.x2; result.y1 = re1->y1 < re2.y1 ? re1->y1 : re2.y1; result.y2 = re1->y2 > re2.y2 ? re1->y2 : re2.y2; return result; } //::49 // +----------------------+ // | GetIntersectRect() | // +----------------------+ inline llgfx_sRECT GetIntersectRect( const llgfx_sRECT &rect1, const llgfx_sRECT &rect2) { llgfx_sRECT result; CopyRect(result,rect1); if( ClipRectB(result,rect2) == false ) { CopyRect(result,rect2); } return result; } //::50 // +----------------------+ // | GetIntersectRect() | // +----------------------+ inline llgfx_sRECT GetIntersectRect( const llgfx_sRECT *rect1, const llgfx_sRECT &rect2) { llgfx_sRECT result; CopyRect(result,rect1); if( ClipRectB(result,rect2) == false ) { CopyRect(result,rect2); } return result; } //::51 // +----------------------+ // | GetIntersectRect() | // +----------------------+ inline llgfx_sRECT GetIntersectRect( const llgfx_sRECT &rect1, const llgfx_sRECT *rect2) { llgfx_sRECT result; CopyRect(result,rect1); if( ClipRectB(result,rect2) == false ) { CopyRect(result,rect2); } return result; } //::52 // +----------------------+ // | GetIntersectRect() | // +----------------------+ inline llgfx_sRECT GetIntersectRect( const llgfx_sRECT *rect1, const llgfx_sRECT *rect2) { llgfx_sRECT result; CopyRect(result,rect1); if( ClipRectB(result,rect2) == false ) { CopyRect(result,rect2); } return result; } //::53 // +------------------+ // | GetPointPosQ() | // +------------------+ inline int GetPointPosQ( int tx, int ty, const llgfx_sRECT *R) { int a; if( tx < R->x1 ) a=0x00; else if( tx > R->x2 ) a=0x20; else a=0x10; if( ty < R->y1 ) ; else if( ty > R->y2 ) a|=0x02; else a|=0x01; return a; } //::54 // +------------------+ // | GetPointPosQ() | // +------------------+ inline int GetPointPosQ( int tx, int ty, const llgfx_sRECT &R) { int a; if( tx < R.x1 ) a=0x00; else if( tx > R.x2 ) a=0x20; else a=0x10; if( ty < R.y1 ) ; else if( ty > R.y2 ) a|=0x02; else a|=0x01; return a; } //::17 // +------------+ // | HEIGHT() | // +------------+ inline int HEIGHT( const llgfx_sRECT &src) { return src.y2 - src.y1; } //::18 // +------------+ // | HEIGHT() | // +------------+ inline int HEIGHT( const llgfx_sRECT *src) { return src->y2 - src->y1; } //::23 // +-------------------+ // | IsPointInRect() | // +-------------------+ inline bool IsPointInRect( const llgfx_sRECT &rect, int x, int y) { if( x >= rect.x1 && y >= rect.y1 && x < rect.x2 && y < rect.y2 ) return true; else return false; } //::24 // +-------------------+ // | IsPointInRect() | // +-------------------+ inline bool IsPointInRect( const llgfx_sRECT *rect, int x, int y) { if( x >= rect->x1 && y >= rect->y1 && x < rect->x2 && y < rect->y2 ) return true; else return false; } //::35 // +-----------------+ // | IsRectEmpty() | // +-----------------+ inline bool IsRectEmpty( const llgfx_sRECT *rect) { return (rect->x1 == rect->x2 || rect->y1 == rect->y2); } //::36 // +-----------------+ // | IsRectEmpty() | // +-----------------+ inline bool IsRectEmpty( const llgfx_sRECT &rect) { return (rect.x1 == rect.x2 || rect.y1 == rect.y2); } //::25 // +-----------------+ // | IsRectEqual() | // +-----------------+ inline bool IsRectEqual( const llgfx_sRECT &rect1, const llgfx_sRECT &rect2) { if( rect1.x1 != rect2.x1 || rect1.y1 != rect2.y1 || rect1.x2 != rect2.x2 || rect1.y2 != rect2.y2) return false; else return true; } //::26 // +-----------------+ // | IsRectEqual() | // +-----------------+ inline bool IsRectEqual( const llgfx_sRECT *rect1, const llgfx_sRECT &rect2) { if( rect1->x1 != rect2.x1 || rect1->y1 != rect2.y1 || rect1->x2 != rect2.x2 || rect1->y2 != rect2.y2) return false; else return true; } //::27 // +-----------------+ // | IsRectEqual() | // +-----------------+ inline bool IsRectEqual( const llgfx_sRECT &rect1, const llgfx_sRECT *rect2) { if( rect1.x1 != rect2->x1 || rect1.y1 != rect2->y1 || rect1.x2 != rect2->x2 || rect1.y2 != rect2->y2) return false; else return true; } //::28 // +-----------------+ // | IsRectEqual() | // +-----------------+ inline bool IsRectEqual( const llgfx_sRECT *rect1, const llgfx_sRECT *rect2) { if( rect1->x1 != rect2->x1 || rect1->y1 != rect2->y1 || rect1->x2 != rect2->x2 || rect1->y2 != rect2->y2) return false; else return true; } //::55 // +------------------+ // | IsRectInRect() | // +------------------+ inline bool IsRectInRect( const llgfx_sRECT &rect, const llgfx_sRECT &reference_rect) { if( 0x11 == GetPointPosQ( rect.x1, rect.y1, reference_rect) && 0x11 == GetPointPosQ( rect.x2, rect.y2, reference_rect) ) return true; else return false; } //::56 // +------------------+ // | IsRectInRect() | // +------------------+ inline bool IsRectInRect( const llgfx_sRECT *rect, const llgfx_sRECT &reference_rect) { if( 0x11 == GetPointPosQ( rect->x1, rect->y1, reference_rect) && 0x11 == GetPointPosQ( rect->x2, rect->y2, reference_rect) ) return true; else return false; } //::57 // +------------------+ // | IsRectInRect() | // +------------------+ inline bool IsRectInRect( const llgfx_sRECT &rect, const llgfx_sRECT *reference_rect) { if( 0x11 == GetPointPosQ( rect.x1, rect.y1, reference_rect) && 0x11 == GetPointPosQ( rect.x2, rect.y2, reference_rect) ) return true; else return false; } //::58 // +------------------+ // | IsRectInRect() | // +------------------+ inline bool IsRectInRect( const llgfx_sRECT *rect, const llgfx_sRECT *reference_rect) { if( 0x11 == GetPointPosQ( rect->x1, rect->y1, reference_rect) && 0x11 == GetPointPosQ( rect->x2, rect->y2, reference_rect) ) return true; else return false; } //::31 // +----------------------------+ // | IsRectIntersectingRect() | // +----------------------------+ inline bool IsRectIntersectingRect( const llgfx_sRECT &rect, const llgfx_sRECT &reference_rect) { if( rect.x2 <= reference_rect.x1 || rect.y2 <= reference_rect.y1 || rect.x1 >= reference_rect.x2 || rect.y1 >= reference_rect.y2 ) return false; else return true; } //::32 // +----------------------------+ // | IsRectIntersectingRect() | // +----------------------------+ inline bool IsRectIntersectingRect( const llgfx_sRECT *rect, const llgfx_sRECT &reference_rect) { if( rect->x2 <= reference_rect.x1 || rect->y2 <= reference_rect.y1 || rect->x1 >= reference_rect.x2 || rect->y1 >= reference_rect.y2 ) return false; else return true; } //::33 // +----------------------------+ // | IsRectIntersectingRect() | // +----------------------------+ inline bool IsRectIntersectingRect( const llgfx_sRECT &rect, const llgfx_sRECT *reference_rect) { if( rect.x2 <= reference_rect->x1 || rect.y2 <= reference_rect->y1 || rect.x1 >= reference_rect->x2 || rect.y1 >= reference_rect->y2 ) return false; else return true; } //::34 // +----------------------------+ // | IsRectIntersectingRect() | // +----------------------------+ inline bool IsRectIntersectingRect( const llgfx_sRECT *rect, const llgfx_sRECT *reference_rect) { if( rect->x2 <= reference_rect->x1 || rect->y2 <= reference_rect->y1 || rect->x1 >= reference_rect->x2 || rect->y1 >= reference_rect->y2 ) return false; else return true; } //::29 // +-----------------+ // | IsRectValid() | // +-----------------+ inline bool IsRectValid( const llgfx_sRECT &rect) { if( rect.x1 > rect.x2 ) return false; if( rect.y1 > rect.y2 ) return false; return true; } //::30 // +-----------------+ // | IsRectValid() | // +-----------------+ inline bool IsRectValid( const llgfx_sRECT *rect) { if( rect->x1 > rect->x2 ) return false; if( rect->y1 > rect->y2 ) return false; return true; } //::19 // +----------+ // | MIDX() | // +----------+ inline int MIDX( const llgfx_sRECT &rect) { return rect.x1+((rect.x2-rect.x1)>>1); } //::20 // +----------+ // | MIDX() | // +----------+ inline int MIDX( const llgfx_sRECT *rect) { return rect->x1+((rect->x2-rect->x1)>>1); } //::21 // +----------+ // | MIDY() | // +----------+ inline int MIDY( const llgfx_sRECT &rect) { return rect.y1+((rect.y2-rect.y1)>>1); } //::22 // +----------+ // | MIDY() | // +----------+ inline int MIDY( const llgfx_sRECT *rect) { return rect->y1+((rect->y2-rect->y1)>>1); } //::13 // +--------------+ // | MoveRect() | // +--------------+ inline void MoveRect( llgfx_sRECT *dst, int x, int y) { dst->x2-=dst->x; dst->y2-=dst->y; dst->x=x; dst->y=y; dst->x2+=x; dst->y2+=y; } //::14 // +--------------+ // | MoveRect() | // +--------------+ inline void MoveRect( llgfx_sRECT &dst, int x, int y) { dst.x2-=dst.x; dst.y2-=dst.y; dst.x=x; dst.y=y; dst.x2+=x; dst.y2+=y; } //::9 // +----------------+ // | OffsetRect() | // +----------------+ inline void OffsetRect( llgfx_sRECT *dst, int x1, int y1) { dst->x1+=x1; dst->x2+=x1; dst->y1+=y1; dst->y2+=y1; } //::10 // +----------------+ // | OffsetRect() | // +----------------+ inline void OffsetRect( llgfx_sRECT *dst, llgfx_sRECT *src) { dst->x1+=src->x1; dst->x2+=src->x1; dst->y1+=src->y1; dst->y2+=src->y1; } //::11 // +----------------+ // | OffsetRect() | // +----------------+ inline void OffsetRect( llgfx_sRECT &dst, int x1, int y1) { dst.x1+=x1; dst.x2+=x1; dst.y1+=y1; dst.y2+=y1; } //::12 // +----------------+ // | OffsetRect() | // +----------------+ inline void OffsetRect( llgfx_sRECT &dst, llgfx_sRECT &src) { dst.x1+=src.x1; dst.x2+=src.x1; dst.y1+=src.y1; dst.y2+=src.y1; } //::5 // +-------------+ // | SetRect() | // +-------------+ inline void SetRect( llgfx_sRECT &dst, int x1, int y1, int x2, int y2) { dst.x1=x1; dst.x2=x2; dst.y1=y1; dst.y2=y2; } //::6 // +-------------+ // | SetRect() | // +-------------+ inline void SetRect( llgfx_sRECT *dst, int x1, int y1, int x2, int y2) { dst->x1=x1; dst->x2=x2; dst->y1=y1; dst->y2=y2; } //::7 // +------------------+ // | SetRectEmpty() | // +------------------+ inline void SetRectEmpty( llgfx_sRECT &dst) { #ifdef _LIB_ASM_ENABLED __asm { MOV EDI, dst XOR EAX, EAX MOV ECX, 4 REP STOSD } #else dst.x1 = 0; dst.y1 = 0; dst.x2 = 0; dst.y2 = 0; #endif } //::8 // +------------------+ // | SetRectEmpty() | // +------------------+ inline void SetRectEmpty( llgfx_sRECT *dst) { #ifdef _LIB_ASM_ENABLED __asm { MOV EDI, dst XOR EAX, EAX MOV ECX, 4 REP STOSD } #else dst->x1 = 0; dst->y1 = 0; dst->x2 = 0; dst->y2 = 0; #endif } // +----------------+ // | ExpandRect() | // +----------------+ inline void ExpandRect( llgfx_sRECT *dest, int xoffset, int yoffset ) { dest->x1 -= xoffset; dest->x2 += xoffset; dest->y1 -= yoffset; dest->y2 += yoffset; } // +----------------+ // | ExpandRect() | // +----------------+ inline void ExpandRect( llgfx_sRECT &dest, int xoffset, int yoffset ) { dest.x1 -= xoffset; dest.x2 += xoffset; dest.y1 -= yoffset; dest.y2 += yoffset; } // +----------------+ // | ExpandRect() | // +----------------+ inline void ExpandRect( llgfx_sRECT *dest, float xfaktor, float yfaktor ) { int w = ll2d::WIDTH(dest); int xoffset = w - (int)( w * xfaktor); int h = ll2d::HEIGHT(dest); int yoffset = h - (int)( h * yfaktor); ExpandRect(dest,xoffset>>1,yoffset>>1); } // +----------------+ // | ExpandRect() | // +----------------+ inline void ExpandRect( llgfx_sRECT &dest, float xfaktor, float yfaktor ) { int w = ll2d::WIDTH(dest); int xoffset = w - (int)( w * xfaktor); int h = ll2d::HEIGHT(dest); int yoffset = h - (int)( h * yfaktor); ExpandRect(dest,xoffset>>1,yoffset>>1); } //::15 // +-----------+ // | WIDTH() | // +-----------+ inline int WIDTH( const llgfx_sRECT &src) { return src.x2 - src.x1; } //::16 // +-----------+ // | WIDTH() | // +-----------+ inline int WIDTH( const llgfx_sRECT *src) { return src->x2 - src->x1; } inline bool ClipPointToRect( llgfx_sRECT &dst, int &x1, int &y1 ) { int x2 = MIDX(dst); int y2 = MIDY(dst); int xmax = dst.x2 -1 ; int ymax = dst.y2 -1 ; bool out = false; bool clipped = false; do{ if (x1 < dst.x1) // clip left { y1 = y1 + ((y2 - y1) * (dst.x1 - x1)) / (x2 - x1); x1 = dst.x1; out = true; clipped = true; } else if (y1 < dst.y1) // clip above { x1 = x1 + ((x2 - x1) * (dst.y1 - y1)) / (y2 - y1); y1 = dst.y1; out = true; clipped = true; } else if (x1 > xmax) // clip right { y1 = y1 + ((y2 - y1) * (xmax - x1)) / (x2 - x1); x1 = xmax; out = true; clipped = true; } else if (y1 > ymax) // clip below { x1 = x1 + ((x2 - x1) * (ymax - y1)) / (y2 - y1); y1 = ymax; out = true; clipped = true; } else out = false; // break }while( out ); return clipped; } //:End Namespace GTOR_END_NAMESPACE() #endif // LL2D_RECT_INCLUDED