Advertisement
nik1111

utill

May 19th, 2022
667
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --
  2. -- Created by Grcpils
  3. -- 03/14/2021
  4. -- Github: https://github.com/grcpils/cc-gui_api
  5. -- Please do not delete this header ;)
  6. --
  7.  
  8. local drawCustomShape = function (xmin, xmax, ymin, ymax, progress)
  9.     for cY = ymin, ymax do
  10.         for cX = xmin, progress do
  11.             if cX <= xmax and cY <= ymax then
  12.                 GUI_MONITOR.setCursorPos(cX, cY)
  13.                 GUI_MONITOR.write(" ")
  14.             end
  15.         end
  16.     end
  17. end
  18.  
  19. local drawShapeOut = function (shape)
  20.     for cY = shape.ymin, shape.ymax do
  21.         for cX = shape.xmin, shape.xmax do
  22.             GUI_MONITOR.setCursorPos(cX, cY)
  23.             if cY == shape.ymin or cY == shape.ymax then
  24.                 GUI_MONITOR.write(" ")
  25.             elseif cX == shape.xmin or cX == shape.xmax then
  26.                 GUI_MONITOR.write(" ")
  27.             end
  28.         end
  29.     end
  30. end
  31.  
  32. local drawShape = function(shape)
  33.     for cY = shape.ymin, shape.ymax do
  34.         for cX = shape.xmin, shape.xmax do
  35.             GUI_MONITOR.setCursorPos(cX, cY)
  36.             GUI_MONITOR.write(" ")
  37.         end
  38.     end
  39. end
  40.  
  41. local getCoordonate = function(pos, size)
  42.     local ymin = math.floor(pos.x)
  43.     local xmin = math.floor(pos.y)
  44.     local ymax = math.floor((pos.x + size.h))
  45.     local xmax = math.floor((pos.y + size.w))
  46.     return xmin, xmax, ymin, ymax
  47. end
  48.  
  49. local printInfo = function(s,...)
  50.     term.setTextColor(colors.white)
  51.     return io.write(s:format(...))
  52. end
  53.  
  54. local printErr = function(s,...)
  55.     term.setTextColor(colors.red)
  56.     return io.write(s:format(...))
  57. end
  58.  
  59. local printWarn = function(s,...)
  60.     term.setTextColor(colors.orange)
  61.     return io.write(s:format(...))
  62. end
  63.  
  64. local clearAll = function()
  65.     GUI_MONITOR.clear()
  66. end
  67.  
  68. return {
  69.     printErr = printErr,
  70.     printInfo = printInfo,
  71.     printWarn = printWarn,
  72.     getCoordonate = getCoordonate,
  73.     drawShape = drawShape,
  74.     drawShapeOut = drawShapeOut,
  75.     drawCustomShape = drawCustomShape,
  76.     clearAll = clearAll
  77. }
Advertisement
RAW Paste Data Copied
Advertisement