mp_stickers
Shocking Stickers
|
Represents an arrangement of many sticker that is output as a single Image when the user calls render(). More...
#include <StickerSheet.h>
Public Member Functions | |
StickerSheet (const Image &picture) | |
Add any constructors/destructors you may need based on your class design for StickerSheet. More... | |
int | addSticker (Image &sticker, int x, int y) |
Adds a sticker to the StickerSheet, so that the top-left of the sticker's Image is at (x, y) on the StickerSheet. More... | |
int | setStickerAtLayer (Image &sticker, unsigned layer, int x, int y) |
Adds a sticker to the StickerSheet at layer layer , so that the top-left of the sticker's Image is at (x, y) on the StickerSheet. More... | |
bool | translate (unsigned index, int x, int y) |
Changes the x and y coordinates of the Image in the specified layer. More... | |
void | removeSticker (unsigned index) |
Removes the sticker at the given zero-based layer index. More... | |
Image * | getSticker (unsigned index) |
Returns a pointer to the sticker at the specified index, not a copy of it. More... | |
int | layers () const |
Returns the total number of layers available on the Stickersheet. More... | |
Image | render () const |
Renders the whole StickerSheet on one Image and returns that Image. More... | |
Represents an arrangement of many sticker that is output as a single Image when the user calls render().
StickerSheet::StickerSheet | ( | const Image & | picture | ) |
Add any constructors/destructors you may need based on your class design for StickerSheet.
Initializes this StickerSheet with a deep copy of the base picture.
picture | The base picture to use in the StickerSheet |
int StickerSheet::addSticker | ( | Image & | sticker, |
int | x, | ||
int | y | ||
) |
Adds a sticker
to the StickerSheet, so that the top-left of the sticker's Image
is at (x, y)
on the StickerSheet.
The sticker must be added to the lowest possible layer available.
If all available layers have been filled, a new layer must be added above all existing layers.
sticker | The Image of the sticker. |
x | The x location of the sticker on the StickerSheet |
y | The y location of the sticker on the StickerSheet |
Image * StickerSheet::getSticker | ( | unsigned | index | ) |
Returns a pointer to the sticker at the specified index, not a copy of it.
That way, the user can modify the Image.
If the index is invalid, return NULL.
index | The layer in which to get the sticker. |
int StickerSheet::layers | ( | ) | const |
Returns the total number of layers available on the Stickersheet.
void StickerSheet::removeSticker | ( | unsigned | index | ) |
Removes the sticker at the given zero-based layer index.
Make sure that the other stickers don't change order.
index | The layer in which to delete the png |
Image StickerSheet::render | ( | ) | const |
Renders the whole StickerSheet on one Image and returns that Image.
The base picture is drawn first and then each sticker is drawn in order starting with layer zero (0), then layer one (1), and so on.
If a pixel's alpha channel in a sticker is zero (0), no pixel is drawn for that sticker at that pixel. If the alpha channel is non-zero, a pixel is drawn. (Alpha blending is awesome, but not required.)
The returned image always includes the full contents of the picture and all stickers. It should expand in each corresponding direction if stickers go beyond the edge of the picture.
int StickerSheet::setStickerAtLayer | ( | Image & | sticker, |
unsigned | layer, | ||
int | x, | ||
int | y | ||
) |
Adds a sticker
to the StickerSheet at layer layer
, so that the top-left of the sticker's Image
is at (x, y)
on the StickerSheet.
If there is already a sticker at layer
it should be replaced and if layer
is beyond the top of the existing layers, add a new layer on top.
sticker | The Image of the sticker. |
layer | The layer where the sticker is to be placed. |
x | The x location of the sticker on the StickerSheet |
y | The y location of the sticker on the StickerSheet |
bool StickerSheet::translate | ( | unsigned | index, |
int | x, | ||
int | y | ||
) |
Changes the x and y coordinates of the Image in the specified layer.
If the layer is invalid or does not contain a sticker, this function must return false. Otherwise, this function returns true.
index | Zero-based layer index of the sticker. |
x | The new x location of the sticker on the StickerSheet |
y | The new y location of the sticker on the StickerSheet |
true
if the translate was successful; otherwise false
.