I had no idea that printing something like "\x1b[2J\x1b[H" can clear the screen - with a bit of googling I found out that this is not that unusual a command, but it still took a little reading to figure it out! [1]
Looks like the rest of the code is for generating the donut. Quite a bit of math involved - too much for a sunday morning to look into and attempt to decipher!
Those are so-called ANSI terminal escape sequences - there is a whole list of them. Hex 1B is the escape character, the characters after that determine the action (clearing the screen, changin text color, moving the cursor etc.) Well, and "[2J" is the sequence for clearing the screen.
<ESC>[H ("home") moves the cursor to the upper-left hand corner, so I initially clear the screen and then use "home" to do the animation.
An alternative method to animate ascii stuff, used in the Yahoo logo, is just to cursor-up 25 lines (or whatever) with <ESC>[25A between frames. That way it doesn't have to clear the screen and you can see your command history, etc.
Looks like the rest of the code is for generating the donut. Quite a bit of math involved - too much for a sunday morning to look into and attempt to decipher!
[1] http://www.codeguru.com/forum/archive/index.php/t-311110.htm... explains it quite well:
Those are so-called ANSI terminal escape sequences - there is a whole list of them. Hex 1B is the escape character, the characters after that determine the action (clearing the screen, changin text color, moving the cursor etc.) Well, and "[2J" is the sequence for clearing the screen.