mdbtxt1
mdbtxt2
Proceed to Safety

# ASCII Graphics

Robert P. Munafo, 2012 Apr 11.

An "ASCII graphic" is a graphical image rendered entirely out of characters from the ASCII character set, usually in a monospace font. Many of the original illustrations in this encyclopedia were rendered in ASCII graphics to permit sending the articles to email users. Following is a precise description of how they are generated.

A Mandelbrot image is drawn on a 350×350 grid using the distance estimator method, which generates a good line-art rendition. The pixel grid is broken up into character cells, each 5×12 pixels in size. Within each character cell, six blocks are defined, each 2×4 pixels in size. The rightmost column of pixels in each character cell is ignored. A six-bit pattern value is generated by doing a true-or-false test on each of the six blocks. The algorithm first takes only the upper-left pixel in each block. If the resulting pattern value is 0, the algorithm recomputes the pattern value using the boolean OR of four pixels within each block. Once a pattern value is achieved, a character is produced by looking up in a 64-entry table. Figure A shows the bit positions assigned to each of the six blocks when forming the pattern value, and Figure B shows the mapping from pattern values onto representational ASCII characters. (Note in particular that several ASCII characters are used more than once.)

32 16 1 1 2 2 3 3 4 4 5 5 6 6 8 4 01234567890....5....0....5....0....5....0....5....0....5....0..3 2 1 .,_-:/a-\ce-vrm':/d']//~(/("(/d`\;L~\))`\[L"\)b^7F%"T)\$"(FC*#F@    Fig. A Fig. B: Character corresponding to each pattern value (first two rows are column numbers from 0 to 63)

Here are a couple examples. In each, a 2×3 block of pixels is converted into a number by adding the values from figure A, then the appropriate character is found in figure B:

pixel pixel ASCII character pixels values sum (from table)    * * 32 16 * ---> 8 ---> 57 ---> ( * 1       * 32 * ---> 8 ---> 41 ---> \ * 1

For a 350×350 image, the result is 30 lines of text, each containing 70 characters plus a newline. A total of 12320 bits of information is expressed in 2130 bytes of text.

Here are some images of the Mandelbrot set produced by this method:

: tmz -0.76 0.001 2.56 -ascii -grid 350 ., ^(, _ "_-- .__.v"\-.. ^@^^'^"d~ .,__ _,_^\, aF`, ., ., -7YYr,_@~"*''` '`^~":*",a__]L, .,:*.-`` ^~~`^C^ :_ 'm)"" `Y_ , -]_,. _- _ -a-" \-.L `(*vaaFL7c,, ]C` /`, ._ -.e/- '",:` rF , ~_a_:^ '/ :~` ------/c-,ev-,Le)" ^ ` .-` ' ` ^@v-], .- '-, -^ :;Le, ._~] @- -(Lav_a_\rF` ') m^- -a^""` mF`` -\$L, .%), -~ ' aaC_, .aY' ^ ''`:C--, _,'`r_ _\$__F-e.___, .__._:r"^v-T", -~^~ "`^^%"^ '"%^^'"` '- -Y_ .(` '~F"__a^'~ '_\__ 'c` " '-` -0.760 +0.001 i @ 2.560 nmax 1024 gridsize 350x350    : tmz R2t 7 -ascii -grid 350 -, ` : - a` '-, ~, ', ' ] :` -, ~, -, ` ' a- . .- -, . ', ~, ', c , , .` _~ .,- -, ~, '\ ", '\ ^-ae`/,/`.- /` -' -, ^e \ \ '\ .`-,@@bama- _,' . . - -, '\ - ~, ~,-,`.'._m@@@d\['\ .- _ ' _-- . '-, ~, `, '. \'e'\-)@@F*`'*@)/\-a-/,_- .,-' '-, '\ 'e ", ,'. -,\amddLedd@L_ _/@\$bLa\Lm_~,-`. '-., -. . `, 'c-," ',.-,-;T@@"Y""^` ''^*YF*@@-'-''._.---^ '`-_ `- `. ..L/e`-`.'-~-:m@Y*` -m@FY`-^^^ ^ , '\ `\' '/:@@(b/@b)a`(d@* *Y@)-`^^` _. '--.. ,'-,.-,~,`(::./@@^**""*@d@" 'Y@d%^^^^^'^ `-.'-~\$.,T]:d'@mm@F` ^F a@"'----- ------`abb@@@@@@@d@@@^' ` -aF~@"---------- ''`^\'*F^""7"@@mdc .e "@bC%L___ ,,--' - ./`'.~.~-'F"(*@b-_,.._m@@c .\$b_--___ _, .-` _-`,:-;@@@@Y@@@Y^/Yb, .\$@r--_ ^`^^^ _,-` _-` _ ''\YY";/^~`-\(~@Ca_ a@Y*\%_ ^` _.-^ -` - _~ `/.`:`.''\-^(^@@`__, _ _m__@br~,_'^^--_., ` ..-` ., .~ .~ './`.-`/@@@*Yb@mr` 'vm/@FY\$%@F~`, ` ' ' .~ ' .` _- './`/~/",:]\@b,,./@)-')-`\` .,'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@@@F^ @\_mm md@@@@@@@@@@@@@@@@@@@@@@@@**"`^*@@"` ^^T@@d@@e @@@@@e_, -@@@@Y@@@@@@@@@@@@@bF\$\$@@@@@, " `Y@@" /*@@Y@@_ `._d**FY@@@@@C@@@@(*@@@@@@bmmm- '@/ @e' -*` :(@d@d@FdF@@'@@@@@@b\$*Y@@@@@@@ .F *^ _ma@@@@@@F@@@^m(*Yb@@@Fd@m@@@@@bm, ` a@@@@@@@@@@@m'@@@@@@@@L"*@@@@@@@F`., _, ._ ._ 'FY@@@@@d@@^:@@@@@@@@@'@@@@@@@\$@@@@b_e___mm* /ba@Ld@, '"`-@@@@F) ^T@@@*@@F` *@@@@@@@F@@@@@@F@FF @@@@@@b__, __ , ***^ _, ._, ,.m__,^Y@@*Y%mm@b@@@F' @@@@@@@@@%a@@bmdee _a@),@@@r/@@@@@bmm-.@@@@F@@@b_` @@@@@@@@@@@@@@@^^* 'F@@@@@@@\$@@@@@@@@\/@@@@F*"*" F@@@@@@@Y@d\$*/"_ mm_d@@@@@@@@@@@%@@/LbaCY@@@@e_ @@@@F@@@/@@@@@@@@` -\@@@@@@@@@@@@@@@@@@@@@@@b@@@T' ^^^'^^^^ ^^^^^^^^` '^^^^^^^^^^^^^^^^^^^^^^^^^^^` -0.67654 +0.30794 i @ 0.00415 nmax 34010 gridsize 350x350

Other ASCII art Mandelbrot images can be found in the following Mu-Ency articles: embedded Julia set, Feigenbaum point, paramecia, R2, R2.C(1/2), Seahorse Valley. In most of them you can see the ASCII version side-by-side with a normal high-resolution full-color image.

Standard types of ASCII art

For comparison, here are two samples of hand-created ASCII art, both from the Wikipedia entry :

____ _____ ______________ ____ ____ ______ / _ | / ___// ____/ _/ _/ / _ | / __ \/_ __/ / /_| | \__ \/ / / / / / / /_| | / /_/ / / / / /__| | __/ / /___ / / / / / /__| |/ / / / / / /_/ |_/____/\____/___/___/ /_/ |_/_/ |_| /_/    "Oldskool" or "Amiga" style    o\$ \$o .o\$\$\$\$o. .o\$\$\$\$o .s\$\$\$\$\$o.' `".o\$\$\$\$\$o..o\$\$\$\$\$o.o\$\$\$\$\$o. .o `\$.\$\$' . o\$ \$"'.o \$\$ .o `\$. .o `\$\$ \$\$ .o\$\$.o\$\$\$`"\$\$\$o. \$\$ . \$\$ \$\$ .o\$\$.o\$\$\$ \$\$"o\$" \$\$ \$\$ \$\$ `\$\$ \$\$. \$o.\$\$ \$\$ \$\$ \$\$ \$\$ \$\$. \$\$ \$' \$'.o\$\$\$\$' `\$\$\$\$\$\$o.' \$\$ \$' \$' \$\$ \$\$\$" `\$ \$' \$' \$'    "Newskool" style

Due to the fairly large character set including lots of @@@ characters, my auto-generated Mandelbrot imaging algorithm usually produces output more like the Newskool style. However, as seen in the second Mandelbrot image example above, straight lines often produce _ and / characters that are reminiscent of the Oldskool style.

revisions: 19990203 oldest on record; 20100128 update formatting to RHTF, add examples, add classic ASCII art; 20120411 Fix erroneous substitution

From the Mandelbrot Set Glossary and Encyclopedia, by Robert Munafo, (c) 1987-2024.

This page was written in the "embarrassingly readable" markup language RHTF, and was last updated on 2023 Jul 03. s.27