This was transpiled completely from code and other links found on a1k0n.net.
Created
July 28, 2020 18:23
-
-
Save danii/cb550f402a6f4b80de8cf53184ea5625 to your computer and use it in GitHub Desktop.
Rust Donuts!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main(){let // 13/14 | |
mut a=0f32;let mut b= // 21/22 | |
0f32;print!("\x1b[2J");// // 25/25 | |
loop{let mut r=[' ';1760];let // 29/30 | |
mut z=[0f32;1760];let mut j=0f32;//- // 36/36 | |
while j<6.28{let mut i=0f32;while i< // 36/36 | |
6.28{let c=i.sin();let d=j.cos();let e // 38/38 | |
=a.sin();let f=j.sin();let g=a.cos();// // 39/38 | |
let h=d+2.;let p =1./(c*h*e+f*g+5. // 39/39 | |
);let l=i.cos(); let m=b.cos();// // 40/40 | |
let n=b.sin(); let t=c*h*g-f* // 40/40 | |
e;let x=(40.+30. *p*(l*h*m-t*n) // 40/40 | |
)as usize;let y =(12.+15.*p*(l* // 38/38 | |
h*n+t*m))as usize;let o=x+80*y;let q=( // 38/38 | |
8.*((f*e-c*d*g)*m-c*d*e-f*g-l*d*n))as // 37/38 | |
usize;if 22>y&&y>0&&x>0&&80>x&&p>z[0 // 36/36 | |
]{z[o]=p;r[o]=b".,-~:;=!*#$@"[if // 32/33 | |
q>0{q}else{0}]as char;}i+=0.02 // 30/30 | |
}j+=0.07;}print!("\x1b[H") // 26/26 | |
;let mut k=0usize;while // 23/22 | |
k<1761{print!( // 14/14 | |
//Oops, it went over.. I might have to do it with a bigger donut? | |
"{}",if k%80!=0{r[k]}else{'\n'});a+=0.00004;b+=0.00002;k+=1}std::thread::sleep(std::time::Duration::from_millis(30));}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut a = 0f32; | |
let mut b = 0f32; | |
print!("\x1b[2J"); | |
loop { | |
let mut r = [' '; 1760]; | |
let mut z = [0f32; 1760]; | |
let mut j = 0f32; | |
while j < 6.28 { | |
let mut i = 0f32; | |
while i < 6.28 { | |
let c = i.sin(); | |
let d = j.cos(); | |
let e = a.sin(); | |
let f = j.sin(); | |
let g = a.cos(); | |
let h = d + 2.; | |
let p = 1. / (c * h * e + f * g + 5.); | |
let l = i.cos(); | |
let m = b.cos(); | |
let n = b.sin(); | |
let t = c * h * g - f * e; | |
let x = (40. + 30. * p * (l * h * m - t * n)) as usize; | |
let y = (12. + 15. * p * (l * h * n + t * m)) as usize; | |
let o = x + 80 * y; | |
let q = (8. * ((f * e - c * d * g) * m - c * d * e - f * g - l * d * n)) as usize; | |
if 22 > y && y > 0 && x > 0 && 80 > x && p > z[o] { | |
z[o] = p; | |
r[o] = b".,-~:;=!*#$@"[if q > 0 {q} else {0}] as char; | |
} | |
i += 0.02; | |
} | |
j += 0.07; | |
} | |
print!("\x1b[H"); | |
let mut k = 0usize; | |
while k < 1761 { | |
print!("{}", if k % 80 != 0 {r[k]} else {'\n'}); | |
a += 0.00004; | |
b += 0.00002; | |
k += 1 | |
} | |
std::thread::sleep(std::time::Duration::from_millis(30)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On line 29, the if expression always evaluates to
q
sinceq
isusize
, so the program panics with index-out-of-bounds error. Instead,q
should beisize
and should be converted tousize
when used for indexing.