00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00034 #ifndef PG_DRAW_H
00035 #define PG_DRAW_H
00036
00037 #include "pgrect.h"
00038 #include "pgcolor.h"
00039
00040 #ifndef M_PI
00041
00045 #define M_PI 3.14159265359
00046 #endif // M_PI
00047
00048 namespace PG_Draw {
00049
00050
00051 enum BkMode {
00052 TILE,
00057 STRETCH,
00064 TILE3H,
00069 TILE3V,
00074 TILE9
00075 };
00076
00083
00084
00098 DECLSPEC SDL_Surface* RotoScaleSurface(SDL_Surface *src, double angle,
00099 double zoom, bool smooth = true);
00100
00102
00113 DECLSPEC SDL_Surface* ScaleSurface(SDL_Surface *src, double zoomx, double zoomy,
00114 bool smooth = true);
00115
00117
00128 static inline SDL_Surface *ScaleSurface(SDL_Surface *src, const PG_Rect &rect,
00129 bool smooth = true) {
00130 return ScaleSurface(src, static_cast<double>(rect.w) / src->w,
00131 static_cast<double>(rect.h) / src->h, smooth);
00132 }
00133
00135
00146 static inline SDL_Surface *ScaleSurface(SDL_Surface *src, Uint16 newx, Uint16 newy,
00147 bool smooth = true) {
00148 return ScaleSurface(src, static_cast<double>(newx) / src->w,
00149 static_cast<double>(newy) / src->h, smooth);
00150 }
00151
00153
00162 DECLSPEC void BlitScale(SDL_Surface *src, SDL_Surface *dst, bool smooth = true);
00163
00173 DECLSPEC SDL_Surface* CreateGradient(const PG_Rect& r, PG_Gradient& gradient);
00174
00187 DECLSPEC SDL_Surface* CreateGradient(const PG_Rect& r, const PG_Color& ul, const PG_Color& ur, const PG_Color& dl, const PG_Color& dr);
00188
00199 DECLSPEC void DrawGradient(SDL_Surface* surface, const PG_Rect& r, PG_Gradient& gradient);
00200
00214 DECLSPEC void DrawGradient(SDL_Surface * surface, const PG_Rect& rect, const PG_Color& ul, const PG_Color& ur, const PG_Color& dl, const PG_Color& dr);
00215
00224 DECLSPEC SDL_Surface* CreateRGBSurface(Uint16 w, Uint16 h, int flags = SDL_SWSURFACE);
00225
00239 DECLSPEC void DrawThemedSurface(SDL_Surface* surface, const PG_Rect& r, PG_Gradient* gradient, SDL_Surface* background, BkMode bkmode, Uint8 blend);
00240
00253 DECLSPEC void DrawLine(SDL_Surface* surface, Uint32 x0, Uint32 y0, Uint32 x1, Uint32 y1, const PG_Color& color, Uint8 width = 1);
00254
00265 DECLSPEC void SetPixel(int x, int y, const PG_Color& c, SDL_Surface * surface);
00266
00276 inline void BlitSurface(SDL_Surface* srf_src, const PG_Rect& rect_src, SDL_Surface* srf_dst, const PG_Rect& rect_dst) {
00277 SDL_BlitSurface(srf_src, const_cast<PG_Rect*>(&rect_src), srf_dst, const_cast<PG_Rect*>(&rect_dst));
00278 }
00279
00292 DECLSPEC void DrawTile(SDL_Surface* surface, const PG_Rect& ref, const PG_Rect& drawrect, SDL_Surface* tilemap);
00293
00294 #ifndef DOXYGEN_SKIP
00295
00296 DECLSPEC void RectStretch(SDL_Surface* src_surface, int xs1, int ys1, int xs2, int ys2, SDL_Surface* dst_surface, int xd1, int yd1, int xd2, int yd2, Uint32* voiLUT);
00297 DECLSPEC void CreateFilterLUT();
00298 DECLSPEC void PG_SmoothFast(SDL_Surface* src, SDL_Surface* dst);
00299 DECLSPEC void InterpolatePixel(SDL_Surface* src, SDL_Surface* dest);
00300 #endif // DOXYGEN_SKIP
00301
00302 }
00303
00304 #endif // PG_DRAW_H