Angband
Data Structures | Macros | Typedefs | Functions | Variables
z-color.h File Reference

Generic color definitions. More...

#include "h-basic.h"

Go to the source code of this file.

Data Structures

struct  color_type
 

Macros

#define COLOUR_DARK   0 /* d */ /* 0 0 0 */
 Angband "attributes" (with symbols, and base (R,G,B) codes) More...
 
#define COLOUR_WHITE   1 /* w */ /* 4 4 4 */
 
#define COLOUR_SLATE   2 /* s */ /* 2 2 2 */
 
#define COLOUR_ORANGE   3 /* o */ /* 4 2 0 */
 
#define COLOUR_RED   4 /* r */ /* 3 0 0 */
 
#define COLOUR_GREEN   5 /* g */ /* 0 2 1 */
 
#define COLOUR_BLUE   6 /* b */ /* 0 0 4 */
 
#define COLOUR_UMBER   7 /* u */ /* 2 1 0 */
 
#define COLOUR_L_DARK   8 /* D */ /* 1 1 1 */
 
#define COLOUR_L_WHITE   9 /* W */ /* 3 3 3 */
 
#define COLOUR_L_PURPLE   10 /* P */ /* ? ? ? */
 
#define COLOUR_YELLOW   11 /* y */ /* 4 4 0 */
 
#define COLOUR_L_RED   12 /* R */ /* 4 0 0 */
 
#define COLOUR_L_GREEN   13 /* G */ /* 0 4 0 */
 
#define COLOUR_L_BLUE   14 /* B */ /* 0 4 4 */
 
#define COLOUR_L_UMBER   15 /* U */ /* 3 2 1 */
 
#define COLOUR_PURPLE   16 /* p */
 
#define COLOUR_VIOLET   17 /* v */
 
#define COLOUR_TEAL   18 /* t */
 
#define COLOUR_MUD   19 /* m */
 
#define COLOUR_L_YELLOW   20 /* Y */
 
#define COLOUR_MAGENTA   21 /* i */
 
#define COLOUR_L_TEAL   22 /* T */
 
#define COLOUR_L_VIOLET   23 /* V */
 
#define COLOUR_L_PINK   24 /* I */
 
#define COLOUR_MUSTARD   25 /* M */
 
#define COLOUR_BLUE_SLATE   26 /* z */
 
#define COLOUR_DEEP_L_BLUE   27 /* Z */
 
#define COLOUR_SHADE   28 /* for shaded backgrounds */
 
#define ATTR_FULL   0 /* full color translation */
 The following allow color 'translations' to support environments with a limited color depth as well as translate colours to alternates for e.g. More...
 
#define ATTR_MONO   1 /* mono color translation */
 
#define ATTR_VGA   2 /* 16 color translation */
 
#define ATTR_BLIND   3 /* "Blind" color translation */
 
#define ATTR_LIGHT   4 /* "Torchlit" color translation */
 
#define ATTR_DARK   5 /* "Dark" color translation */
 
#define ATTR_HIGH   6 /* "Highlight" color translation */
 
#define ATTR_METAL   7 /* "Metallic" color translation */
 
#define ATTR_MISC   8 /* "Miscellaneous" - see misc_to_attr */
 
#define MAX_ATTR   9
 
#define MAX_COLORS   256
 Maximum number of colours, and number of "basic" Angband colours. More...
 
#define BASIC_COLORS   29
 
#define BG_BLACK   0 /* The set number for the black-background glyphs */
 
#define BG_SAME   1 /* The set number for the same-background glyphs */
 
#define BG_DARK   2 /* The set number for the dark-background glyphs */
 
#define BG_MAX   3 /* The max number of backgrounds */
 

Typedefs

typedef struct color_type color_type
 A game color. More...
 

Functions

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

Variables

byte angband_color_table [MAX_COLORS][4]
 

Colour constants

More...
 
color_type color_table [MAX_COLORS]
 Global array of color names and translations. More...
 
byte gamma_table [256]
 XXX XXX XXX Important note about "colors" XXX XXX XXX. More...
 

Detailed Description

Generic color definitions.

