Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
ColorPalette.cpp
Go to the documentation of this file.
1#include "ColorPalette.hpp"
2
3const Color ColorPalette::_teamColors[PALETTE_SIZE] = {RED, GREEN, BLUE, YELLOW, ORANGE,
4 PURPLE, PINK, LIME, SKYBLUE, MAGENTA};
5
6// KEEP = {0,0,0,0} = don't touch that material slot
8 // RED blush: orange (red+yellow)
9 {RED, RED, {255, 140, 0, 255}},
10 // GREEN blush: cyan (green+blue)
11 {GREEN, GREEN, {0, 200, 200, 255}},
12 // BLUE model as-is, purple blush already baked in
13 {KEEP, KEEP, KEEP},
14 // YELLOW blush: orange (yellow+red)
15 {YELLOW, YELLOW, {255, 140, 0, 255}},
16 // ORANGE blush: red (orange+red)
17 {ORANGE, ORANGE, {200, 50, 50, 255}},
18 // PURPLE blush: magenta (purple+red)
19 {PURPLE, PURPLE, {180, 0, 180, 255}},
20 // PINK blush: purple (pink+blue)
21 {PINK, PINK, {160, 60, 200, 255}},
22 // LIME blush: green (lime+green)
23 {LIME, LIME, {0, 180, 60, 255}},
24 // SKYBLUE blush: blue (skyblue+blue)
25 {SKYBLUE, SKYBLUE, {60, 100, 220, 255}},
26 // MAGENTA blush: purple (magenta+blue)
27 {MAGENTA, MAGENTA, {160, 0, 200, 255}},
28};
29
30Color ColorPalette::getTeamColor(int index) { return _teamColors[index % PALETTE_SIZE]; }
31
33{
34 for (int i = 0; i < PALETTE_SIZE; i++) {
35 if (colorEquals(_teamColors[i], teamColor)) return _slimePalettes[i];
36 }
37 // fallback: raw tint on outer+inner, leave blush
38 return {teamColor, teamColor, KEEP};
39}
40
41bool ColorPalette::colorEquals(Color a, Color b)
42{
43 return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;
44}
45
46Color ColorPalette::getResourceColor(int resourceIndex)
47{
48 static const Color resourceColors[] = {
49 RED, // food
50 DARKGRAY, // linemate
51 GREEN, // deraumere
52 BLUE, // sibur
53 YELLOW, // mendiane
54 ORANGE, // phiras
55 PURPLE // thystame
56 };
57
58 if (resourceIndex < 0 || resourceIndex >= 7) return WHITE;
59 return resourceColors[resourceIndex];
60}
static constexpr int PALETTE_SIZE
static const SlimePalette _slimePalettes[PALETTE_SIZE]
static Color getResourceColor(int resourceIndex)
Returns the designated UI/3D color for a given resource index.
static bool colorEquals(Color a, Color b)
Utility to compare two colors for equality.
static const Color _teamColors[PALETTE_SIZE]
static constexpr Color KEEP
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 SlimePalette getSlimePalette(Color teamColor)
Returns a slime palette with variations based on the team color.