Angband
Functions | Variables
z-color.c File Reference

Generic color definitions. More...

#include "h-basic.h"
#include "z-color.h"
#include "z-util.h"

Functions

int color_char_to_attr (char c)
 Accept a color index character; if legal, return the color.
int color_text_to_attr (const char *name)
 Converts a string to a terminal color byte.
const char * attr_to_text (byte a)
 Extract a textual representation of an attribute.
void build_gamma_table (int gamma)
 Build the gamma table so that floating point isn't needed.

Variables

byte angband_color_table [MAX_COLORS][4]
 

Colour constants


color_type color_table [MAX_COLORS]
 Global array of color names and translations.
byte gamma_table [256]
 XXX XXX XXX Important note about "colors" XXX XXX XXX.
static const s16b gamma_helper [256]
 Table of ln(x / 256) * 256 for x going from 0 -> 255.

Detailed Description

Generic color definitions.

Copyright (c) 1997 Ben Harrison

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Function Documentation

const char* attr_to_text ( byte  a)

Extract a textual representation of an attribute.

References BASIC_COLORS.

Referenced by spoil_mon_desc(), and spoil_mon_info().

void build_gamma_table ( int  gamma)

Build the gamma table so that floating point isn't needed.

Note gamma goes from 0->256. The old value of 100 is now 128.

References gamma_helper, gamma_table, i, and value.

int color_char_to_attr ( char  c)

Accept a color index character; if legal, return the color.

-LM-

Unlike Sangband, we don't translate these colours here.

References BASIC_COLORS, COLOUR_DARK, and COLOUR_WHITE.

Referenced by parse_artifact_graphics(), parse_feat_graphics(), parse_flavor_flavor(), parse_monster_color(), parse_object_base_graphics(), parse_object_graphics(), parse_pit_color(), parse_prefs_message(), and parse_trap_graphics().

int color_text_to_attr ( const char *  name)

Variable Documentation

byte angband_color_table[MAX_COLORS][4]


Colour constants

Global table of color definitions (mostly zeros)

Referenced by colors_modify(), dump_colors(), html_screenshot(), and parse_prefs_color().

color_type color_table[MAX_COLORS]

Global array of color names and translations.

Referenced by colors_modify(), and dump_colors().

const s16b gamma_helper[256]
static
Initial value:
{
0, -1420, -1242, -1138, -1065, -1007, -961, -921, -887, -857, -830,
-806, -783, -762, -744, -726, -710, -694, -679, -666, -652, -640,
-628, -617, -606, -596, -586, -576, -567, -577, -549, -541, -532,
-525, -517, -509, -502, -495, -488, -482, -475, -469, -463, -457,
-451, -455, -439, -434, -429, -423, -418, -413, -408, -403, -398,
-394, -389, -385, -380, -376, -371, -367, -363, -359, -355, -351,
-347, -343, -339, -336, -332, -328, -325, -321, -318, -314, -311,
-308, -304, -301, -298, -295, -291, -288, -285, -282, -279, -276,
-273, -271, -268, -265, -262, -259, -257, -254, -251, -248, -246,
-243, -241, -238, -236, -233, -231, -228, -226, -223, -221, -219,
-216, -214, -212, -209, -207, -205, -203, -200, -198, -196, -194,
-192, -190, -188, -186, -184, -182, -180, -178, -176, -174, -172,
-170, -168, -166, -164, -162, -160, -158, -156, -155, -153, -151,
-149, -147, -146, -144, -142, -140, -139, -137, -135, -134, -132,
-130, -128, -127, -125, -124, -122, -120, -119, -117, -116, -114,
-112, -111, -109, -108, -106, -105, -103, -102, -100, -99, -97, -96,
-95, -93, -92, -90, -89, -87, -86, -85, -83, -82, -80, -79, -78,
-76, -75, -74, -72, -71, -70, -68, -67, -66, -65, -63, -62, -61,
-59, -58, -57, -56, -54, -53, -52, -51, -50, -48, -47, -46, -45,
-44, -42, -41, -40, -39, -38, -37, -35, -34, -33, -32, -31, -30,
-29, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16,
-14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1
}

Table of ln(x / 256) * 256 for x going from 0 -> 255.

Referenced by build_gamma_table().

byte gamma_table[256]

XXX XXX XXX Important note about "colors" XXX XXX XXX.

The "COLOUR_*" color definitions list the "composition" of each "Angband color" in terms of "quarters" of each of the three color components (Red, Green, Blue), for example, COLOUR_UMBER is defined as 2/4 Red, 1/4 Green, 0/4 Blue.

These values are NOT gamma-corrected. On most machines (with the Macintosh being an important exception), you must "gamma-correct" the given values, that is, "correct for the intrinsic non-linearity of the phosphor", by converting the given intensity levels based on the "gamma" of the target screen, which is usually 1.7 (or 1.5).

The actual formula for conversion is unknown to me at this time, but you can use the table below for the most common gamma values.

So, on most machines, simply convert the values based on the "gamma" of the target screen, which is usually in the range 1.5 to 1.7, and usually is closest to 1.7. The converted value for each of the five different "quarter" values is given below:

Given Gamma 1.0 Gamma 1.5 Gamma 1.7 Hex 1.7


0/4 0.00 0.00 0.00 #00 1/4 0.25 0.27 0.28 #47 2/4 0.50 0.55 0.56 #8f 3/4 0.75 0.82 0.84 #d7 4/4 1.00 1.00 1.00 #ff Table of gamma values

Referenced by build_gamma_table().