Adonthell 0.4
|
Class where drawables can actually be drawn to. More...
#include <surface.h>
Public Member Functions | |
surface (bool mode=true) | |
Default constructor. | |
virtual | ~surface () |
Destructor. | |
surface & | operator= (surface &src) |
Surface copy (similar to copy ()). | |
void | copy (surface &src) |
Synonym of operator = to guarantee its access from Python. | |
Settings. | |
These methods sets the parameters of the surface. | |
bool | is_masked () const |
Returns whether a surface is masked or not. | |
void | set_mask (bool m) |
Sets the mask parameter of the surface. | |
u_int8 | alpha () const |
Returns the alpha value of the surface. | |
void | set_alpha (u_int8 a) |
Sets the alpha value of the surface. | |
bool | is_dbl_mode () const |
void | set_dbl_mode (bool mode) |
Drawing Methods. | |
void | draw (s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const |
Draw the surface. | |
void | draw (s_int16 x, s_int16 y, s_int16 sx, s_int16 sy, u_int16 sl, u_int16 sh, const drawing_area *da_opt=NULL, surface *target=NULL) const |
Draw a part of the surface. | |
void | draw_part (s_int16 x, s_int16 y, s_int16 sx, s_int16 sy, u_int16 sl, u_int16 sh, const drawing_area *da_opt=NULL, surface *target=NULL) const |
Synonym of draw () to guarantee its access from Python. | |
void | fillrect (s_int16 x, s_int16 y, u_int16 l, u_int16 h, u_int32 col, drawing_area *da_opt=NULL) |
Fills an area of the surface with a given color. | |
void | fillrect (s_int16 x, s_int16 y, u_int16 l, u_int16 h, u_int8 r, u_int8 g, u_int8 b, drawing_area *da_opt=NULL) |
Fills an area of the surface with a given color. | |
void | fillrect_rgb (s_int16 x, s_int16 y, u_int16 l, u_int16 h, u_int8 r, u_int8 g, u_int8 b, drawing_area *da_opt=NULL) |
Synonym of fillrect () to guarantee its access from Python. | |
Pixel manipulation Methods. | |
Use these methods to directly and quickly manipulate pixels from a surface. | |
void | lock () const |
Locks the surface. | |
void | unlock () const |
Unlock the surface after you've worked on it's pixels with the get_pix () and put_pix () methods. | |
void | put_pix (u_int16 x, u_int16 y, u_int32 col) |
Puts a pixel of a given color. | |
void | put_pix (u_int16 x, u_int16 y, u_int8 r, u_int8 g, u_int8 b) |
Puts a pixel of a given color. | |
void | put_pix_rgb (u_int16 x, u_int16 y, u_int8 r, u_int8 g, u_int8 b) |
Synonym of put_pix () to guarantee its access from Python. | |
void | get_pix (u_int16 x, u_int16 y, u_int32 &col) const |
Gets a pixel from the surface. | |
void | get_pix (u_int16 x, u_int16 y, u_int8 &r, u_int8 &g, u_int8 &b) const |
Gets a pixel from a surface. | |
void | get_pix_rgb (u_int16 x, u_int16 y, u_int8 r, u_int8 g, u_int8 b) const |
Synonym of get_pix () to guarantee its access from Python. | |
Public Attributes | |
SDL_Surface * | vis |
The actual surface. | |
Protected Member Functions | |
void | resize (u_int16 l, u_int16 h) |
Resize this surface. | |
void | clear () |
Resets the surface to it's initial state, that is totally empty. | |
void | resize_aux (u_int16 l, u_int16 h) |
void | double_size (const surface &src) |
void | half_size (const surface &src) |
void | get_pix_aux (u_int16 x, u_int16 y, u_int32 &col) const |
void | put_pix_aux (u_int16 x, u_int16 y, u_int32 col) |
Protected Attributes | |
bool | changed |
Must be set to true when you change the surface by something else than class surface operations. | |
bool | dbl_mode |
double mode | |
Friends | |
class | screen |
Class where drawables can actually be drawn to.
Another name for a surface could eventually be "pixmap". A surface is nothing more than an array of pixels where drawables can put their image to. This class has only two purposes: to group methods shared by image and screen, and to ensure that every drawing operation can be performed on the screen or on an image.
Every surface has two special parameters:
surface::surface | ( | bool | mode = true | ) |
Default constructor.
The surface will be totally empty, that is (0, 0) sized, no mask, alpha value of 255 (opaque).
Definition at line 183 of file surface.cc.
surface::~surface | ( | ) | [virtual] |
Destructor.
Definition at line 193 of file surface.cc.
bool surface::is_masked | ( | ) | const [inline] |
void surface::set_mask | ( | bool | m | ) |
Sets the mask parameter of the surface.
m | true if the surface should be masked, false otherwise. |
Definition at line 198 of file surface.cc.
u_int8 surface::alpha | ( | ) | const [inline] |
void surface::set_alpha | ( | u_int8 | a | ) |
Sets the alpha value of the surface.
a | The new alpha value for this surface. |
Definition at line 208 of file surface.cc.
void surface::draw | ( | s_int16 | x, |
s_int16 | y, | ||
const drawing_area * | da_opt = NULL , |
||
surface * | target = NULL |
||
) | const [inline, virtual] |
Draw the surface.
x | X position where to draw. |
y | Y position where to draw. |
da_opt | optional drawing_area to use during the drawing operation. |
target | pointer to the surface where to draw the drawable. If NULL, draw on the screen. |
Implements drawable.
void surface::draw | ( | s_int16 | x, |
s_int16 | y, | ||
s_int16 | sx, | ||
s_int16 | sy, | ||
u_int16 | sl, | ||
u_int16 | sh, | ||
const drawing_area * | da_opt = NULL , |
||
surface * | target = NULL |
||
) | const |
Draw a part of the surface.
x | X position where to draw. |
y | Y position where to draw. |
sx | X position where to start drawing from this image. |
sy | Y position where to start drawing from this image. |
sl | length of the part of this image to draw. |
sh | height of the part of this image to draw. |
da_opt | optional drawing_area to use during the drawing operation. |
target | pointer to the surface where to draw the drawable. If NULL, draw on the screen. |
Definition at line 215 of file surface.cc.
void surface::draw_part | ( | s_int16 | x, |
s_int16 | y, | ||
s_int16 | sx, | ||
s_int16 | sy, | ||
u_int16 | sl, | ||
u_int16 | sh, | ||
const drawing_area * | da_opt = NULL , |
||
surface * | target = NULL |
||
) | const [inline] |
void surface::fillrect | ( | s_int16 | x, |
s_int16 | y, | ||
u_int16 | l, | ||
u_int16 | h, | ||
u_int32 | col, | ||
drawing_area * | da_opt = NULL |
||
) |
Fills an area of the surface with a given color.
The color you pass to this function MUST come from a game's function (like surface::get_pix () or screen::trans_col ()), because of the screen depth dependant value of the col argument.
x | X position where to fill. |
y | Y position where to fill. |
l | length of the area to fill. |
h | height of the area to fill. |
col | color to fill the surface with. |
da_opt | optionnal drawing_area to use during the fill operation. |
Definition at line 260 of file surface.cc.
void surface::fillrect | ( | s_int16 | x, |
s_int16 | y, | ||
u_int16 | l, | ||
u_int16 | h, | ||
u_int8 | r, | ||
u_int8 | g, | ||
u_int8 | b, | ||
drawing_area * | da_opt = NULL |
||
) | [inline] |
Fills an area of the surface with a given color.
This function is independant of the screen depth. You just give the red, green and blue triplets of the color you want to fill with.
x | X position where to fill. |
y | Y position where to fill. |
l | length of the area to fill. |
h | height of the area to fill. |
r | red value of the color to fill with. |
g | green value of the color to fill with. |
b | blue value of the color to fill with. |
da_opt | optionnal drawing_area to use during the fill operation. |
void surface::fillrect_rgb | ( | s_int16 | x, |
s_int16 | y, | ||
u_int16 | l, | ||
u_int16 | h, | ||
u_int8 | r, | ||
u_int8 | g, | ||
u_int8 | b, | ||
drawing_area * | da_opt = NULL |
||
) | [inline] |
void surface::lock | ( | ) | const |
Locks the surface.
Sometimes you may want to access directly the pixels of a surface. This can be done with the get_pix () and put_pix () methods, thus you must ABSOLUTELY lock the surface before doing so. This function is made for that. Note that using get_pix () or put_pix () without locking the surface may result in unpredictable behavior, crashes included.
Definition at line 287 of file surface.cc.
void surface::unlock | ( | ) | const |
Unlock the surface after you've worked on it's pixels with the get_pix () and put_pix () methods.
Definition at line 294 of file surface.cc.
void surface::put_pix | ( | u_int16 | x, |
u_int16 | y, | ||
u_int32 | col | ||
) |
Puts a pixel of a given color.
The col parameter is specific to the current screen depth, and must come from a game's function like get_pix or screen::trans_col ().
x | X position of the pixel to change. |
y | Y position of the pixel to change. |
col | color to put. |
Definition at line 301 of file surface.cc.
void surface::put_pix | ( | u_int16 | x, |
u_int16 | y, | ||
u_int8 | r, | ||
u_int8 | g, | ||
u_int8 | b | ||
) | [inline] |
Puts a pixel of a given color.
The r, g and b parameters are the hex triplets of the color to put.
x | X position of the pixel to change. |
y | Y position of the pixel to change. |
r | red value of the color to put. |
g | green value of the color to put. |
b | blue value of the color to put. |
void surface::put_pix_rgb | ( | u_int16 | x, |
u_int16 | y, | ||
u_int8 | r, | ||
u_int8 | g, | ||
u_int8 | b | ||
) | [inline] |
void surface::get_pix | ( | u_int16 | x, |
u_int16 | y, | ||
u_int32 & | col | ||
) | const |
Gets a pixel from the surface.
The col parameter is specific to the current screen depth, and can be used with functions like put_pix ().
x | X position of the pixel to change. |
y | Y position of the pixel to change. |
col | returned color. |
Definition at line 360 of file surface.cc.
void surface::get_pix | ( | u_int16 | x, |
u_int16 | y, | ||
u_int8 & | r, | ||
u_int8 & | g, | ||
u_int8 & | b | ||
) | const [inline] |
Gets a pixel from a surface.
The returned r, g and b values are the hex triplets of the color.
x | X position of the pixel to change. |
y | Y position of the pixel to change. |
r | red value of the color. |
g | green value of the color. |
b | blue value of the color. |
void surface::get_pix_rgb | ( | u_int16 | x, |
u_int16 | y, | ||
u_int8 | r, | ||
u_int8 | g, | ||
u_int8 | b | ||
) | const [inline] |
Surface copy (similar to copy ()).
Definition at line 400 of file surface.cc.
void surface::copy | ( | surface & | src | ) | [inline] |
void surface::resize | ( | u_int16 | l, |
u_int16 | h | ||
) | [protected] |
Resize this surface.
All the content will be lost.
l | new length. |
h | new height. |
Reimplemented in image, and label.
Definition at line 422 of file surface.cc.
void surface::clear | ( | ) | [protected] |
Resets the surface to it's initial state, that is totally empty.
Reimplemented in image.
Definition at line 447 of file surface.cc.
SDL_Surface* surface::vis |
bool surface::changed [mutable, protected] |
bool surface::dbl_mode [protected] |