]> git.proxmox.com Git - ceph.git/blob - ceph/src/civetweb/src/third_party/duktape-1.8.0/examples/coffee/mandel.coffee
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / civetweb / src / third_party / duktape-1.8.0 / examples / coffee / mandel.coffee
1 mandel = (x0, y0, x1, y1, w, h, maxiter) ->
2 [dx, dy] = [(x1 - x0) / w, (y1 - y0) / h]
3 res = []
4
5 y = y0
6 for yc in [0..h-1]
7 x = x0
8 for xc in [0..w-1]
9 [xx, yy] = [x, y]
10 c = '*'
11 for i in [0..maxiter-1]
12 # (xx+i*yy)^2 + (x+i*y) = xx^2 + i*2*xx*yy - yy^2 + x + i*y
13 # = (xx^2 - yy^2 + x) + i*(2*xx*yy + y)
14 [xx2, yy2] = [xx*xx, yy*yy]
15 if xx2 + yy2 >= 4.0
16 c = '.'
17 break
18 [xx, yy] = [xx2 - yy2 + x, 2*xx*yy + y]
19 res.push(c)
20 x += dx
21 res.push('\n')
22 y += dy
23
24 print(res.join(''))
25 return
26
27 mandel(-2, 2, 2, -2, 200, 100, 1000)
28