Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
ColorPalette Class Reference

Centralized color palette for teams and entity materials. More...

#include <ColorPalette.hpp>

+ Collaboration diagram for ColorPalette:

Classes

struct  SlimePalette
 

Static Public Member Functions

static Color getTeamColor (int index)
 Returns a unique color for a team based on its index. Will repeat if more teams than palette size.
 
static Color getResourceColor (int resourceIndex)
 Returns the designated UI/3D color for a given resource index.
 
static SlimePalette getSlimePalette (Color teamColor)
 Returns a slime palette with variations based on the team color.
 
static bool colorEquals (Color a, Color b)
 Utility to compare two colors for equality.
 

Static Public Attributes

static constexpr Color KEEP = {0, 0, 0, 0}
 
static constexpr int PALETTE_SIZE = 10
 

Static Private Attributes

static const Color _teamColors [PALETTE_SIZE]
 
static const SlimePalette _slimePalettes [PALETTE_SIZE]
 

Detailed Description

Centralized color palette for teams and entity materials.

Definition at line 8 of file ColorPalette.hpp.

Member Function Documentation

◆ colorEquals()

bool ColorPalette::colorEquals ( Color  a,
Color  b 
)
static

Utility to compare two colors for equality.

Parameters
aFirst color.
bSecond color.
Returns
True if colors are equal, false otherwise.

Definition at line 41 of file ColorPalette.cpp.

Referenced by EntityRenderer::drawPlayer(), and getSlimePalette().

+ Here is the caller graph for this function:

◆ getResourceColor()

Color ColorPalette::getResourceColor ( int  resourceIndex)
static

Returns the designated UI/3D color for a given resource index.

Definition at line 46 of file ColorPalette.cpp.

Referenced by EntityTooltipWidget::_rebuild(), and EntityRenderer::drawResources().

+ Here is the caller graph for this function:

◆ getSlimePalette()

ColorPalette::SlimePalette ColorPalette::getSlimePalette ( Color  teamColor)
static

Returns a slime palette with variations based on the team color.

Parameters
teamColorThe base color of the team.
Returns
SlimePalette with colors derived from the team color.

Definition at line 32 of file ColorPalette.cpp.

References _slimePalettes, _teamColors, colorEquals(), KEEP, and PALETTE_SIZE.

Referenced by EntityRenderer::drawPlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTeamColor()

Color ColorPalette::getTeamColor ( int  index)
static

Returns a unique color for a team based on its index. Will repeat if more teams than palette size.

Parameters
indexIndex of the team (0-based).
Returns
Color for the team.

Definition at line 30 of file ColorPalette.cpp.

References _teamColors, and PALETTE_SIZE.

Referenced by RaylibRenderer::_initTeamColors().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _slimePalettes

const ColorPalette::SlimePalette ColorPalette::_slimePalettes
staticprivate
Initial value:
= {
{RED, RED, {255, 140, 0, 255}},
{GREEN, GREEN, {0, 200, 200, 255}},
{KEEP, KEEP, KEEP},
{YELLOW, YELLOW, {255, 140, 0, 255}},
{ORANGE, ORANGE, {200, 50, 50, 255}},
{PURPLE, PURPLE, {180, 0, 180, 255}},
{PINK, PINK, {160, 60, 200, 255}},
{LIME, LIME, {0, 180, 60, 255}},
{SKYBLUE, SKYBLUE, {60, 100, 220, 255}},
{MAGENTA, MAGENTA, {160, 0, 200, 255}},
}
static constexpr Color KEEP

Definition at line 7 of file ColorPalette.hpp.

Referenced by getSlimePalette().

◆ _teamColors

const Color ColorPalette::_teamColors
staticprivate
Initial value:
= {RED, GREEN, BLUE, YELLOW, ORANGE,
PURPLE, PINK, LIME, SKYBLUE, MAGENTA}

Definition at line 3 of file ColorPalette.hpp.

Referenced by getSlimePalette(), and getTeamColor().

◆ KEEP

constexpr Color ColorPalette::KEEP = {0, 0, 0, 0}
staticconstexpr

Sentinel: do not modify this material slot.

Definition at line 17 of file ColorPalette.hpp.

Referenced by EntityRenderer::drawPlayer(), and getSlimePalette().

◆ PALETTE_SIZE

constexpr int ColorPalette::PALETTE_SIZE = 10
staticconstexpr

Definition at line 47 of file ColorPalette.hpp.

Referenced by getSlimePalette(), and getTeamColor().


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