Euphoria
eu::core::Palette Struct Reference

#include <palette.h>

Public Member Functions

constexpr Palette (const std::string_view &n, const ranges::span< const Rgbi > &c)
 
const Rgbiget_random_color (Random *r) const
 Get a random color. More...
 
const Rgbiget_safe_index (unsigned int i) const
 Get a color based on the index. More...
 
const Rgbiget_closest_color (const Rgbi &c) const
 
int get_index_closest (const Rgbi &c) const
 

Public Attributes

std::string_view name
 the name of the palette More...
 
ranges::span< const Rgbicolors
 

Detailed Description

Definition at line 18 of file palette.h.

Constructor & Destructor Documentation

◆ Palette()

constexpr eu::core::Palette::Palette ( const std::string_view &  n,
const ranges::span< const Rgbi > &  c 
)
inlineconstexpr

Definition at line 27 of file palette.h.

Member Function Documentation

◆ get_closest_color()

const Rgbi & eu::core::Palette::get_closest_color ( const Rgbi c) const

Definition at line 39 of file palette.cc.

◆ get_index_closest()

int eu::core::Palette::get_index_closest ( const Rgbi c) const

Definition at line 46 of file palette.cc.

◆ get_random_color()

const Rgbi & eu::core::Palette::get_random_color ( Random r) const

Get a random color.

Parameters
rthe random generator to use
Returns
a random color

Definition at line 25 of file palette.cc.

◆ get_safe_index()

const Rgbi & eu::core::Palette::get_safe_index ( unsigned int  i) const

Get a color based on the index.

The index is modulated based on the palette size, ensuring a valid color.

Parameters
ithe index
Returns
the color

Definition at line 32 of file palette.cc.

Member Data Documentation

◆ colors

ranges::span<const Rgbi> eu::core::Palette::colors

Definition at line 25 of file palette.h.

◆ name

std::string_view eu::core::Palette::name

the name of the palette

Definition at line 23 of file palette.h.


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