function f_iter(x,y)local real = ((x - 306) / 150)-0.5local imag = (y - 192) / 150local cx = reallocal cy = imaglocal newXlocal newYlocal it = 0while it < 61 donewX = (real * real - imag * imag) + cxnewY = (2 * real * imag) + cyreal = newXimag = newYif real * real + imag * imag > 64 then break endit = it + 1endreturn itend
function fract()sim.createBox(4,4,607,379,125)pid = 1for px=4, 607, 1 dofor py = 4, 379, 1 dolocal pid= sim.partID(px,py)--sim.partCreate(px,py,125)local its = f_iter(px,py)--local pid= sim.partID(px,py)--print(pid)sim.partProperty(pid,sim.FIELD_CTYPE,2^(its/2))pid = pid+1endendend