00001 00023 #include "IsoGeometryTools.h" 00024 00026 00028 POINT CreatePoint(int x, int y) { 00029 POINT result; 00030 00031 result.x = x; 00032 result.y = y; 00033 00034 return result; 00035 } 00036 00038 SDL_Rect* GetSDLRect(POINT* p) { 00039 SDL_Rect* result = new SDL_Rect(); 00040 00041 result->x = p->x; 00042 result->y = p->y; 00043 00044 result->w = 0; 00045 result->h = 0; 00046 00047 return result; 00048 } 00049 00050 bool PointInRect(RECT* r, POINT* p) { 00051 if(p->x <= r->left) { 00052 return false; 00053 } 00054 00055 if(p->x > r->right) { 00056 return false; 00057 } 00058 00059 if(p->y <= r->top) { 00060 return false; 00061 } 00062 00063 if(p->y > r->bottom) { 00064 return false; 00065 } 00066 00067 return true; 00068 } 00069 00071 00072 00073 00075 00077 void setRectEmpty(RECT* rectangle) { 00078 rectangle->bottom = 0; 00079 rectangle->left = 0; 00080 rectangle->right = 0; 00081 rectangle->top = 0; 00082 } 00083 00085 void setRect(RECT* rectangle, long left, long top, long right, long bottom) { 00086 rectangle->bottom = bottom; 00087 rectangle->left = left; 00088 rectangle->right = right; 00089 rectangle->top = top; 00090 } 00091 00093 void CopyRect(RECT* destination, RECT* source) { 00094 destination->bottom = source->bottom; 00095 destination->left = source->left; 00096 destination->right = source->right; 00097 destination->top = source->top; 00098 } 00099 00101 void OffsetRect(RECT* rectangle, int dx, int dy) { 00102 rectangle->left += dx; 00103 rectangle->right += dx; 00104 00105 rectangle->top += dy; 00106 rectangle->bottom += dy; 00107 } 00108 00109 void OffsetRect(RECT* rectangle, POINT point) { 00110 OffsetRect(rectangle, point.x, point.y); 00111 } 00112 00114 SDL_Rect* GetSDLRect(RECT* r) { 00115 SDL_Rect* result = new SDL_Rect(); 00116 00117 result->x = r->left; 00118 result->y = r->top; 00119 result->w = r->right - r->left; 00120 result->h = r->bottom - r->top; 00121 00122 return result; 00123 } 00124