Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Created November 10, 2020 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterhellberg/838e5d86b0cc1ab7de1e77ec99b60ccb to your computer and use it in GitHub Desktop.
Save peterhellberg/838e5d86b0cc1ab7de1e77ec99b60ccb to your computer and use it in GitHub Desktop.
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)
}
}
@peterhellberg
Copy link
Author

@peterhellberg
Copy link
Author

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