ASCII Art

Art is everywhere we look.

Take the internet, for example. From the minimalist design of this blog page, to the news articles we read and the memes we spend hours on Youtube watching. Wherever we go, whatever we make, we inject some amount of art into the environment. Most of us take this for granted, but good design helps our mental health tremendously, especially as people are spending more and more time on the internet.

But I’d like to focus your attention on one extraordinary example of this principle. Even in the black and white, rigidly structured environment of a terminal, people have managed to create art.

If you’re a CMU student, then you’ll have probably encountered this screen at some point:

You see it after logging into your AFS enviroment.

The first time I encountered this, in the middle of 15-122 recitation, I thought it was neat. I took a screenshot of it and told myself that I’d put it somewhere on my website eventually. And here we are.

But this post is more than just an excuse to share this ASCII rendering of the Scotty Shield. After looking into it more, it seems the world of ASCII art is much deeper than I could’ve imagined.

A very famous piece of ASCII art (at least for programmers) is the spinning donut. Credits go to Andy Sloane, who wrote the donut.c file below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
             k;double sin()
         ,cos();main(){float A=
       0,B=0,i,j,z[1760];char b[
     1760];printf("\x1b[2J");for(;;
  ){memset(b,32,1760);memset(z,0,7040)
  ;for(j=0;6.28>j;j+=0.07)for(i=0;6.28
 >i;i+=0.02){float c=sin(i),d=cos(j),e=
 sin(A),f=sin(j),g=cos(A),h=d+2,D=1/(c*
 h*e+f*g+5),l=cos      (i),m=cos(B),n=s\
in(B),t=c*h*g-f*        e;int x=40+30*D*
(l*h*m-t*n),y=            12+15*D*(l*h*n
+t*m),o=x+80*y,          N=8*((f*e-c*d*g
 )*m-c*d*e-f*g-l        *d*n);if(22>y&&
 y>0&&x>0&&80>x&&D>z[o]){z[o]=D;;;b[o]=
 ".,-~:;=!*#$@"[N>0?N:0];}}/*#****!!-*/
  printf("\x1b[H");for(k=0;1761>k;k++)
   putchar(k%80?b[k]:10);A+=0.04;B+=
     0.02;}}/*****####*******!!=;:~
       ~::==!!!**********!!!==::-
         .,~~;;;========;;;:~-.
             ..,--------,*/

which produces a spinning donut animation:

Crazy.

You’ve probably heard the explanation for how it works before, but in case you haven’t, this article explains it pretty well.

The techniques used to generate the donut animation are actually the same ones commonly used throughout computer graphics. However, what sets it apart is that it’s all done right in the terminal, with certain ASCII symbols corresponding to brightness values. I think it’s quite neat.

There’s thousands of examples of ASCII art on the internet. The most common technique is to just take an existing video and match the brightness values to ASCII characters, rather than generating the animation itself like in the donut animation. In fact, here’s a website dedicated to ASCII art.

If there’s one takeaway to be had from this post, I guess it’d be to appreciate how our artistic instincts can reach every corner of the known world, including the metaphysical world (the internet included). Even (or especially) in the dullest, most structured environments, art still shines through. And I think we should take a moment to appreciate that.

Because our terminals would be a lot emptier without art.




Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • Monte Carlo Options Pricing
  • D.E. Shaw Connect 2024
  • Convergence in $$\mathbb{R}^{2}$$