Skip to content
/ donut Public

A mesmerizing ASCII art animation of a rotating donut rendered in your terminal, written in C.

License

Notifications You must be signed in to change notification settings

maty7253/donut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🍩 A fucking Donut

A mesmerizing ASCII art animation of a rotating donut rendered in your terminal, written in C. This program creates a 3D donut (torus) that rotates in space, using ASCII characters to create the illusion of depth and movement.

🔧 How It Works

The program uses mathematical principles to create a 3D rendering of a torus (donut shape) in ASCII art:

  1. Creates a rotating torus using parametric equations
  2. Projects 3D coordinates onto a 2D space
  3. Calculates lighting and shadows
  4. Renders the result using ASCII characters for different lighting levels
  5. Updates the display in real-time for animation

🚀 Installation

  1. Clone the repository:
git clone https://github.com/maty7253/donut.git
cd donut
  1. Compile the program:
gcc -o donut donut.c -lm

Usage

Run the compiled program:

./donut

To exit the program, press Ctrl+C.

Technical Details

The program uses several mathematical concepts:

  • Torus Generation: Uses parametric equations to generate points on a torus surface
  • 3D Rotation: Implements rotation matrices for 3D animation
  • Projection: Converts 3D coordinates to 2D screen space
  • Illumination: Calculates surface normals for basic lighting effects
  • ASCII Rendering: Maps brightness levels to ASCII characters

Key Variables

  • A and B: Rotation angles
  • i and j: Parameters for torus generation
  • z[]: Z-buffer for depth handling
  • b[]: Character buffer for ASCII output

License

This project is open source and available under the MIT License.

Acknowledgments

This implementation is inspired by the classic donut.c code by Andy Sloane, demonstrating the beauty of mathematical visualization through ASCII art.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

About

A mesmerizing ASCII art animation of a rotating donut rendered in your terminal, written in C.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages