ASCII color to HEX Color

3k views Asked by At

I am a builder on an old-fasioned MUD. I have been tasked with making a web-based room/object/mobile editor. This is no problem for me, and am almost complete. The only problem I have is the colour chart. I'm not sure how to convert the ASCII colours from Lope's ColoUr system to HEX values to use in CSS.

For instance, Red is defined as:

#define C_RED       "\e[0;31m"  

I'm not sure how to change that to red in Hex to use for CSS, and which shade (there are two shades of red in lope's colour system. One dark, one light. Same for most colors).

Does anyone know of a way to convert from one to the other?

2

There are 2 answers

3
Nick On

Manually entering each entry would be my first guess, unless there's a pattern you can follow for the console colors.

2
Dancrumb On

As I recall, there are only 10 'colours' to worry about here:

  • Red
  • Green
  • Blue
  • Cyan
  • Magenta (Purple)
  • Yellow
  • Black
  • White

Luckily, these are just the primary and secondary colours from an RGB system:

  • Red: 0xFF0000
  • Green: 0x00FF00
  • Blue: 0x0000FF
  • Cyan: 0x00FFFF
  • Magenta (Purple): 0xFF00FF
  • Yellow: 0xFFFF00
  • Black: 0x000000
  • White: 0xFFFFFF

For dark versions, try halving each byte to 7F