Created
November 10, 2020 12:48
-
-
Save peterhellberg/838e5d86b0cc1ab7de1e77ec99b60ccb to your computer and use it in GitHub Desktop.
Simplified version of https://github.com/Vlad-Shevliakov/ASCII-render
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
package main | |
import ( | |
"math" | |
"time" | |
) | |
func main() { | |
delay := 16 * time.Millisecond | |
coreString := ".,-~:;=!*#$@" | |
A := float64(0) | |
B := float64(0) | |
var i, j float64 | |
var k int | |
z := make([]float64, 1760) | |
b := make([]string, 1760) | |
print("\033[H\033[2J") // clear previous stdout | |
for { | |
for i := range b { | |
b[i] = " " | |
} | |
for i := range z { | |
z[i] = 0 | |
} | |
for j = 0; j < 6.28; j += 0.07 { | |
for i = 0; i < 6.28; i += 0.02 { | |
c := math.Sin(i) | |
d := math.Cos(j) | |
e := math.Sin(A) | |
f := math.Sin(j) | |
g := math.Cos(A) | |
h := d + 2 | |
D := 1 / (c*h*e + f*g + 5) | |
l := math.Cos(i) | |
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 := int(x + 80*y) | |
N := int(8 * ((f*e-c*d*g)*m - c*d*e - f*g - l*d*n)) | |
if y < 22 && y > 0 && x > 0 && x < 80 && D > z[o] { | |
point := 0 | |
if N > 0 { | |
point = N | |
} | |
z[o] = D | |
b[o] = string(coreString[point]) | |
} | |
} | |
} | |
print("\x1b[H") | |
for k = 0; k < 1761; k++ { | |
v := "\n" | |
if k%80 > 0 { | |
v = string(b[k]) | |
} | |
print(v) | |
A += 0.00004 | |
B += 0.00002 | |
} | |
time.Sleep(delay) | |
} | |
} |
Reduced file size by removing use of fmt
(From 2.1 MB to 1.3 MB when using 1.15.4
under macOS
)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original Go code: https://github.com/Vlad-Shevliakov/ASCII-render
Original C code: https://www.dropbox.com/s/79ga2m7p2bnj1ga/donut_deobfuscated.c?dl=0