1 mandel = (x0, y0, x1, y1, w, h, maxiter) ->
2 [dx, dy] = [(x1 - x0) / w, (y1 - y0) / h]
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]
18 [xx, yy] = [xx2 - yy2 + x, 2*xx*yy + y]
27 mandel(-2, 2, 2, -2, 200, 100, 1000)