-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdonut.lua
More file actions
44 lines (39 loc) · 1.28 KB
/
donut.lua
File metadata and controls
44 lines (39 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
local A, B = 0, 0
while true do
local z = {}
local b = {}
for i = 0, 1760 do
z[i] = 0
b[i] = (i % 80 == 79) and "\n" or " "
end
for j = 0, 6.28, 0.07 do
for i = 0, 6.28, 0.02 do
local c = math.sin(i)
local d = math.cos(j)
local e = math.sin(A)
local f = math.sin(j)
local g = math.cos(A)
local h = d + 2
local D = 1 / (c * h * e + f * g + 5)
local l = math.cos(i)
local m = math.cos(B)
local n = math.sin(B)
local t = c * h * g - f * e
local x = math.floor(40 + 30 * D * (l * h * m - t * n))
local y = math.floor(12 + 15 * D * (l * h * n + t * m))
local o = x + 80 * y
local N = math.floor(8 * ((f * e - c * d * g) * m - c * d * e - f * g - l * d * n))
if 0 <= y and y < 22 and 0 <= x and x < 80 and D > z[o] then
z[o] = D
local lum = ".,-~:;=!*#$@"
b[o] = lum:sub(math.max(1, math.min(#lum, N + 1)), math.max(1, math.min(#lum, N + 1)))
end
end
end
io.write("\027[H") -- ANSI escape to go to top of screen
for i = 0, 1760 do
io.write(b[i])
end
A = A + 0.04
B = B + 0.02
end