Satisfying ascii animation with C 😉 - The doughnut shaped code that generates a spinning 🍩

preview_player
Показать описание
#shorts #satisfying #ascii_art #ascii
#animation #codeWithC #learnC

A Doughnut shaped code that generates a spinning doughnut 🍩 😎

More like this: Python Magic #1

Original author:
Рекомендации по теме
Комментарии
Автор

k;double sin()
, cos();main(){float A=
0, B=0, i, j, z[1760];char b[

){memset(b, 32, 1760);memset(z, 0, 7040)

>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&&

"., -~:;=!*#$@"[N>0?N:0];}}/*#****!!-*/






CodeRewind
Автор

People here can't seem to understand the point is the code is shaped is like a donut, it doesn't need to be clean

WindowsDrawer
Автор

People who don't understand programming will think that the shape of the code is the one that will give the shape of a donut 😂

Assem_DEV
Автор

I was about to comment "b e a n" because of the thumbnail, but now i shall say...

d o n u t

Memztroijan
Автор

the perfect line of code dosen't exi-

WhiteWallAh_
Автор

me thinking about code seriously a minute, with out knowing c language

smclwoq
Автор

A classic!

This is a PPM (Portable Pixel Map) animation program in C, written by John Hancock in 1986. It's a
simple raycasting-based 3D graphics demo that uses ASCII art to display the scene.

Here's a breakdown of what the code does:

1. Initialization: The program sets up some variables and arrays for storing pixel data.
2. Main loop: The program enters an infinite loop, where it repeatedly:
* Clears the screen using ANSI escape sequences (`\x1b[2J`).
* Sets up some mathematical constants (A, B, etc.).
* Calculates the sine and cosine of various angles (i, j, A, B) using simple trigonometric formula
formulas.
* Uses these calculations to determine the pixel values (D, l, m, n) for a 2D grid.
* Updates the pixel data array (z) and ASCII art string (b) based on the calculated values.
3. Output: The program prints the updated ASCII art using ANSI escape sequences (`\x1b[H`), followed
by the `putchar` function to display each line of text.

The animation is a simple, rotating 3D scene with some basic lighting and shading effects. The ASCII
art rendering gives the appearance of a 2D projection of the 3D scene onto a plane.

This code is a great example of the creativity and ingenuity that can be achieved with limited
resources (in this case, early computing technology and the ASCII character set). It's also a
testament to the enduring appeal of simple, yet engaging, graphical demonstrations.

hand-eye
Автор

My brain stopped working when I saw that code for a sec

rovrzoq
Автор

Thank you! This is amazing and WAY cool!

ForgottenMachines
Автор

🍩
wait.

the syntax is cleverly arranged as the donut _AND_ it's unreadable?

perfecto for beginners!! 🍩
or as my wise sensei would always say:

"donut try to code the donut, before you have mastered the tao-nut."

joey_yangyin
Автор

Can anyone explain how this code is not erroneous? There's no declaration of standard libraries and the k variable is declared in the wildest way possible

k_gold
Автор

bro this is just like boiling doughnuts to bake doughnuts out of it

HaoyuW
Автор

#include<stdio.h>
#include<stdlib.h>
#include<cstring>
#include<math.h>
int k;

temdemencia
Автор

THAT AINT DONUT THAT SHAPED LIKE TORUS

GroovyBall
Автор

"Why does you code this thing?"
"Donut"

BobChess
Автор

What software is this i wanna try it out

SodaCrack
Автор

I couldn't see wheres the loop codes

IndahxDragon-dtrn
Автор

Sometimes you can donut but sometimes you should-n't

nxone
Автор

Is C this messy or is it just a bunch of variables?

vincenteriksson
Автор

import math
import time
import os

def generate_donut_frame(A, B):
z = [0] * 1760
b = [' '] * 1760
for j in range(0, 628, 7):
for i in range(0, 628, 2):
c = math.sin(i / 100)
d = math.cos(j / 100)
e = math.sin(A)
f = math.sin(j / 100)
g = math.cos(A)
h = d + 2
D = 1 / (c * h * e + f * g + 5)
l = math.cos(i / 100)
m = math.cos(B)
n = math.sin(B)
t = c * h * g - f * e
x = int(40 + 30 * D * (l * h * m - t * n))
y = int(12 + 15 * D * (l * h * n + t * m))
o = x + 80 * y
N = int(8 * ((f * e - c * d * g) * m - c * d * e - f * g - l * d * n))
if 22 > y > 0 and 80 > x > 0 and D > z[o]:
z[o] = D
b[o] = "., -~:;=!*#$@"[N if N > 0 else 0]
return ''.join(b[i] if i % 80 else b[i] + '\n' for i in range(1760))

A = 0
B = 0

for _ in range(100): # Running for 100 frames
frame = generate_donut_frame(A, B)
os.system('cls' if os.name == 'nt' else 'clear')
print(frame)
A += 0.04
B += 0.02
time.sleep(0.03) # Adjust the sleep time to control the speed
#run this in python

RealGian