AsciiColor

Back to homepage 12 october 2019

AsciiColor is a perl script that renders ASCII arts in color. It's simple and allows you to make colorful ASCII arts with a simple text editor.

__ _ __ __ \ _\\ \_\ _\ - \_\ \___\_\ \__\ 7E3h

The script is available here, along with some demo files.

It takes options and a file name as it's arguments, and renders the ascii art in one of the 3 formats:

  1. ANSI mode - uses ANSI escape codes
  2. mIRC mode - uses mIRC color codes
  3. HTML mode - generates HTML fragments for embedding in websites.
ANSI mode is the default.

The ASCII art is defined by two files - a .txt and a .map file. The .txt file contains the characters that make up the ASCII art, and the .map file is made of hex digits in place of the ASCII art characters. Each hex digit (0-9, a-f, A-F) corresponds to one of the 16 colors.

The file structure is very simple. The .txt file is just the ascii art in monochrome.

  __   _   __  __
 \  _\\ \_\  _\  -
  \_\  \___\_\ \__\ 7E3h
  

While the .map file has a hex digit in place of each character in the .txt file

  FF   F   FF  FF
 A  2AA A2A  2A  A
  232  2333232 2332 8888
  

The asciicolor script loads these two files and outputs the ASCII art in color.

__ __ __ __ :__: :__: :__: :__: :__: :__: :__: :__:

Below is the script running in terminal (in ANSI mode)

Use -h to print the help

Usage: ./asciicolor4.pl [-dhbmarw] <artfile>
  The script takes artfile.txt and artfile.map files as argument
  and prints out the ascii art in color.
  the map file name is generated from the txt parameter
  The map file contains numbers 0-9 and letters a-f
  that define colour, in place of the ascii art characters
  By default ANSI escape codes are used
  Options are checked in the order listed
  -a    Use ANSI escape codes (default)
  -b    Use bold text for light colours (mIRC)
  -h    Print help and exit
  -m    Use mIRC formatting codes
  -r    Enable reverse video
  -d    Enable debug info
  -w    Enable web mode (outputs partial html)
  Map file color values:
  +------+------------+
  | DARK | LIGHT/BOLD |
  +------+------------+
  | 0    | 8 black    |
  | 1    | 9 red      |
  | 2    | A green    |
  | 3    | B yellow   |
  | 4    | C blue     |
  | 5    | D magenta  |
  | 6    | E cyan     |
  | 7    | F white    |
  +------+------------+
  AsciiColor v4.0 by polprog, 2019
  https://polprog.net/ released on 3BSD

Back to homepage