Colors

From NetHackWiki
(Redirected from Colours)
Jump to: navigation, search

On some systems, NetHack can display monsters, objects and dungeon features in color. (This is not the same thing as the graphical display using tiles.) The exact appearance of these colors depends on many things, including the platform NetHack was compiled for, compile-time options, run-time options, your terminal settings and the monitor you're using.

If your NetHack supports color output, it can be toggled on or off using the color option.

For the colors of the wiki itself, see function templates and ReplaceCharsBlock.

NetHack color codes

Internally, the colors in NetHack are specified using the 16 CLR_* color codes (including NO_COLOR, a dark gray used as the default color) defined in the file includes/color.h.

color name numeric value
CLR_BLACK 0
CLR_RED 1
CLR_GREEN 2
CLR_BROWN 3
CLR_BLUE 4
CLR_MAGENTA 5
CLR_CYAN 6
CLR_GRAY 7
NO_COLOR 8
CLR_ORANGE 9
CLR_BRIGHT_GREEN 10
CLR_YELLOW 11
CLR_BRIGHT_BLUE 12
CLR_BRIGHT_MAGENTA 13
CLR_BRIGHT_CYAN 14
CLR_WHITE 15
CLR_MAX 16


The same file also defines a number of "logical" colors for different materials and effects which map to these 16 colors: for example, both leather and wood are defined to be CLR_BROWN.

logical name color name
HI_OBJ CLR_MAGENTA
HI_METAL CLR_CYAN
HI_COPPER CLR_YELLOW
HI_SILVER CLR_GRAY
HI_GOLD CLR_YELLOW
HI_LEATHER CLR_BROWN
HI_CLOTH CLR_BROWN
HI_ORGANIC CLR_BROWN
HI_WOOD CLR_BROWN
HI_PAPER CLR_WHITE
HI_GLASS CLR_BRIGHT_CYAN
HI_MINERAL CLR_GRAY
DRAGON_SILVER CLR_BRIGHT_CYAN
HI_ZAP CLR_BRIGHT_BLUE

Terminal color codes

On systems where NetHack outputs text to be displayed in a terminal (rather than handling text rendering by itself), the internal color codes defined in color.h are mapped to ANSI escape codes or equivalent codes defined in the system terminfo. This mapping is specified in win/tty/termcap.c, and (for a mapping of 16 to 16 colors) is surprisingly platform-dependent. Notable quirks include:

  • On systems defining MICRO (which are these?), CLR_BLUE is mapped to the same color code as CLR_BRIGHT_BLUE, presumably because the default blue is considered too dark.
  • On many (most?) systems (which?), no color codes are defined for CLR_BLACK, CLR_GRAY and NO_COLOR, leaving them all as the default text color (usually gray).
  • On Unix systems using terminfo, CLR_BLACK is actually aliased to CLR_BLUE. There is a comment saying that this is done to avoid trying to display black text on a (presumed) black background, as it might not be visible.
  • On the Atari TOS port, several of the darker colors are mapped to their bright counterparts. (Which ones? The code is kind of confusing...)

On some systems, the mapping from NetHack colors to terminal colors may be adjusted using the videocolors option.

RGB colors

On some systems, NetHack directly maps the 16 internal color codes to RGB colors. On others, this task is left for the terminal emulator, while on some (mainly older) systems, the color choices may even be determined by the graphics hardware.

A user has suggested improving this page or section as follows:

"List some NetHack/terminal color palettes here."

mtty palette

Black
Red
Green
Brown
Blue
Magenta
Cyan
Gray
Orange
Bright green
Yellow
Bright blue
Bright magenta
Bright cyan
White

Monitor

Even the appearance of the RGB colors is not fixed, but can vary depending on your display hardware and software. Some issues that can affect color rendering include:

  • Your computer may or may not apply gamma correction to colors (and, if it does, it may or may not be properly calibrated). Also, different monitors may have different natural gamma values, and on some monitors the gamma value may even be adjustable.
  • CRT and LCD monitors have different color gamuts, affecting the colors they can display.
  • The brightness, contrast and color temperature of the monitor can also vary, and are often subject to user adjustment.
  • Finally, ambient lighting and variations in the human eye itself can affect the appearance of colors.

What all this comes down to is that colors which look nice and easily visible to one person may not look as good to another. Thus, picking a good color palette is ultimately a personal, subjective choice.

Changing terminal colors

PuTTY

The colors for PuTTY can be changed in the putty settings, or you could use Windows Console colors editor which can also create a registry file for putty.

rxvt

From the command line: rxvt -color4 lightblue.

rxvt colors can also be set via the X11 resources as seen in the xterm configuration below by using Rxvt*color4: lightblue in ~/.Xdefaults

xterm

From the command line: xterm -xrm "XTerm*color4: lightblue"

Similar to setting X11 resources, you can change the colors used by xterm, by putting eg. the following in ~/.Xdefaults:

XTerm*color4: lightblue

And then doing xrdb -merge ~/.Xdefaults to set the resource. Starting xterm after that will use the lightblue color.

Linux console

You can output an OSC control sequence to change a color. The format is: Esc]Pnrrggbb, where Esc means the escape character. nrrggbb is a sequence of 7 hexadecimal digits, where n is the color number, and rr, gg and bb are the red, green and blue parts of the color.

You can do this with the echo command, for example:

 echo -e '\e]P40000ff'

This will set the fourth color (dark blue) to the RGB values 0, 0, and 255. To reset all colors, use this sequence:

 echo -e '\e]R'

You might want to put this into a script so you don't have to do this manually every time you play.

See Also

This page may need to be updated for NetHack 3.6.0.

It may contain text specific to NetHack 3.4.3. Information on this page may be out of date.

Editors: After reviewing this page and making necessary edits, please change the {{nethack-343}} tag to {{nethack-360}} or {{noversion}} as appropriate.