ASCII Graphics
Robert P. Munafo, 2010 Jan 28.
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
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 pixels values sum character
* * 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:
: ./tc -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
: ./tc 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,,./@)-')-`\` .,'`-, .- /` -` .~ a~ -_-'("F@b@@C^/ ,`, `. `-- ,~` .~ /` r` ., -',\T@@@@F.-`. ` - _-` .' ./ .- ., ^~YF`\-\ `- `. - -` - .~ a` ' .~ , c - ~, ~, `-, .'` a~ :` ' . -, ~ '-, .- .` .- .` ' -, ` .-- .` ' : , -, ' ` ` ` -1.999095831 +0.000000000 i @ 0.000 nmax 1374 gridsize 350x350
: ./tc -0.6763208 0.3077812 0.0051198 -nmax 20000 -ascii -grid 350 @@@@@@@@CYF*Y@@@@b:m@b_ '**@@Y@@@@@@@@@@@@@@@@@@@FF@$FY@@F..me__-__,. @*Y@b@%*F($@@@@@Ca@@@@@, ` ""@@@@@@@@@@@@@F@@*%@@@@@@C@@d@@@@bm@@@@ '*@@@" :d@@@@@@@@@YF*@" :b@@@@@@@@@@@@@@@db^@@@@@@@@@@@@@@@@@^(% "^` ^"Y@@@@@@b_ ''*"YFT@@^$@@@@@@*;-**@@@@@@@@F^^L^)/@@ m@Y@Y@/`` ^ ^@@@@@@@F" ````'"^^`/@@@@@@@ ` ^ .__ __,, '"""*^"*` /m,m@bam@m(@@@@@@@$ v@@`_, .mam@@F^ __., _^@@@@@@@@@LF@@@bL, ._d@@@@@.d@@@@@@L .mem@@@` '@@@@@@@@@C@@L$@@@@F me_ '*@@@@F@e7@@@@@L.a@@@@@@@@m, $@@@@@@@@@@@@Y@dT Y@@ _me@@@@@@@@b@dbmF@@@@@@@@dm,:d@@@@@@@@_,` 'Y` '` .,_me.m@@@@@@@@@@@@@@$b@@@@@@Y@YF` *Y(@@@@@@@c_ _, '*@@@@@@@@@@@@@@@@@@@@@@@m@@F:mmm@mmLd*@@YC@@@@T* -_@@@@@@@@@@@@@@@@@@@@@@C$**:@@@@@@@@@bmem@@@@@"^ mbad, '%@@@@@@@@@@@@@@bC@@dC@@@@@@@@@@@@@@@@@LY@@@__` @@@b_ , '**Y@@@@@@@@@@@@@@@@Y@@@@@@@@@@*** "F@@@bFC"" @@@@@mbb ./@@@@@@@@@@@@@@FY@@@@C^` 'T* 'Y@@C~ @F@@@@@@d[ "*""(@@@@@@@@C@@]@@@@@L___ (L^ @@@@b^^'*" -dbdb@@@@@@@@@@@(*@@@@@@C ]` -*@@^` -am@@@@@@@@^mC@bd@@L@d@@@@b, . '^ -*@@@@@@@@@^@@@@@@bF$@@@@@@_a,_, ___- ,._,_,m,a, ^"F"@@@@e-*@@@@@@c*@@@@@@@@@bd@@d* @m@@@@@@@%_ .., 'Y*"'. ^^^,^^a.d^T@@**%%@FF@\ @@@@@@@@@@@Ld@mmba, :@L:m@c:@@@@mmc_@@@@@@@` @Y@@@@@@@@@@@@@@^^ __a%@@@@@@@@@@@@@~@@@@%^`* @b@@@@@@@@Y@b$mL_, .$@@@@@@@@@@@b@@@@@@C@@@m- @Y@@*Y$d@@[@@@@@@b_ -@@@@@@@@@@@@@@@@@*@@@@\` mmm:@@@@@@$Y@@Y@@*Yc **@@@@@@@@d@^^"^ '"; @@@@@@@@@@@.%%:"^ .ab@@@@@@@@@@@@c ' @*^***@@@@\d@@dddm- ^Y@@@Y@@@@@@@@@@m_,m- ^ ^^^^'^^^^^^^^^ '^^ ^^^ `'^^^^^^` -0.67632 +0.30778 i @ 0.005 nmax 20000 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.
From the Mandelbrot Set Glossary and Encyclopedia, by Robert Munafo. Mu-ency index
Robert Munafo's home pages on HostMDS (c) 1996-2010 Robert P. Munafo. about contact
This work is licensed under a Creative Commons Attribution 2.5
License. Details here
s.13