tbx  0.7.6
Public Member Functions | List of all members
tbx::ColourPalette Class Reference

A class to hold a list of Colours for the a colour palette. More...

#include <sprite.h>

Public Member Functions

 ColourPalette (int size=0)
 Construct a colour palette of a specified size. More...
 
 ColourPalette (const ColourPalette &other)
 Construct a palette by making a copy of another palette. More...
 
void resize (int new_size)
 Resize the colour palette. More...
 
void desktop_palette ()
 Convert this palette to the current desktop palette.
 
ColourPaletteoperator= (const ColourPalette &other)
 Assign to a copy of another palette. More...
 
bool operator== (const ColourPalette &other)
 Check if two palettes contain all the same colours. More...
 
bool operator!= (const ColourPalette &other)
 Check if two palette have one or more colours different. More...
 
Colouroperator[] (int index)
 Get reference to colour in the palette. More...
 
const Colouroperator[] (int index) const
 Get constant reference to colour in the palette. More...
 
void entry (int index, const Colour &col)
 Set the specified index to the given colour. More...
 
Colour entry (int index) const
 Return the colour for the specified index. More...
 
int size () const
 Return the size of the palette.
 
const Colouraddress () const
 Get a pointer to the array of colours.
 

Detailed Description

A class to hold a list of Colours for the a colour palette.

Typically this is returned from a sprite that has < 32 thousand colours

Constructor & Destructor Documentation

◆ ColourPalette() [1/2]

ColourPalette::ColourPalette ( int  size = 0)

Construct a colour palette of a specified size.

The palette will just consist of black entries

Parameters
sizenumber of colours in the palette

◆ ColourPalette() [2/2]

ColourPalette::ColourPalette ( const ColourPalette other)

Construct a palette by making a copy of another palette.

Parameters
otherpalette to copy

Member Function Documentation

◆ entry() [1/2]

Colour tbx::ColourPalette::entry ( int  index) const
inline

Return the colour for the specified index.

Parameters
indexindex of entry to return palette from (0 to size-1)
Returns
Colour at the given index

◆ entry() [2/2]

void tbx::ColourPalette::entry ( int  index,
const Colour col 
)
inline

Set the specified index to the given colour.

Parameters
indexindex of entry to set palette for (0 to size-1)
colnew colour for the entry

◆ operator!=()

bool ColourPalette::operator!= ( const ColourPalette other)

Check if two palette have one or more colours different.

Parameters
otherpalette to compare to
Returns
true if palettes are different

◆ operator=()

ColourPalette & ColourPalette::operator= ( const ColourPalette other)

Assign to a copy of another palette.

Parameters
otherpalette to copy
Returns
*this

◆ operator==()

bool ColourPalette::operator== ( const ColourPalette other)

Check if two palettes contain all the same colours.

Parameters
otherpalette to compare to
Returns
true if they are the same

◆ operator[]() [1/2]

Colour& tbx::ColourPalette::operator[] ( int  index)
inline

Get reference to colour in the palette.

Parameters
indexindex of entry in the palette (0 to size-1)
Returns
reference to the colour

◆ operator[]() [2/2]

const Colour& tbx::ColourPalette::operator[] ( int  index) const
inline

Get constant reference to colour in the palette.

Parameters
indexindex of entry in the palette (0 to size-1)
Returns
constant reference to the colour

◆ resize()

void ColourPalette::resize ( int  newsize)

Resize the colour palette.

Note: Old colours are not preserved and the palette is reset so all entries are black

Parameters
newsizenew number of colours in the palette

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