Guest User

Untitled

a guest
Jan 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. monitor = peripheral.wrap("top")
  2. monitor.clear()
  3. mw,mh = monitor.getSize()
  4.  
  5. function scale(x,y)
  6.  
  7. x0 = (3.5 * (x-1) / mw) - 2.5
  8. y0 = (2 * (y-1) / mh) - 1
  9. return x0,y0
  10. end
  11.  
  12. function getColor(iter)
  13. if iter == 0 then
  14. return colors.black
  15. end
  16. return colors.white
  17. -- return bit.blshift(iter%100,1)
  18. end
  19.  
  20. for i = 1,mw do
  21. for j = 1,mh do
  22.  
  23. x0,y0 = scale(i,j)
  24.  
  25. x = 0
  26. y = 0
  27.  
  28. iter = 0
  29. maxIter = 1000
  30.  
  31. while x*x + y*y < 2*2 and iter < maxIter do
  32.  
  33. xTemp = x*x - y*y + x0
  34. y = 2*x*y
  35. x = xTemp
  36.  
  37. iter = iter + 1
  38.  
  39. end
  40.  
  41. bgColor = getColor(iter)
  42.  
  43. monitor.setBackgroundColor(bgColor)
  44. monitor.setCursorPos(j,i)
  45. monitor.write(" ")
  46. sleep(.1)
  47. end
  48. end
Add Comment
Please, Sign In to add comment