|
Adonthell
0.4
|
Class where drawables can actually be drawn to. More...
#include <surface.h>


Public Member Functions | |
| surface (bool mode=true) | |
| Default constructor. More... | |
| virtual | ~surface () |
| Destructor. More... | |
| surface & | operator= (surface &src) |
| Surface copy (similar to copy ()). More... | |
| void | copy (surface &src) |
| Synonym of operator = to guarantee its access from Python. More... | |
Settings. | |
These methods sets the parameters of the surface. | |
| bool | is_masked () const |
| Returns whether a surface is masked or not. More... | |
| void | set_mask (bool m) |
| Sets the mask parameter of the surface. More... | |
| u_int8 | alpha () const |
| Returns the alpha value of the surface. More... | |
| void | set_alpha (u_int8 a) |
| Sets the alpha value of the surface. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
Pixel manipulation Methods. | |
Use these methods to directly and quickly manipulate pixels from a surface. | |
| void | lock () const |
| Locks the surface. More... | |
| void | unlock () const |
| Unlock the surface after you've worked on it's pixels with the get_pix () and put_pix () methods. More... | |
| void | put_pix (u_int16 x, u_int16 y, u_int32 col) |
| Puts a pixel of a given color. More... | |
| 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. More... | |
| 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. More... | |
| void | get_pix (u_int16 x, u_int16 y, u_int32 &col) const |
| Gets a pixel from the surface. More... | |
| 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. More... | |
| 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. More... | |
Public Member Functions inherited from drawable | |
| drawable () | |
| Default constructor. More... | |
| virtual | ~drawable () |
| Destructor. More... | |
| u_int16 | length () const |
| Returns the length of the drawable. More... | |
| u_int16 | height () const |
| Returns the height of the drawable. More... | |
| virtual bool | update () |
| Virtual update function, provided for objects which doesn't need one. More... | |
| virtual bool | input_update () |
| Virtual input update function, provided for objects which doesn't need one. More... | |
Public Attributes | |
| SDL_Surface * | vis |
| The actual surface. More... | |
Protected Member Functions | |
| void | resize (u_int16 l, u_int16 h) |
| Resize this surface. More... | |
| void | clear () |
| Resets the surface to it's initial state, that is totally empty. More... | |
| 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 Member Functions inherited from drawable | |
| void | set_length (u_int16 l) |
| Sets the length of the drawable. More... | |
| void | set_height (u_int16 h) |
| Sets the height of the drawable. More... | |
Protected Attributes | |
| bool | changed |
| Must be set to true when you change the surface by something else than class surface operations. More... | |
| bool | dbl_mode |
| double mode More... | |
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.
|
virtual |
Destructor.
Definition at line 193 of file surface.cc.
|
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.
|
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.
|
inlinevirtual |
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::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.
|
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::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.
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.
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. |
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.
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. |
Surface copy (similar to copy ()).
Definition at line 400 of file surface.cc.
|
inline |
Resize this surface.
All the content will be lost.
| l | new length. |
| h | new height. |
Definition at line 422 of file surface.cc.
|
protected |
Resets the surface to it's initial state, that is totally empty.
Definition at line 447 of file surface.cc.
|
mutableprotected |