Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

pgdraw.h File Reference

Header file for the PG_Draw namespace. More...

#include "pgrect.h"
#include "pgcolor.h"

Include dependency graph for pgdraw.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  PG_Draw

Defines

#define M_PI   3.14159265359
 The definition of the number PI.

Enumerations

enum  BkMode {
  TILE, STRETCH, TILE3H, TILE3V,
  TILE9
}

Functions

DECLSPEC SDL_Surface * RotoScaleSurface (SDL_Surface *src, double angle, double zoom, bool smooth=true)
 Rotate and scale an SDL_Surface.
DECLSPEC SDL_Surface * ScaleSurface (SDL_Surface *src, double zoomx, double zoomy, bool smooth=true)
 Scale an SDL_Surface.
static SDL_Surface * ScaleSurface (SDL_Surface *src, const PG_Rect &rect, bool smooth=true)
 Scale an SDL_Surface.
static SDL_Surface * ScaleSurface (SDL_Surface *src, Uint16 newx, Uint16 newy, bool smooth=true)
 Scale an SDL_Surface.
DECLSPEC void BlitScale (SDL_Surface *src, SDL_Surface *dst, bool smooth=true)
 Scale and blit surface.
DECLSPEC SDL_Surface * CreateGradient (const PG_Rect &r, PG_Gradient &gradient)
 Creates a surface filled with a gradient.
DECLSPEC SDL_Surface * CreateGradient (const PG_Rect &r, const PG_Color &ul, const PG_Color &ur, const PG_Color &dl, const PG_Color &dr)
 Creates a surface filled with a gradient.
DECLSPEC void DrawGradient (SDL_Surface *surface, const PG_Rect &r, PG_Gradient &gradient)
 Draw a gradient on a surface.
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)
 Draw a gradient on a surface.
DECLSPEC SDL_Surface * CreateRGBSurface (Uint16 w, Uint16 h, int flags=SDL_SWSURFACE)
 Create a new SDL surface.
DECLSPEC void DrawThemedSurface (SDL_Surface *surface, const PG_Rect &r, PG_Gradient *gradient, SDL_Surface *background, BkMode bkmode, Uint8 blend)
 Draw a 'themed' surface.
DECLSPEC void DrawLine (SDL_Surface *surface, Uint32 x0, Uint32 y0, Uint32 x1, Uint32 y1, const PG_Color &color, Uint8 width=1)
 Draw a line.
DECLSPEC void SetPixel (int x, int y, const PG_Color &c, SDL_Surface *surface)
 Set a pixel.
void BlitSurface (SDL_Surface *srf_src, const PG_Rect &rect_src, SDL_Surface *srf_dst, const PG_Rect &rect_dst)
 replacement for SDL_BlitSurface
DECLSPEC void DrawTile (SDL_Surface *surface, const PG_Rect &ref, const PG_Rect &drawrect, SDL_Surface *tilemap)
 Tiles a surface with a given image.
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)
DECLSPEC void CreateFilterLUT ()
DECLSPEC void PG_SmoothFast (SDL_Surface *src, SDL_Surface *dst)
DECLSPEC void InterpolatePixel (SDL_Surface *src, SDL_Surface *dest)


Detailed Description

Header file for the PG_Draw namespace.

Author:
Alexander Pipelka

Definition in file pgdraw.h.


Define Documentation

#define M_PI   3.14159265359
 

The definition of the number PI.

Some platforms dont define M_PI. So we have to define it.

Definition at line 45 of file pgdraw.h.

Referenced by PG_Draw::RotoScaleSurface(), and sinc().


Enumeration Type Documentation

enum PG_Draw::BkMode
 

Enumeration values:
TILE 
STRETCH  Backgroundmode STRETCH.

Macro defining the background mode for stretching

TILE3H  Backgroundmode 3TILEH.

Macro defining the background mode for horizontal 3 part tiling (the left part of the tile to the left, the right part to the right, the middle part repeatedly within the rest)

TILE3V  Backgroundmode 3TILEV.

Macro defining the background mode for vertical 3 part tiling

TILE9  Backgroundmode 9TILE.

Macro defining the background mode for 9 part tiling

Definition at line 51 of file pgdraw.h.


Function Documentation

DECLSPEC void PG_Draw::BlitScale SDL_Surface *  src,
SDL_Surface *  dst,
bool  smooth = true
 

Scale and blit surface.

Scales a 32 bit or 8 bit SDL_Surface to the size of the destination surface dst and blits the result to the destination surface. If the surface is not 8bit or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.

Parameters:
src Source surface
dst destination surface
smooth whether or not to use anti-aliasing

