Porytiles
Loading...
Searching...
No Matches
porytiles2::Palette< ColorType > Class Template Reference

A palette container for colors that support transparency checking. More...

#include <palette.hpp>

Public Member Functions

 Palette ()=default
 
 Palette (ColorType color)
 Constructs a palette filled with a single color.
 
void add (ColorType color)
 Adds a color to the end of the palette.
 
void set (ColorType color, std::size_t index)
 Sets the color at a specific index in the palette.
 
std::size_t size () const
 Returns the number of colors in the palette.
 
const std::vector< ColorType > & colors () const
 Returns a const reference to the internal color vector.
 

Detailed Description

template<SupportsTransparency ColorType>
class porytiles2::Palette< ColorType >

A palette container for colors that support transparency checking.

Palette is a simple vector-backed container for storing colors that satisfy the SupportsTransparency concept. It provides basic operations for adding, setting, and accessing colors in the palette. The palette has no hard size limit, but is typically used with palettes of size 16 (the GBA standard palette size).

The ColorType template parameter must satisfy the SupportsTransparency concept, meaning it must provide methods for checking whether a color is transparent.

Template Parameters
ColorTypeThe color type of this palette must satisfy the SupportsTransparency concept

Definition at line 34 of file palette.hpp.

Constructor & Destructor Documentation

◆ Palette() [1/2]

template<SupportsTransparency ColorType>
porytiles2::Palette< ColorType >::Palette ( )
default

◆ Palette() [2/2]

template<SupportsTransparency ColorType>
porytiles2::Palette< ColorType >::Palette ( ColorType  color)
inlineexplicit

Constructs a palette filled with a single color.

Creates a palette containing 16 copies of the provided color. This is useful for creating uniform palettes or placeholder palettes.

Parameters
colorThe color to fill the palette with

Definition at line 47 of file palette.hpp.

Member Function Documentation

◆ add()

template<SupportsTransparency ColorType>
void porytiles2::Palette< ColorType >::add ( ColorType  color)
inline

Adds a color to the end of the palette.

Appends the provided color to the palette's internal color vector.

Parameters
colorThe color to add

Definition at line 62 of file palette.hpp.

◆ colors()

template<SupportsTransparency ColorType>
const std::vector< ColorType > & porytiles2::Palette< ColorType >::colors ( ) const
inline

Returns a const reference to the internal color vector.

Returns
Const reference to the vector of colors

Definition at line 99 of file palette.hpp.

◆ set()

template<SupportsTransparency ColorType>
void porytiles2::Palette< ColorType >::set ( ColorType  color,
std::size_t  index 
)
inline

Sets the color at a specific index in the palette.

Replaces the color at the given index with the provided color. Panics if the index is out of bounds.

Parameters
colorThe color to set
indexThe index at which to set the color

Definition at line 76 of file palette.hpp.

◆ size()

template<SupportsTransparency ColorType>
std::size_t porytiles2::Palette< ColorType >::size ( ) const
inline

Returns the number of colors in the palette.

Returns
The size of the palette

Definition at line 89 of file palette.hpp.


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