libvisual  0.5.0
Public Member Functions | Public Attributes | List of all members
LV::Palette Struct Reference

Colour palette class for indexed colour modes. More...

#include <libvisual/lv_palette.h>

Collaboration diagram for LV::Palette:
Collaboration graph
[legend]

Public Member Functions

 Palette ()=default
 Creates a new Palette object.
 
 Palette (unsigned int ncolors)
 
 Palette (Palette const &)=default
 
 Palette (Palette &&palette)
 
Paletteoperator= (Palette const &rhs)=default
 
Paletteoperator= (Palette &&rhs)
 
bool empty () const
 
unsigned int size () const
 
void blend (Palette const &src1, Palette const &src2, float rate)
 This function is capable of morphing from one palette to another. More...
 
void allocate_colors (unsigned int size)
 Allocate an amount of colors for a VisPalette. More...
 
Color color_cycle (float rate)
 Can be used to cycle through the colors of a VisPalette and blend between elements. More...
 
int find_color (Color const &color) const
 

Public Attributes

std::vector< Colorcolors
 

Detailed Description

Colour palette class for indexed colour modes.

Note
This is currently only used for 8-bit images

Definition at line 46 of file lv_palette.h.

Member Function Documentation

void LV::Palette::allocate_colors ( unsigned int  size)

Allocate an amount of colors for a VisPalette.

Parameters
sizeNumber of colors to allocate

Definition at line 41 of file lv_palette.cpp.

void LV::Palette::blend ( Palette const &  src1,
Palette const &  src2,
float  rate 
)

This function is capable of morphing from one palette to another.

Parameters
src1Pointer to a VisPalette that acts as the first source for the morph.
src2Pointer to a VisPalette that acts as the second source for the morph.
rateValue that sets the rate of the morph, which is valid between 0 and 1.

Definition at line 46 of file lv_palette.cpp.

VisColor LV::Palette::color_cycle ( float  rate)

Can be used to cycle through the colors of a VisPalette and blend between elements.

The rate is from 0.0 to number of VisColors in the VisPalette. The VisColor is newly allocated so you have to unref it. The last VisColor in the VisPalette is morphed with the first.

Parameters
rateSelection of the VisColor from the VisPalette, goes from 0.0 to number of VisColors in the VisPalette and morphs between colors if needed.
Returns
A new Color, possibly a morph between two Colors

Definition at line 58 of file lv_palette.cpp.


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