void PG_Draw::BlitSurface SDL_Surface *  srf_src,
const PG_Rect rect_src,
SDL_Surface *  srf_dst,
const PG_Rect rect_dst
[inline]
 

replacement for SDL_BlitSurface

Parameters:
srf_src source surface
rect_src PG_Rect of the source rectangle
srf_dst destination surface
rect_dst PG_Rect of the destination rectangle
This function simply replaces SDL_BlitSurface and uses PG_Rect instead of SDL_Rect.

Definition at line 276 of file pgdraw.h.

Referenced by VehicleTypeBaseWidget::display(), TechWidget::display(), BuildingTypeBaseWidget::display(), MapComponent::displayClip(), Draw3TileH(), Draw3TileV(), Draw9Tile(), PG_WidgetDnD::drawDragArea(), DrawTileSurface(), PG_Widget::eventBlit(), PG_ProgressBar::eventBlit(), PG_Button::eventBlit(), StoringPosition::eventBlit(), PG_Widget::FadeIn(), PG_Widget::FadeOut(), and PG_Draw::DrawTile().

DECLSPEC void PG_Draw::CreateFilterLUT  ) 
 

DECLSPEC SDL_Surface* PG_Draw::CreateGradient const PG_Rect r,
const PG_Color ul,
const PG_Color ur,
const PG_Color dl,
const PG_Color dr
 

Creates a surface filled with a gradient.

Parameters:
r the dimensions of the surface to be created
ul upper/left gradient color
ur upper/right gradient color
dl lower/left gradient color
dr lower/right gradient color
Returns:
a SDL_Surface pointer to the new surface
This function creates a new surface filled with a given gradient defined by a set of colors

DECLSPEC SDL_Surface* PG_Draw::CreateGradient const PG_Rect r,
PG_Gradient gradient
 

Creates a surface filled with a gradient.

Parameters:
r the dimensions of the surface to be created
gradient the gradient colors to use (order: ul(upper left), ur, dl, dr)
Returns:
a SDL_Surface pointer to the new surface
This function creates a new surface filled with a given gradient defined by a set of colors

Referenced by PG_Draw::CreateGradient().

DECLSPEC SDL_Surface* PG_Draw::CreateRGBSurface Uint16  w,
Uint16  h,
int  flags = SDL_SWSURFACE
 

Create a new SDL surface.

Parameters:
w width of the new surface
h height of the new surface
flags surface-flags (default = SDL_SWSURFACE)
Returns:
pointer to the new surface This function creates a new SDL surface

Referenced by PG_Application::DrawCursor(), PG_WidgetDnD::eventMouseButtonDown(), PG_Widget::FadeIn(), PG_Widget::FadeOut(), PG_Draw::CreateGradient(), PG_Widget::PG_Widget(), and PG_Widget::SizeWidget().

DECLSPEC void PG_Draw::DrawGradient SDL_Surface *  surface,
const PG_Rect rect,
const PG_Color ul,
const PG_Color ur,
const PG_Color dl,
const PG_Color dr
 

Draw a gradient on a surface.

Parameters:
surface the surface to draw the gradient to
rect the rectangle where the gradient should be drawn
ul upper/left gradient color
ur upper/right gradient color
dl lower/left gradient color
dr lower/right gradient color
This function is the same as the other one above except that the gradient colors are the arguments instead of a gradient.

DECLSPEC void PG_Draw::DrawGradient SDL_Surface *  surface,
const PG_Rect r,
PG_Gradient gradient
 

Draw a gradient on a surface.

Parameters:
surface the surface to draw the gradient to
r the rectangle where the gradient should be drawn
gradient the gradient colors (order: ul(upper left), ur, dl, dr)
Note:
If the surface is clipped, the gradient is only drawn within the intersection of the clipping rect and r.

Referenced by PG_Draw::CreateGradient(), PG_Draw::DrawGradient(), and PG_Draw::DrawThemedSurface().

DECLSPEC void PG_Draw::DrawLine SDL_Surface *  surface,
Uint32  x0,
Uint32  y0,
Uint32  x1,
Uint32  y1,
const PG_Color color,
Uint8  width = 1
 

Draw a line.

Parameters:
surface destination surface
x0 x startposition
y0 y startposition
x1 x endposition
y1 y endposition
color color of the line
width width of the line
Draws a line with given color and width onto a surface.

Referenced by PG_Widget::DrawLine().

DECLSPEC void PG_Draw::DrawThemedSurface SDL_Surface *  surface,
const PG_Rect r,
PG_Gradient gradient,
SDL_Surface *  background,
BkMode  bkmode,
Uint8  blend
 

