mp_stickers
Shocking Stickers
StickerSheet Class Reference

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...
 
ImagegetSticker (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...
 

Detailed Description

Represents an arrangement of many sticker that is output as a single Image when the user calls render().

Constructor & Destructor Documentation

◆ StickerSheet()

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.

Parameters
pictureThe base picture to use in the StickerSheet

Member Function Documentation

◆ addSticker()

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.

Parameters
stickerThe Image of the sticker.
xThe x location of the sticker on the StickerSheet
yThe y location of the sticker on the StickerSheet
Returns
The zero-based layer index the sticker was added to.

◆ getSticker()

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.

Parameters
indexThe layer in which to get the sticker.
Returns
A pointer to a specific Image in the StickerSheet

◆ layers()

int StickerSheet::layers ( ) const

Returns the total number of layers available on the Stickersheet.

Returns
The total number of layers

◆ removeSticker()

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.

Parameters
indexThe layer in which to delete the png

◆ render()

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.

Returns
An Image object representing the drawn scene

◆ setStickerAtLayer()

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.

Parameters
stickerThe Image of the sticker.
layerThe layer where the sticker is to be placed.
xThe x location of the sticker on the StickerSheet
yThe y location of the sticker on the StickerSheet
Returns
The zero-based layer index the sticker was added to.

◆ translate()

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.

Parameters
indexZero-based layer index of the sticker.
xThe new x location of the sticker on the StickerSheet
yThe new y location of the sticker on the StickerSheet
Returns
true if the translate was successful; otherwise false.

The documentation for this class was generated from the following file: