tbx
0.7.3
|
Sprite from a user sprite area. More...
#include <sprite.h>
Public Member Functions | |
UserSprite () | |
Construct an unassigned sprite. More... | |
UserSprite (SpriteArea *area, const std::string &name) | |
Construct a user sprite from a sprite area and name. More... | |
virtual | ~UserSprite () |
Destructor - not this does not delete the sprite from the sprite area as this class is just a reference to the sprite. | |
bool | operator== (const UserSprite &other) const |
Check if two sprite classes refer to the same underlying sprite. | |
bool | operator!= (const UserSprite &other) const |
Check if two sprite classes DO NOT refer to the same underlying sprite. | |
bool | is_valid () const |
Check this sprite object is valid. | |
bool | rename (const std::string &name) |
Renames the sprite. More... | |
virtual void | plot_raw (const Point &pos, int code=SPA_USE_MASK) const |
Plot this sprite at the given position with no scaling or colour conversions. | |
virtual void | plot_scaled (const Point &pos, const ScaleFactors *sf, const TranslationTable *tt=0, int code=SPA_USE_MASK) const |
Plot this sprite scaled using the given colour translation. More... | |
virtual void | plot_screen (const Point &pos, int code=SPA_USE_MASK) const |
Plot sprite to screen. More... | |
virtual void | plot_raw (int x, int y, int code=SPA_USE_MASK) const |
Plot this sprite at the given position with no scaling or colour conversions. | |
virtual void | plot_scaled (int x, int y, const ScaleFactors *sf, const TranslationTable *tt=0, int code=SPA_USE_MASK) const |
Plot this sprite scaled using the given colour translation. More... | |
virtual void | plot_screen (int x, int y, int code=SPA_USE_MASK) const |
Plot sprite to screen. More... | |
virtual std::string | name () const |
Get the name of the sprite. More... | |
virtual bool | info (Size *pixel_size, int *mode=NULL, bool *mask=NULL) const |
Get information about the sprite. More... | |
bool | get_palette (ColourPalette &pal) const |
Get palette (non-flashing colours only) for this sprite. More... | |
bool | set_palette (ColourPalette &pal) |
Set the sprites palette. More... | |
bool | create_palette (bool col256=false) |
Create a palette for a sprite. More... | |
bool | create_palette (ColourPalette &pal) |
Create a palette for a sprite. More... | |
bool | remove_palette () |
Remove palette from a sprite. | |
bool | create_mask () |
Create a mask for the sprite. More... | |
bool | remove_mask () |
Remove sprite mask. More... | |
int | pixel (int x, int y) const |
Get pixel at given location. More... | |
void | pixel (int x, int y, int gcol) |
Set pixel at given location. More... | |
void | pixel (int x, int y, int gcol, int tint) |
Set pixel at given location. More... | |
int | pixel (int x, int y, int *tint) const |
Get pixel at given location. More... | |
bool | mask_pixel (int x, int y) const |
Check is mask pixel is set at given location. More... | |
void | mask_pixel (int x, int y, bool on) |
Set or clear mask pixel is at given location. More... | |
SpriteArea * | get_sprite_area () const |
Return SpriteArea this sprite is from. | |
int | offset () const |
Return offset of this sprite in the sprite area. | |
OsSpritePtr | pointer () const |
Return pointer to underlying RISC OS sprite. | |
virtual int | area_id () const |
Return sprite area id used for calls that take an area pointer or a special value for WIMP/System areas. | |
bool | has_palette () const |
Returns true if this sprite has a palette. | |
virtual void | get_wimp_scale (ScaleFactors &factor) const |
Get the scale factors required to plot this sprite in the WIMP as its logical size. More... | |
![]() | |
virtual void | plot (int x, int y) const |
Plot sprite to screen. More... | |
virtual void | plot (const Point &pos) const |
Plot sprite to screen. More... | |
Size | size () const |
Return the size of the sprite. More... | |
int | width () const |
Return the width of the sprite. More... | |
int | height () const |
Return the height of the sprite. More... | |
Size | pixel_size () const |
Get size of the sprite in pixels. More... | |
int | mode () const |
Get the mode of the sprite. More... | |
bool | has_mask () const |
Check if the sprite has a mask. More... | |
Protected Member Functions | |
UserSprite (SpriteArea *area, int offset) | |
Private constructor used by sprite area to return a sprite. | |
Protected Attributes | |
SpriteArea * | _area |
Sprite area containing this sprite. | |
int | _offset |
offset of sprite within the sprite area | |
Friends | |
class | SpriteArea |
Sprite from a user sprite area.
A sprite reference is returned using the SpriteArea::get_sprite method.
A runtime error or crash will occur is you try to use a sprite after the SpriteArea it was retrieved from has been deleted.
UserSprite::UserSprite | ( | ) |
Construct an unassigned sprite.
UserSprite::UserSprite | ( | SpriteArea * | area, |
const std::string & | name | ||
) |
Construct a user sprite from a sprite area and name.
SpriteException | if name is not in the sprite area. |
bool UserSprite::create_mask | ( | ) |
Create a mask for the sprite.
The mask is created all solid
bool UserSprite::create_palette | ( | bool | col256 = false | ) |
Create a palette for a sprite.
Will only create a palette if one doesn't already exist
col256 | - use full 256 colour palette for 256 colour sprites |
bool UserSprite::create_palette | ( | ColourPalette & | pal | ) |
Create a palette for a sprite.
Will only create a palette if one doesn't already exist
pal | initial palette required |
bool UserSprite::get_palette | ( | ColourPalette & | pal | ) | const |
Get palette (non-flashing colours only) for this sprite.
pal | palette to copy entries to |
|
virtual |
Get the scale factors required to plot this sprite in the WIMP as its logical size.
factor | scale factors updated with the correct value |
Implements tbx::Sprite.
|
virtual |
Get information about the sprite.
pixel_size | pointer to Size to be updated with size of sprite in pixels |
mode | pointer to integer to receive the sprite mode number or 0 (the default) not to return the mode |
mask | pointer to a boolean which will be set to true if the sprite has a mask or 0 (the default) not to return the mask |
Implements tbx::Sprite.
bool UserSprite::mask_pixel | ( | int | x, |
int | y | ||
) | const |
Check is mask pixel is set at given location.
x | x coordinate to get the mask pixel for in pixels |
y | y coordinate to get the mask pixel for in pixels |
OSError | failed to retrieve mask pixel |
void UserSprite::mask_pixel | ( | int | x, |
int | y, | ||
bool | on | ||
) |
Set or clear mask pixel is at given location.
x | x coordinate to set the mask pixel for in pixels |
y | y coordinate to set the mask pixel for in pixels |
on | true to set the mask pixel, false to unset it |
OSError | failed to set mask pixel |
|
virtual |
int UserSprite::pixel | ( | int | x, |
int | y | ||
) | const |
Get pixel at given location.
The returned pixel colour is from 0 to number of colours in the sprite -1. For a 256 colour sprite this will only return 0-63, for full colour information use pixel(x,y,&tint) to return the tint information as well.
x | x coordinate to get the pixel for in pixels |
y | y coordinate to get the pixel for in pixels |
OSError | failed to retrieve pixel |
void UserSprite::pixel | ( | int | x, |
int | y, | ||
int | gcol | ||
) |
Set pixel at given location.
For a 256 colour sprite the gcol parameter is 0-63, and the tint is set to 0, use pixel(x,y,gcol, tint) to set the tint information as well.
x | x coordinate to set the pixel for in pixels |
y | y coordinate to set the pixel for in pixels |
gcol | pixel value to set from 0 to number colours in sprite-1 |
OSError | failed to set pixel |
void UserSprite::pixel | ( | int | x, |
int | y, | ||
int | gcol, | ||
int | tint | ||
) |
Set pixel at given location.
For a 256 colour sprite the gcol parameter is 0-63 and the tint is also used.
x | x coordinate to set the pixel for in pixels |
y | y coordinate to set the pixel for in pixels |
gcol | pixel value to set from 0 to number colours in sprite-1 |
tint | value to of tint (0, 64, 128 or 192 in 256 colour modes, ignored in all other modes) |
OSError | failed to set pixel |
int UserSprite::pixel | ( | int | x, |
int | y, | ||
int * | tint | ||
) | const |
Get pixel at given location.
The returned pixel colour is from 0 to number of colours in the sprite -1. For a 256 colour sprite this will only return 0-63, and the tint of the colour is return in tint
x | x coordinate to get the pixel for in pixels |
y | y coordinate to get the pixel for in pixels |
tint | value to receive tint (0, 64, 128 or 192 in 256 colour modes, 0 in all other modes) |
OSError | failed to retrieve pixel |
|
virtual |
Plot this sprite scaled using the given colour translation.
Implements tbx::Sprite.
|
virtual |
Plot this sprite scaled using the given colour translation.
Implements tbx::Sprite.
|
virtual |
Plot sprite to screen.
Calculates the translation table and scale factors for the current screen and plots the sprite
Implements tbx::Sprite.
|
virtual |
Plot sprite to screen.
Calculates the translation table and scale factors for the current screen and plots the sprite
Implements tbx::Sprite.
bool UserSprite::remove_mask | ( | ) |
Remove sprite mask.
bool UserSprite::rename | ( | const std::string & | name | ) |
Renames the sprite.
Returns true if successful
bool UserSprite::set_palette | ( | ColourPalette & | pal | ) |
Set the sprites palette.
Note: Does not create a palette if there it not already one
pal | new value for palette |