Draw a 'themed' surface.

Parameters:
surface the surface to draw on
r the rectangle of the surface to draw in
gradient pointer to a gradient structure (may be NULL)
background pointer to a background surface (may be NULL)
bkmode the mode how to fill in the background surface (BKMODE_TILE | BKMODE_STRETCH | BKMODE_3TILEH | BKMODE_3TILEV | BKMODE_9TILE)
blend the blend-level between gradient an background; the higher the blend level the more transparent the background is.
Note:
This function first draws the gradient, then the (partly transparent) background.

Referenced by PG_ThemeWidget::CreateThemedSurface(), PG_PopupMenu::eventBlit(), PG_Image::eventBlit(), and PG_ThemeWidget::eventDraw().

DECLSPEC void PG_Draw::DrawTile SDL_Surface *  surface,
const PG_Rect ref,
const PG_Rect drawrect,
SDL_Surface *  tilemap
 

Tiles a surface with a given image.

Parameters:
surface the surface to draw to
ref unused, to be removed
drawrect the area on the surface you want to draw to
tilemap the image you want to tile the surface with
This function takes the tilemap and repeatedly blits it on the surface. If drawrect->w is not a multiple of tilemap->w (the same with the height), the tiles on the right or lower border are cut off appropriately.

Referenced by PG_Application::RedrawBackground().

DECLSPEC void PG_Draw::InterpolatePixel SDL_Surface *  src,
SDL_Surface *  dest
 

DECLSPEC void PG_Draw::PG_SmoothFast SDL_Surface *  src,
SDL_Surface *  dst
 

DECLSPEC void PG_Draw::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
 

DECLSPEC SDL_Surface* PG_Draw::RotoScaleSurface SDL_Surface *  src,
double  angle,
double  zoom,
bool  smooth = true
 

Rotate and scale an SDL_Surface.

Rotates and scales a 32bit or 8bit SDL_Surface to newly created destination surface. If smooth is 1 the destination 32bit surface is anti-aliased. If the surface is not 8bit or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.

Parameters:
src source surface
angle the rotation in degrees
zoom the scaling factor
smooth whether or not to use anti-aliasing
Returns:
A new surface with the scaled, rotated original surface.

static SDL_Surface* PG_Draw::ScaleSurface SDL_Surface *  src,
Uint16  newx,
Uint16  newy,
bool  smooth = true
[inline, static]
 

Scale an SDL_Surface.

Scales a 32bit or 8bit SDL_Surface to newly created destination surface. If the surface is not 8bit or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.

Parameters:
src source surface
newx,newy the width and height of the new surface
smooth whether or not to enable anti-aliasing
Returns:
A newly created surface with the scaled surface

Definition at line 146 of file pgdraw.h.

References PG_Draw::ScaleSurface(), and ForestCalculation::smooth().

static SDL_Surface* PG_Draw::ScaleSurface SDL_Surface *  src,
const PG_Rect rect,
bool  smooth = true
[inline, static]
 

Scale an SDL_Surface.

Scales a 32bit or 8bit SDL_Surface to newly created destination surface. If the surface is not 8bit or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.

Parameters:
src source surface
rect PG_Rect specifying the width and height of the new surface
smooth whether or not to enable anti-aliasing
Returns:
A newly created surface with the scaled surface

Definition at line 128 of file pgdraw.h.

References PG_Draw::ScaleSurface(), and ForestCalculation::smooth().

DECLSPEC SDL_Surface* PG_Draw::ScaleSurface SDL_Surface *  src,
double  zoomx,
double  zoomy,
bool  smooth = true
 

Scale an SDL_Surface.

Scales a 32bit or 8bit SDL_Surface to newly created destination surface. If the surface is not 8bit or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.

Parameters:
src source surface
zoomx,zoomy width and height scaling factors
smooth whether or not to enable anti-aliasing
Returns:
A newly created surface with the scaled surface

Referenced by Draw3TileH(), Draw3TileV(), PG_Draw::BlitScale(), PG_Draw::DrawThemedSurface(), PG_Application::RedrawBackground(), PG_Draw::ScaleSurface(), and SmallGuiButton::updateIcon().

DECLSPEC void PG_Draw::SetPixel int  x,
int  y,
const PG_Color c,
SDL_Surface *  surface
 

Set a pixel.

Parameters:
x x position
y y position
c color
surface destination surface
Note:
This function assumes that the surface has already been locked if neccessary.

Referenced by plotpixel(), and PG_Widget::SetPixel().


Generated on Tue Jun 24 01:58:22 2008 for Advanced Strategic Command by  doxygen 1.4.2