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


Public Member Functions | |
| surface (const u_int8 &scale=1) | |
| Default constructor. More... | |
| virtual | ~surface () |
| Destructor. 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, const bool &alpha_channel=false) |
| Sets the alpha value of the surface. More... | |
| bool | has_alpha_channel () const |
| Returns whether the surface has an alpha channel. More... | |
| u_int8 | scale () const |
| Get the surfaces current scaling factor. More... | |
| void | set_scale (const u_int8 &scale) |
| Change the scale of the surface to the given value, resizing the internal texture appropriately. More... | |
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... | |
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... | |
Pixel manipulation Methods. | |
Use these methods to directly and quickly manipulate pixels from a surface. | |
| SDL_Texture * | Surface |
| the surface More... | |
| u_int8 | scale_ |
| current scale More... | |
| s_int16 | offset_x_ |
| sub-pixel offset More... | |
| class | screen |
| u_int32 | map_color (const u_int8 &r, const u_int8 &g, const u_int8 &b, const u_int8 &a=255) const |
| void | unmap_color (u_int32 col, u_int8 &r, u_int8 &g, u_int8 &b, u_int8 &a) const |
| 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... | |
| u_int32 | get_pix (u_int16 x, u_int16 y) 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... | |
| surface & | operator= (const surface &src) |
| Surface copy (similar to copy ()). More... | |
| void | copy (const surface &src) |
| Synonym of operator = to guarantee its access from Python. More... | |
| 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 | set_data (void *data, u_int16 l, u_int16 h, u_int8 bytes_per_pixel=BYTES_PER_PIXEL, u_int32 red_mask=R_MASK, u_int32 green_mask=G_MASK, u_int32 blue_mask=B_MASK, u_int32 alpha_mask=0) |
| void * | get_data (u_int8 bytes_per_pixel, u_int32 red_mask, u_int32 green_mask, u_int32 blue_mask, u_int32 alpha_mask) const |
| SDL_Surface * | to_sw_surface (SDL_Rect *rect=NULL) const |
| Create a software surface backed by the (streaming) texture data. More... | |
| void | lock (SDL_Rect *rect) const |
| lock part of the surface specified by rect More... | |
Additional Inherited Members | |
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... | |
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 | ( | const u_int8 & | scale = 1 | ) |
Default constructor.
The surface will be totally empty, that is (0, 0) sized, no mask, alpha value of 255 (opaque).
Definition at line 41 of file surface.cc.
|
virtual |
Destructor.
Definition at line 53 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 59 of file surface.cc.
|
inline |
| void surface::set_alpha | ( | u_int8 | a, |
| const bool & | alpha_channel = false |
||
| ) |
Sets the alpha value of the surface.
If alpha_channel is set to true, then the surface_alpha value will be silently ignored. Needs to be called before surface::resize to take effect.
| surface_alpha | The new alpha value for this surface. |
| alpha_channel | Whether to enable per-pixel alpha for the surface. |
Definition at line 106 of file surface.cc.
|
inline |
|
inline |
| void surface::set_scale | ( | const u_int8 & | scale | ) |
Change the scale of the surface to the given value, resizing the internal texture appropriately.
| scale | the new scale to set. |
Definition at line 515 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 158 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 239 of file surface.cc.
|
inline |
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.
| 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 336 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 347 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. @returnl returned color. |
Definition at line 441 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 587 of file surface.cc.
|
inline |
Resize this surface.
All the content will be lost.
| l | new length. |
| h | new height. |
Definition at line 631 of file surface.cc.
|
protected |
Resets the surface to it's initial state, that is totally empty.
Definition at line 665 of file surface.cc.
|
protected |
Create a software surface backed by the (streaming) texture data.
Definition at line 123 of file surface.cc.
|
protected |
lock part of the surface specified by rect
Definition at line 325 of file surface.cc.