forked from svaarala/duktape
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmandel.lua
More file actions
41 lines (33 loc) · 815 Bytes
/
Copy pathmandel.lua
File metadata and controls
41 lines (33 loc) · 815 Bytes
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
-- Translated from tests/ecmascript/test-dev-mandel2-func.js.
function mandel()
local w = 80
local h = 40
local iter = 100
local i, j, k
local x0, y0, xx, yy, c, xx2, yy2
local res
for i=0,h-1 do
y0 = (i / h) * 4.0 - 2.0
res = {}
for j=0,w-1 do
x0 = (j / w) * 4.0 - 2.0
xx = 0
yy = 0
c = '#'
for k=0,iter-1 do
xx2 = xx*xx
yy2 = yy*yy
if xx2 + yy2 < 4.0 then
yy = 2*xx*yy + y0
xx = xx2 - yy2 + x0
else
c = '.';
break
end
end
table.insert(res, c)
end
print(table.concat(res))
end
end
mandel()