00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef DRAWLIBS_H
00023 #define DRAWLIBS_H
00024
00025 #include "SDL.h"
00026
00027 template<typename T>
00028 inline int sgn(T x)
00029 {
00030 return x < 0 ? -1 : (x > 0 ? 1 : 0);
00031 }
00032
00033 DLLEXPORT SDL_Surface *CreateSurface(Uint32 flags, int width, int height,
00034 int bpp = 32);
00035 DLLEXPORT void ConvertSurface(SDL_Surface ** surface);
00036
00037 DLLEXPORT void DrawPixel(SDL_Surface * screen, int x, int y, Uint32 color);
00038 DLLEXPORT void DrawLine(SDL_Surface * screen, int x1, int y1, int x2, int y2,
00039 Uint32 color);
00040 DLLEXPORT void DrawRect(SDL_Surface * screen, int x1, int y1, int x2, int y2,
00041 Uint32 color);
00042 DLLEXPORT void DrawRound(SDL_Surface * screen, int x0, int y0, int w, int h,
00043 int corner, Uint32 color);
00044
00045 DLLEXPORT void vertgradient(SDL_Surface * surf, SDL_Color c1, SDL_Color c2,
00046 Uint8 alpha = 255);
00047 DLLEXPORT void vertgradient2(SDL_Surface * surf, SDL_Rect & gradRect,
00048 SDL_Color c1, SDL_Color c2, Uint8 alpha = 255);
00049 DLLEXPORT void horizgradient2(SDL_Surface * surf, SDL_Rect & gradRect,
00050 SDL_Color c1, SDL_Color c2, Uint8 alpha = 255);
00051
00052 DLLEXPORT Uint32 GetPixel(SDL_Surface * surface, int x, int y);
00053 DLLEXPORT void FloodFill(SDL_Surface * screen, int x, int y, Uint32 c);
00054 DLLEXPORT void DrawTriangle(SDL_Surface * s, int x[3], int y[3], Uint32 c);
00055
00056 enum
00057 {
00058 ARROW_UP,
00059 ARROW_DOWN,
00060 ARROW_LEFT,
00061 ARROW_RIGHT
00062 };
00063 DLLEXPORT void DrawArrow(SDL_Surface * s, int type, int x, int y, int a,
00064 Uint32 color, bool fill = false, Uint32 fillcolor = 0);
00065
00066 #define SLOCK(surface) \
00067 do { \
00068 if(SDL_MUSTLOCK(surface)) \
00069 SDL_LockSurface(surface); \
00070 } while(0)
00071
00072 #define SUNLOCK(surface) \
00073 do { \
00074 if(SDL_MUSTLOCK(surface)) \
00075 SDL_UnlockSurface(surface); \
00076 } while(0)
00077
00078 #endif