Marbellous
Marbellous, a WebApp to generate paper marbling patterns.
Public Member Functions | List of all members
Palette Class Reference

Contains a vector of colors. More...

#include <Palette.hpp>

Collaboration diagram for Palette:
Collaboration graph

Public Member Functions

 Palette ()
 Construct a new Palette object. More...
 
 Palette (size_t colors)
 Construct a new Palette object with colors colors. More...
 
size_t add (Color const col)
 Add a color to the palette. More...
 
size_t getSize () const
 Get the palette's size. More...
 
Coloroperator[] (size_t const index)
 Get or set the color at index. More...
 
const Coloroperator[] (size_t const index) const
 Get the color at index. More...
 
unsigned getRandomColorId () const
 Returns a random color of that pallet based on the ratios. More...
 
void setRatioAt (size_t index, unsigned ratio)
 Set the ratio of the color at index. More...
 
void setColorAt (size_t index, const Color &color)
 set new color and update ratios More...
 
std::vector< Color >::const_iterator begin () const
 
std::vector< Color >::const_iterator end () const
 

Detailed Description

Contains a vector of colors.

Constructor & Destructor Documentation

◆ Palette() [1/2]

Palette::Palette ( )

Construct a new Palette object.

◆ Palette() [2/2]

Palette::Palette ( size_t  colors)

Construct a new Palette object with colors colors.

Parameters
colorsNumber of colors to pre allocate.

Member Function Documentation

◆ add()

size_t Palette::add ( Color const  col)

Add a color to the palette.

Parameters
colColor object to add.
Returns
ID of the color inside the Palette. May be used to modify it later.

◆ begin()

std::vector<Color>::const_iterator Palette::begin ( ) const
inline
Returns
Begin const_iterator over colors

◆ end()

std::vector<Color>::const_iterator Palette::end ( ) const
inline
Returns
End const_iterator over colors

◆ getRandomColorId()

unsigned Palette::getRandomColorId ( ) const

Returns a random color of that pallet based on the ratios.

Returns
ID of a random color.
Here is the caller graph for this function:

◆ getSize()

size_t Palette::getSize ( ) const

Get the palette's size.

Returns
Size of the palette.
Here is the caller graph for this function:

◆ operator[]() [1/2]

Color & Palette::operator[] ( size_t const  index)

Get or set the color at index.

Attention
Might throw std::out_of_range for non existing colors.
Parameters
indexColor to change.
Returns
Reference to the color at index. get or set the color at index, might throw std::out_of_range

◆ operator[]() [2/2]

const Color & Palette::operator[] ( size_t const  index) const

Get the color at index.

Attention
Might throw std::out_of_range for non existing colors.
Parameters
indexColor to get.
Returns
Constant reference to the color at index.

◆ setColorAt()

void Palette::setColorAt ( size_t  index,
const Color color 
)

set new color and update ratios

Here is the caller graph for this function:

◆ setRatioAt()

void Palette::setRatioAt ( size_t  index,
unsigned  ratio 
)

Set the ratio of the color at index.

Parameters
indexID of color to change the ratio for.
ratioNew ratio. updates a ratio
Here is the caller graph for this function:

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