/* * This program source code file is part of SystemK, a library in the KTag project. * * 🛡️ 🃞 * * Copyright © 2016-2025 Joseph P. Kearney and the KTag developers. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * There should be a copy of the GNU Affero General Public License in the LICENSE * file in the root of this repository. If not, see . */ /** \file * \brief This file defines colors used by the KTag system (SystemK). * */ #include #ifndef COLORS_H #define COLORS_H //! Represents a color with 8 bits per color, plus an 8-bit brightness mask, as MMRRGGBB. typedef uint32_t color_t; #define COLOR_BLACK ((color_t)0xFF000000) #define COLOR_WHITE ((color_t)0xFFFFFFFF) #define COLOR_RED ((color_t)0xFFFF0000) #define COLOR_ORANGE ((color_t)0xFFFF7F00) #define COLOR_YELLOW ((color_t)0xFFFFFF00) #define COLOR_GREEN ((color_t)0xFF00FF00) #define COLOR_CYAN ((color_t)0xFF00FFFF) #define COLOR_BLUE ((color_t)0xFF0000FF) #define COLOR_MAGENTA ((color_t)0xFFFF0033) #define COLOR_PURPLE ((color_t)0xFFFF00FF) #define COLOR_PINK ((color_t)0xFFFF3377) #define COLOR_AQUA ((color_t)0xFF557DFF) inline color_t GetColorFromTeamID(uint8_t team_ID) { color_t result = COLOR_BLACK; switch (team_ID) { default: case 0: result = COLOR_PURPLE; break; case 1: result = COLOR_RED; break; case 2: result = COLOR_GREEN; break; case 3: result = COLOR_WHITE; break; case 4: result = COLOR_BLUE; break; case 5: result = COLOR_ORANGE; break; case 6: result = COLOR_YELLOW; break; case 7: result = COLOR_BLACK; break; } return result; } inline color_t Color(uint8_t mask, uint8_t red, uint8_t green, uint8_t blue) { return (((color_t)mask << 24) | ((color_t)red << 16) | ((color_t)green << 8) | ((color_t)blue)); } inline color_t ApplyMask(color_t color, uint8_t mask) { return (((color_t)mask << 24) | (color & 0x00FFFFFF)); } inline uint8_t Red(color_t color) { return ((color >> 24) & ((color >> 16) & 0xFF)); } inline uint8_t Green(color_t color) { return ((color >> 24) & ((color >> 8) & 0xFF)); } inline uint8_t Blue(color_t color) { return ((color >> 24) & (color & 0xFF)); } #endif // COLORS_H