ClanLib
2.3.7
|
This class contains everything to construct a sprite - its data, default settings etc. More...
#include <sprite_description.h>
Public Member Functions | |
Construction | |
CL_SpriteDescription () | |
Constructs a sprite description. More... | |
CL_SpriteDescription (CL_GraphicContext &gc, const CL_StringRef &resource_id, CL_ResourceManager *resources, const CL_ImageImportDescription &import_desc=CL_ImageImportDescription()) | |
Constructs a SpriteDescription. More... | |
CL_SpriteDescription (const CL_SpriteDescription ©) | |
Constructs a SpriteDescription. More... | |
~CL_SpriteDescription () | |
Attributes | |
const std::vector < CL_SpriteDescriptionFrame > & | get_frames () const |
Returns a list over all available frames. More... | |
Operations | |
CL_SpriteDescription & | operator= (const CL_SpriteDescription ©) |
Copy assignment operator. More... | |
void | add_frame (const CL_PixelBuffer &pixelbuffer) |
Adds a single image. More... | |
void | add_frame (const CL_Texture &texture) |
Add frame. More... | |
void | add_frame (const CL_StringRef &fullname, const CL_ImageImportDescription &import_desc=CL_ImageImportDescription()) |
Add frame. More... | |
void | add_frame (CL_IODevice &file, const CL_String &image_type, const CL_ImageImportDescription &import_desc=CL_ImageImportDescription()) |
Add frame. More... | |
void | add_frame (const CL_StringRef &filename, CL_VirtualDirectory &dir, const CL_ImageImportDescription &import_desc=CL_ImageImportDescription()) |
Add frame. More... | |
void | add_frames (const CL_Texture &texture, CL_Rect *frames, int num_frames) |
Add frames. More... | |
void | add_gridclipped_frames (const CL_PixelBuffer &pixelbuffer, int xpos, int ypos, int width, int height, int xarray=1, int yarray=1, int array_skipframes=0, int xspacing=0, int yspacing=0) |
Adds images formed in a grid. More... | |
void | add_gridclipped_frames (const CL_Texture &texture, int xpos, int ypos, int width, int height, int xarray=1, int yarray=1, int array_skipframes=0, int xspacing=0, int yspacing=0) |
void | add_alphaclipped_frames (const CL_PixelBuffer &pixelbuffer, int xpos=0, int ypos=0, double trans_limit=0.05f) |
Adds images separated with pure alpha (within trans_limit). More... | |
void | add_alphaclipped_frames (const CL_Texture &texture, int xpos=0, int ypos=0, double trans_limit=0.05f) |
void | add_alphaclipped_frames_free (const CL_PixelBuffer &pixelbuffer, int xpos=0, int ypos=0, double trans_limit=0.05f) |
Adds images separated with pure alpha (within trans_limit). More... | |
void | add_alphaclipped_frames_free (const CL_Texture &texture, int xpos=0, int ypos=0, double trans_limit=0.05f) |
void | set_frame_delay (int frame, double delay) |
Sets the duration this frame is displayed, in seconds. More... | |
This class contains everything to construct a sprite - its data, default settings etc.
CL_SpriteDescription is used by CL_Sprite to construct itself based on the description. The description class give a big flexibility creating a sprite, individual frames can come from different image sources, or be cut out from an image source using various different techniques.
CL_SpriteDescription::CL_SpriteDescription | ( | ) |
Constructs a sprite description.
resource_id | Resource name of a sprite description resource. |
resources | Resource manager used to load resource. |
CL_SpriteDescription::CL_SpriteDescription | ( | CL_GraphicContext & | gc, |
const CL_StringRef & | resource_id, | ||
CL_ResourceManager * | resources, | ||
const CL_ImageImportDescription & | import_desc = CL_ImageImportDescription() |
||
) |
Constructs a SpriteDescription.
gc | = Graphic Context |
resource_id | = String Ref |
resources | = Resource Manager |
CL_SpriteDescription::CL_SpriteDescription | ( | const CL_SpriteDescription & | copy) |
Constructs a SpriteDescription.
copy | = Sprite Description |
CL_SpriteDescription::~CL_SpriteDescription | ( | ) |
void CL_SpriteDescription::add_alphaclipped_frames | ( | const CL_PixelBuffer & | pixelbuffer, |
int | xpos = 0 , |
||
int | ypos = 0 , |
||
double | trans_limit = 0.05f |
||
) |
Adds images separated with pure alpha (within trans_limit).
The alpha clipper will cut out frames from an image based on the transparency in the picture. It first determines the height of a row by searching for the first line that it considers completely transparent. Then it finds the width of each frame on this line by looking for columns that are completely transparency.
pixelbuffer | Image source. |
texture | Image source. |
xpos,ypos | Upper left position where alpha cutting should begin. |
trans_limit | Amount of non-transparent alpha allowed before a pixel is not considered transparent. |
void CL_SpriteDescription::add_alphaclipped_frames | ( | const CL_Texture & | texture, |
int | xpos = 0 , |
||
int | ypos = 0 , |
||
double | trans_limit = 0.05f |
||
) |
void CL_SpriteDescription::add_alphaclipped_frames_free | ( | const CL_PixelBuffer & | pixelbuffer, |
int | xpos = 0 , |
||
int | ypos = 0 , |
||
double | trans_limit = 0.05f |
||
) |
Adds images separated with pure alpha (within trans_limit).
The alpha clipper will cut out frames from an image based on the transparency in the picture. It scans the lines horizontally from top to bottom. As soon as a non-transarent pixel is discovered, the clipper finds the bounding box for that region and then moves on.
pixelbuffer | Image source. |
texture | Image source. |
xpos,ypos | Upper left position where alpha cutting should begin. |
trans_limit | Amount of non-transparent alpha allowed before a pixel is not considered transparent. |
void CL_SpriteDescription::add_alphaclipped_frames_free | ( | const CL_Texture & | texture, |
int | xpos = 0 , |
||
int | ypos = 0 , |
||
double | trans_limit = 0.05f |
||
) |
void CL_SpriteDescription::add_frame | ( | const CL_PixelBuffer & | pixelbuffer) |
Adds a single image.
pixelbuffer | Image source. |
filename | Filename of image. |
vfs | Virtual File System to load image from. |
void CL_SpriteDescription::add_frame | ( | const CL_Texture & | texture) |
Add frame.
texture | = Texture |
void CL_SpriteDescription::add_frame | ( | const CL_StringRef & | fullname, |
const CL_ImageImportDescription & | import_desc = CL_ImageImportDescription() |
||
) |
Add frame.
fullname | = String Ref |
void CL_SpriteDescription::add_frame | ( | CL_IODevice & | file, |
const CL_String & | image_type, | ||
const CL_ImageImportDescription & | import_desc = CL_ImageImportDescription() |
||
) |
Add frame.
file | = IODevice |
image_type | = String |
void CL_SpriteDescription::add_frame | ( | const CL_StringRef & | filename, |
CL_VirtualDirectory & | dir, | ||
const CL_ImageImportDescription & | import_desc = CL_ImageImportDescription() |
||
) |
Add frame.
filename | = String Ref |
dir | = Virtual Directory |
void CL_SpriteDescription::add_frames | ( | const CL_Texture & | texture, |
CL_Rect * | frames, | ||
int | num_frames | ||
) |
Add frames.
texture | = Texture |
frames | = Rect |
num_frames | = value |
void CL_SpriteDescription::add_gridclipped_frames | ( | const CL_PixelBuffer & | pixelbuffer, |
int | xpos, | ||
int | ypos, | ||
int | width, | ||
int | height, | ||
int | xarray = 1 , |
||
int | yarray = 1 , |
||
int | array_skipframes = 0 , |
||
int | xspacing = 0 , |
||
int | yspacing = 0 |
||
) |
Adds images formed in a grid.
This function will cut out a grid of frames from one image.
pixelbuffer | Image source. |
texture | Image source. |
xpos,ypos | Position of where image grid starts. |
width,height | Size of a frame in the grid. |
xarray,yarray | Number of columns and rows in grid. |
array_skipframes | Number of frames to skip at last gridline. |
xspacing,yspacing | Pixel interspacing between grid frames. |
void CL_SpriteDescription::add_gridclipped_frames | ( | const CL_Texture & | texture, |
int | xpos, | ||
int | ypos, | ||
int | width, | ||
int | height, | ||
int | xarray = 1 , |
||
int | yarray = 1 , |
||
int | array_skipframes = 0 , |
||
int | xspacing = 0 , |
||
int | yspacing = 0 |
||
) |
const std::vector<CL_SpriteDescriptionFrame>& CL_SpriteDescription::get_frames | ( | ) | const |
Returns a list over all available frames.
CL_SpriteDescription& CL_SpriteDescription::operator= | ( | const CL_SpriteDescription & | copy) |
Copy assignment operator.
void CL_SpriteDescription::set_frame_delay | ( | int | frame, |
double | delay | ||
) |
Sets the duration this frame is displayed, in seconds.