A Donut in the Terminal

André — September 2, 2024

This project is inspired by the work of Andy Sloane, and relies heavily on the code written by Robert Moss. I translated his code from Julia to R.

I have recently seen donuts written in C, Python, JavaScript, and Julia. This made me wonder if R, a statistical programming language, could also be used to render such graphics. The answer seems to be yes! The code relies heavily on the cat() function to set the behavior of the donut in the terminal due to its ability to read what seems to be some standard notation formatIt seems to be an ANSI control sequence..

After downloading the code from GitHub, the donut can only be rendered by opening a terminal and requires Rscript to be a PATH variableAt least on Windows 11. On other operating systems, make sure that can be called from the terminal by running: Rscript --version.. Below is a short animation of the script running on my computer.

A (Slow) Rotating Donut

← Back to all posts

A Donut in the Terminal - September 2, 2024 - André