ff_i_color
Various functions for RGB / color manipulation.
Refer to other pages Custom Tokens and ff_i_token for additional details.
Color |
Value |
Sample |
Description |
|---|---|---|---|
RGB_COLOR_DEFAULT |
0xFEFEFE |
#FEFEFE |
Default color |
RGB_COLOR_BUG |
0x660000 |
#660000 |
Color to indicate a bug |
RGB_COLOR_ATTENTION |
0xFEA400 |
#FEA400 |
Color to indicate a point of attention |
RGB_COLOR_SUCCESS |
0x3DC93D |
#3DC93D |
Color to indicate success |
RGB_COLOR_FAIL |
0xFF0000 |
#FF0000 |
Color to indicate failure |
RGB_COLOR_INFO |
0xD0814B |
#D0814B |
Color to indicate simple information |
RGB_COLOR_DEBUG |
0xB4B4B4 |
#B4B4B4 |
Color to indicate debug message |
RGB_COLOR_MESSAGE_COMBAT |
0xFF6601 |
#FF6601 |
Color of combat messages |
RGB_COLOR_MESSAGE_FEEDBACK |
0xFFFF01 |
#FFFF01 |
Color of feedback messages |
RGB_COLOR_MESSAGE_MAGIC |
0xCC77FF |
#CC77FF |
Color of magic related messages |
RGB_COLOR_MESSAGE_SAVE_GAME |
0x20FF20 |
#20FF20 |
When saving the game |
RGB_COLOR_MESSAGE_SKILLS |
0x0166FF |
#0166FF |
Color of skill check messages |
RGB_COLOR_MESSAGE_SAVING_THROW |
0x66CCFF |
#66CCFF |
Color of saving throw messages |
RGB_COLOR_MESSAGE_PAUSE_GAME |
0xFF0101 |
#FF0101 |
When pausing or unpausing |
RGB_COLOR_PLAYER_NAME |
0x99FFFF |
#99FFFF |
Color of player’s name |
RGB_COLOR_OTHERS_NAME |
0xCC99CC |
#CC99CC |
Color of another’s player name |
RGB_COLOR_DAMAGE_ACID |
0x01FF01 |
#01FF01 |
Color of acid damage |
RGB_COLOR_DAMAGE_COLD |
0x99FFFF |
#99FFFF |
Color of cold damage |
RGB_COLOR_DAMAGE_DIVINE |
0xFFFF01 |
#FFFF01 |
Color of divine damage |
RGB_COLOR_DAMAGE_ELECTRICAL |
0x0166FF |
#0166FF |
Color of electrical damage |
RGB_COLOR_DAMAGE_FIRE |
0xFF0101 |
#FF0101 |
Color of fire damage |
RGB_COLOR_DAMAGE_MAGICAL |
0xCC77FF |
#CC77FF |
Color of magical damage |
RGB_COLOR_DAMAGE_NEGATIVE |
0x999999 |
#999999 |
Color of negative damage |
RGB_COLOR_DAMAGE_POSITIVE |
0xFFFFFF |
#FFFFFF |
Color of positive damage |
RGB_COLOR_DAMAGE_SONIC |
0x0FF9901 |
#0FF9901 |
Color of magical damage |
References
-
RGB_COLOR_DEFAULT
Default color.
-
RGB_COLOR_BUG
Color to indicate a bug.
-
RGB_COLOR_ATTENTION
Color to indicate a point of attention.
-
RGB_COLOR_SUCCESS
Color to indicate success.
-
RGB_COLOR_FAIL
Color to indicate failure.
-
RGB_COLOR_INFO
Color to indicate simple information.
-
RGB_COLOR_DEBUG
Color to indicate debug message.
-
RGB_COLOR_MESSAGE_COMBAT
Color of combat messages.
-
RGB_COLOR_MESSAGE_FEEDBACK
Color of feedback messages.
-
RGB_COLOR_MESSAGE_MAGIC
Color of magic related messages.
-
RGB_COLOR_MESSAGE_SAVE_GAME
When saving the game.
-
RGB_COLOR_MESSAGE_SKILLS
Color of skill check messages.
-
RGB_COLOR_MESSAGE_SAVING_THROW
Color of saving throw messages.
-
RGB_COLOR_MESSAGE_PAUSE_GAME
When pausing or unpausing.
-
RGB_COLOR_PLAYER_NAME
Color of player’s name.
-
RGB_COLOR_OTHERS_NAME
Color of another’s player name.
-
RGB_COLOR_DAMAGE_ACID
Color of acid damage.
-
RGB_COLOR_DAMAGE_COLD
Color of cold damage.
-
RGB_COLOR_DAMAGE_DIVINE
Color of divine damage.
-
RGB_COLOR_DAMAGE_ELECTRICAL
Color of electrical damage.
-
RGB_COLOR_DAMAGE_FIRE
Color of fire damage.
-
RGB_COLOR_DAMAGE_MAGICAL
Color of magical damage.
-
RGB_COLOR_DAMAGE_NEGATIVE
Color of negative damage.
-
RGB_COLOR_DAMAGE_POSITIVE
Color of positive damage.
-
RGB_COLOR_DAMAGE_SONIC
Color of magical damage.
-
int GetRGBAsInt(struct rgb stInput)
- Parameters:
stInput – RGB struct whose r/g/b components are clamped to 0-255 before packing.
stInput – Struct rgb
- Returns:
Color
Converts an RGB value to an integer.
-
struct rgb GetIntAsRGB(int nColor)
- Parameters:
nColor – A packed RGB integer (e.g. 0xFF8800).
nColor – Color
- Returns:
An struct rgb
Get the components of a RGB color.
Source code
// @code
#include "ff_i_maths"
#include "ff_i_token"
// -----------------------------------------------------------------------------
//! @struct rgb
//! @brief Struct containing Red, Green, Blue components.
struct rgb
{
int r; //!< Red
int g; //!< Green
int b; //!< Blue
};
// -----------------------------------------------------------------------------
//! @var RGB_COLOR_DEFAULT
//! @brief Default color
const int RGB_COLOR_DEFAULT = 0xFEFEFE;
//! @var RGB_COLOR_BUG
//! @brief Color to indicate a bug
const int RGB_COLOR_BUG = 0x660000;
//! @var RGB_COLOR_ATTENTION
//! @brief Color to indicate a point of attention
const int RGB_COLOR_ATTENTION = 0xFEA400;
//! @var RGB_COLOR_SUCCESS
//! @brief Color to indicate success
const int RGB_COLOR_SUCCESS = 0x3DC93D;
//! @var RGB_COLOR_FAIL
//! @brief Color to indicate failure
const int RGB_COLOR_FAIL = 0xFF0000;
//! @var RGB_COLOR_INFO
//! @brief Color to indicate simple information
const int RGB_COLOR_INFO = 0xD0814B;
//! @var RGB_COLOR_DEBUG
//! @brief Color to indicate debug message
const int RGB_COLOR_DEBUG = 0xB4B4B4;
// -----------------------------------------------------------------------------
//! @var RGB_COLOR_MESSAGE_COMBAT
//! @brief Color of combat messages
const int RGB_COLOR_MESSAGE_COMBAT = 0xFF6601;
//! @var RGB_COLOR_MESSAGE_FEEDBACK
//! @brief Color of feedback messages
const int RGB_COLOR_MESSAGE_FEEDBACK = 0xFFFF01;
//! @var RGB_COLOR_MESSAGE_MAGIC
//! @brief Color of magic related messages
const int RGB_COLOR_MESSAGE_MAGIC = 0xCC77FF;
//! @var RGB_COLOR_MESSAGE_SAVE_GAME
//! @brief When saving the game
const int RGB_COLOR_MESSAGE_SAVE_GAME = 0x20FF20;
//! @var RGB_COLOR_MESSAGE_SKILLS
//! @brief Color of skill check messages
const int RGB_COLOR_MESSAGE_SKILLS = 0x0166FF;
//! @var RGB_COLOR_MESSAGE_SAVING_THROW
//! @brief Color of saving throw messages
const int RGB_COLOR_MESSAGE_SAVING_THROW = 0x66CCFF;
//! @var RGB_COLOR_MESSAGE_PAUSE_GAME
//! @brief When pausing or unpausing
const int RGB_COLOR_MESSAGE_PAUSE_GAME = 0xFF0101;
//! @var RGB_COLOR_PLAYER_NAME
//! @brief Color of player's name
const int RGB_COLOR_PLAYER_NAME = 0x99FFFF;
//! @var RGB_COLOR_OTHERS_NAME
//! @brief Color of another's player name
const int RGB_COLOR_OTHERS_NAME = 0xCC99CC;
// -----------------------------------------------------------------------------
//! @var RGB_COLOR_DAMAGE_ACID
//! @brief Color of acid damage
const int RGB_COLOR_DAMAGE_ACID = 0x01FF01;
//! @var RGB_COLOR_DAMAGE_COLD
//! @brief Color of cold damage
const int RGB_COLOR_DAMAGE_COLD = 0x99FFFF;
//! @var RGB_COLOR_DAMAGE_DIVINE
//! @brief Color of divine damage
const int RGB_COLOR_DAMAGE_DIVINE = 0xFFFF01;
//! @var RGB_COLOR_DAMAGE_ELECTRICAL
//! @brief Color of electrical damage
const int RGB_COLOR_DAMAGE_ELECTRICAL = 0x0166FF;
//! @var RGB_COLOR_DAMAGE_FIRE
//! @brief Color of fire damage
const int RGB_COLOR_DAMAGE_FIRE = 0xFF0101;
//! @var RGB_COLOR_DAMAGE_MAGICAL
//! @brief Color of magical damage
const int RGB_COLOR_DAMAGE_MAGICAL = 0xCC77FF;
//! @var RGB_COLOR_DAMAGE_NEGATIVE
//! @brief Color of negative damage
const int RGB_COLOR_DAMAGE_NEGATIVE = 0x999999;
//! @var RGB_COLOR_DAMAGE_POSITIVE
//! @brief Color of positive damage
const int RGB_COLOR_DAMAGE_POSITIVE = 0xFFFFFF;
//! @var RGB_COLOR_DAMAGE_SONIC
//! @brief Color of magical damage
const int RGB_COLOR_DAMAGE_SONIC = 0x0FF9901;
// -----------------------------------------------------------------------------
//! @brief Converts an RGB value to an integer
//! @param stInput RGB struct whose r/g/b components are clamped to 0-255 before packing.
//! @param stInput Struct rgb
//! @return Color
int GetRGBAsInt(struct rgb stInput);
int GetRGBAsInt(struct rgb stInput)
{
stInput.r = clamp(stInput.r, 0, 255);
stInput.g = clamp(stInput.g, 0, 255);
stInput.b = clamp(stInput.b, 0, 255);
return (stInput.r * 65536) + (stInput.g * 256) + stInput.b;
}
// -----------------------------------------------------------------------------
//! @brief Get the components of a RGB color
//! @param nColor A packed RGB integer (e.g. 0xFF8800).
//! @param nColor Color
//! @return An struct rgb
struct rgb GetIntAsRGB(int nColor);
struct rgb GetIntAsRGB(int nColor)
{
struct rgb stColor;
stColor.r = (nColor >> 16) & 0xFF;
stColor.g = (nColor >> 8) & 0xFF;
stColor.b = nColor & 0xFF;
return stColor;
}