Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor = peripheral.wrap("top")
- monitor.clear()
- mw,mh = monitor.getSize()
- function scale(x,y)
- x0 = (3.5 * (x-1) / mw) - 2.5
- y0 = (2 * (y-1) / mh) - 1
- return x0,y0
- end
- function getColor(iter)
- if iter == 0 then
- return colors.black
- end
- return colors.white
- -- return bit.blshift(iter%100,1)
- end
- for i = 1,mw do
- for j = 1,mh do
- x0,y0 = scale(i,j)
- x = 0
- y = 0
- iter = 0
- maxIter = 1000
- while x*x + y*y < 2*2 and iter < maxIter do
- xTemp = x*x - y*y + x0
- y = 2*x*y
- x = xTemp
- iter = iter + 1
- end
- bgColor = getColor(iter)
- monitor.setBackgroundColor(bgColor)
- monitor.setCursorPos(j,i)
- monitor.write(" ")
- sleep(.1)
- end
- end
Add Comment
Please, Sign In to add comment