Copyright (c) 1997 Ben Harrison

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.

Macro Definition Documentation

#define ATTR_BLIND   3 /* "Blind" color translation */
#define ATTR_DARK   5 /* "Dark" color translation */
#define ATTR_FULL   0 /* full color translation */

The following allow color 'translations' to support environments with a limited color depth as well as translate colours to alternates for e.g.

menu highlighting.

#define ATTR_HIGH   6 /* "Highlight" color translation */
#define ATTR_LIGHT   4 /* "Torchlit" color translation */
#define ATTR_METAL   7 /* "Metallic" color translation */
#define ATTR_MISC   8 /* "Miscellaneous" - see misc_to_attr */
#define ATTR_MONO   1 /* mono color translation */
#define ATTR_VGA   2 /* 16 color translation */
#define BASIC_COLORS   29
#define BG_BLACK   0 /* The set number for the black-background glyphs */

Referenced by html_screenshot().

#define BG_DARK   2 /* The set number for the dark-background glyphs */

Referenced by grid_get_attr(), and html_screenshot().

#define BG_MAX   3 /* The max number of backgrounds */

Referenced by html_screenshot().

#define BG_SAME   1 /* The set number for the same-background glyphs */

Referenced by grid_get_attr(), and html_screenshot().

#define COLOUR_BLUE   6 /* b */ /* 0 0 4 */
#define COLOUR_BLUE_SLATE   26 /* z */
#define COLOUR_DARK   0 /* d */ /* 0 0 0 */

Angband "attributes" (with symbols, and base (R,G,B) codes)

The "(R,G,B)" codes are given in "fourths" of the "maximal" value, and should "gamma corrected" on most (non-Macintosh) machines.

Referenced by color_char_to_attr(), html_screenshot(), message_type_color(), monster_health_attr(), and spell_color().

#define COLOUR_DEEP_L_BLUE   27 /* Z */
#define COLOUR_GREEN   5 /* g */ /* 0 2 1 */
#define COLOUR_L_BLUE   14 /* B */ /* 0 4 4 */
#define COLOUR_L_DARK   8 /* D */ /* 1 1 1 */
#define COLOUR_L_GREEN   13 /* G */ /* 0 4 0 */
#define COLOUR_L_PINK   24 /* I */
#define COLOUR_L_PURPLE   10 /* P */ /* ? ? ? */
#define COLOUR_L_RED   12 /* R */ /* 4 0 0 */
#define COLOUR_L_TEAL   22 /* T */
#define COLOUR_L_UMBER   15 /* U */ /* 3 2 1 */
#define COLOUR_L_VIOLET   23 /* V */
#define COLOUR_L_WHITE   9 /* W */ /* 3 3 3 */

Referenced by describe_combat(), and test_graphics1().

#define COLOUR_L_YELLOW   20 /* Y */
#define COLOUR_MAGENTA   21 /* i */
#define COLOUR_MUD   19 /* m */
#define COLOUR_MUSTARD   25 /* M */
#define COLOUR_ORANGE   3 /* o */ /* 4 2 0 */
#define COLOUR_PURPLE   16 /* p */
#define COLOUR_RED   4 /* r */ /* 3 0 0 */
#define COLOUR_SHADE   28 /* for shaded backgrounds */

Referenced by html_screenshot().

#define COLOUR_SLATE   2 /* s */ /* 2 2 2 */
#define COLOUR_TEAL   18 /* t */
#define COLOUR_UMBER   7 /* u */ /* 2 1 0 */

Referenced by monster_health_attr().

#define COLOUR_VIOLET   17 /* v */
#define COLOUR_WHITE   1 /* w */ /* 4 4 4 */
#define COLOUR_YELLOW   11 /* y */ /* 4 4 0 */
#define MAX_ATTR   9
#define MAX_COLORS   256

Maximum number of colours, and number of "basic" Angband colours.

Referenced by color_text_to_attr(), display_glyphs(), dump_colors(), glyph_command(), grid_get_attr(), html_screenshot(), and parse_prefs_color().

Typedef Documentation

A game color.

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)
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().

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().