Advertisement
klindley

ellipsev3

Jan 17th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. --local co = require("coroutine")
  2. local world = require("component").debug.getWorld()
  3.  
  4. local orig_x, orig_y, orig_z, height, width, height2, block_id, block_meta, filled = ...
  5. local a2, b2, fa2, fb2, x, y, zigma
  6.  
  7. orig_x = tonumber(orig_x)
  8. orig_y = tonumber(orig_y)
  9. orig_z = tonumber(orig_z)
  10. height = tonumber(height)
  11. height2 = tonumber(height2)
  12. width = tonumber(width)
  13. block_id = tonumber(block_id)
  14. block_meta = tonumber(block_meta)
  15. filled = tonumber(filled)
  16.  
  17. function setpixel(x, y, z)
  18. world.setBlock(x, y, z, block_id, block_meta)
  19. end
  20.  
  21. function setline(x1, y1, z1, x2, y2, z2)
  22. world.setBlocks(x1, y1, z1, x2, y2, z2, block_id, block_meta)
  23. end
  24.  
  25. a2 = width * width
  26. b2 = height * height
  27. fa2 = 4 * a2
  28. fb2 = 4 * b2
  29.  
  30.  
  31. z = height2 - 1
  32. x = 0
  33. y = height
  34. sigma = 2 * b2+a2*(1-2*height)
  35. print(z, height)
  36.  
  37.  
  38. -- first half
  39. while b2*x <= a2*y do
  40. -- setline(orig_x + x, orig_y, orig_z + y, orig_x - x, orig_y, orig_z - y)
  41. if (filled == 1) then
  42. setline(orig_x + x, orig_y+z, orig_z - y, orig_x + x, orig_y+z, orig_z + y)
  43. setline(orig_x - x, orig_y+z, orig_z - y, orig_x - x, orig_y+z, orig_z + y)
  44. else
  45. setline(orig_x + x, orig_y, orig_z + y, orig_x + x, orig_y+z, orig_z + y)
  46. setline(orig_x + x, orig_y, orig_z - y, orig_x + x, orig_y+z, orig_z - y)
  47. setline(orig_x - x, orig_y, orig_z + y, orig_x - x, orig_y+z, orig_z + y)
  48. setline(orig_x - x, orig_y, orig_z - y, orig_x - x, orig_y+z, orig_z - y)
  49. end
  50.  
  51. if (sigma >= 0) then
  52. sigma = sigma + (fa2 * (1-y))
  53. y = y-1
  54. end
  55. sigma = sigma + (b2 * ((4 * x) + 6))
  56. x = x + 1
  57. end
  58.  
  59. x = width
  60. y = 0
  61. sigma = 2*a2+b2*(1-2*width)
  62.  
  63. while (a2*y <= b2*x) do
  64. if (filled == 1) then
  65. setline(orig_x + x, orig_y+z, orig_z + y, orig_x - x, orig_y+z, orig_z + y)
  66. setline(orig_x + x, orig_y+z, orig_z - y, orig_x - x, orig_y+z, orig_z - y)
  67. else
  68. -- setline(orig_x + x, orig_y+z, orig_z + y, orig_x - x, orig_y+z, orig_z + y)
  69. setline (orig_x + x, orig_y+z, orig_z + y, orig_x + x, orig_y, orig_z + y)
  70. setline (orig_x + x, orig_y+z, orig_z - y, orig_x + x, orig_y, orig_z - y)
  71. -- setline(orig_x + x, orig_y, orig_z - y, orig_x - x, orig_y, orig_z - y)
  72. setline (orig_x - x, orig_y+z, orig_z + y, orig_x - x, orig_y, orig_z + y)
  73. setline (orig_x - x, orig_y+z, orig_z - y, orig_x - x, orig_y, orig_z - y)
  74. end
  75.  
  76. if (sigma >= 0) then
  77. sigma = sigma + (fb2 * (1 - x))
  78. x = x - 1
  79. end
  80.  
  81. sigma = sigma + (a2 * ((4 * y) + 6))
  82.  
  83. y = y + 1
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement