From 8319d127a552e4d67bd708fdf85ff3ea00f1d985 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 11 May 2023 21:23:10 +0300 Subject: [PATCH] initial commit --- README.md | 3 +++ donut | Bin 0 -> 16440 bytes donut.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 README.md create mode 100755 donut create mode 100644 donut.c diff --git a/README.md b/README.md new file mode 100644 index 0000000..77ab433 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Spinning donut + +Source: https://www.a1k0n.net/2011/07/20/donut-math.html diff --git a/donut b/donut new file mode 100755 index 0000000000000000000000000000000000000000..2d27b1dca7ed4595a0321bc99db0313a177b58a3 GIT binary patch literal 16440 zcmeHOZ**Km6`$QUkYd~2mKFmAx%8^;ZTGlaPTNvKM3UroC*io{xK=l4{7CS@PkGKPht^Ei#9-I{oR?lFT2kK z(GTK>opav1bN~GA%-lCKJM;F<*8;)yPKQHqnj*d=i0gGLiBBtbuhbb3pI9ko;C`++ zN1OtFs+1|cPZ4NU8giD>N-duPO1LV@OhC_8V!@PaNR)7srLCtb4O5}pLAVN1Y2Hq6 zJx$@5vfe7sqx8Z?gJgijv=~RR8LE+LF|?|bcI&wGYRWib2{)o~BO1r_s4kBw$CF}0 z*Ge5vJM}?F$tUkZ*m2z&XQ%75JyR-!(#E$^k^iQ=dX4M$NH@Yx7b&q|%H>@P9L436 zCVtEtba|6KhiV;vraHW0aa*iu#qz~%k(#zxysNvWd*zCn70bQJ4(}zh3RJHpxTsHE zdG#jY>=k*EG2S5@lAi_{C8y?DPquS#QP>IpP}{a!?myfge4u^WgR@@!$A;H-9GONo z)DFUs4JDG%#ffx$vFwx3TVXVN0z-2WIhEm=!2YU9?0Y7We{&M~`bp&HK<>e1Pt-p= zb|LtBT<1?97iMikof(NHqAjsxDw=4hTiezVk2Zvw+M>cVTiQF~W-=8@q)bzpPH32n z#hXRABiRf{xI1Jv$Ks*3*zM#2{U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6^qQFeGn_)UrkOUyoVYak&G=2#F5)n(H_C>jGxr>UDIK zVO`_Z{<_+=5Mxd@1BTWb>oy4U%HTC?{6X`Y_3JkV8q5a&nqa`>a|=E`e?Vsu{^fLo zrNx>@ZtH@dzCNsl5hPkyza9N=75%s->t& zJR%afMH4FSz&9n6+Lt`xp{ssdERt%47AHz{&^udWR)giSlL^m~Y(OC;he%3lFCVZF z-egaED%1p;N+{aOIh-PiCOU;zcG8x3m$x&~(HTvodWu9%T``Ye=ef+E2cV{24$+! z>kOv6e${Ge%Xy*~;G#7n<5y}tQy+B2iPw`XTY*e5zFXs&E?`4Vd7fl(tqsrXB&HrV z)YOi@9&&sY(82ZRbvaXRzg`Yo>v(n>LWb7ljOTSb(@F|1619=C+6!D)l6xfNQvvuc1-Vrj@InV^SYhsRstjOGvfLysSr72D5i|( zeFM|HHstad&+Y%V#;?(Kyboc@`xe5}Ud4|8E@TuF_HX@u>EAKlpTR^X`}2Pc(qgHm;q&+Z>9sbyc=XDoT-hZ;az5YMZc#gmDXiH5wep+h9 zkNKC7q4qPr+oLp07b(`d+sl6ynqvG;k1}QYeG92F{QOw_D`aNk(!<``5AZovyFK$v ze-Esy2+!y6hHD^1Vmrl+^DI9C1@#>+pZ5iP?wHRPQ~#&LIDU@rK}PLoJfG_uT1?jJ ze^r%Jcg8b)AL3%X@M-HMiZZLER{4x~0$hyuX@F1Txt?~s#RE*fxc 0) { + if (ooz > zbuffer[yp][xp]) { + zbuffer[yp][xp] = ooz; + int luminance_index = L*8; + output[yp][xp] = ".,-~:;=!*#$@"[luminance_index]; + } + } + } + } + + printf("\x1b[H"); + for (int j = 0; j < screen_height; j++) { + for (int i = 0; i < screen_width; i++) { + putchar(output[i][j]); + } + putchar('\n'); + } +} + +int main() { + float A = 0; + float B = 0; + while (1) { + render_frame(A, B); + A += 0.04/20; + B += 0.02/20; + } +}