Advertisement
SuperMcBrent

drawLib

Jan 22nd, 2022
632
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Drawing Functions
  2. function drawTitle(x, y, text, color_txt, color_bg, monitor)
  3.     monitor.setBackgroundColor(color_bg)
  4.     monitor.setTextColor(color_txt)
  5.     monitor.setCursorPos(x,y)
  6.     monitor.write(text)
  7.     monitor.setCursorPos(1,1)
  8.     monitor.setBackgroundColor(colors.black)
  9. end
  10. function drawLine(x, y, length, size, color_bar, monitor)
  11.     for yPos = y, y+size-1 do
  12.         monitor.setBackgroundColor(color_bar)
  13.         monitor.setCursorPos(x, yPos)
  14.         monitor.write(string.rep(" ", length))
  15.         monitor.setBackgroundColor(colors.black)
  16.     end
  17. end
  18. function drawProg(x, y, length, size, minVal, maxVal, color_bar, color_bg, monitor)
  19.     drawLine(x, y, length, size, color_bg, monitor)
  20.     local barSize = math.floor((minVal/maxVal)*length)
  21.     drawLine(x, y, barSize, size, color_bar, monitor)
  22. end
  23. function drawContent(x, y, height, width, minVal, maxVal, color_bar, color_bg, monitor)
  24.     drawGraph(x, y, height, width, color_bg, monitor)
  25.     local a = math.floor((minVal/maxVal)*height)
  26.     drawGraph(x, y, a, width, color_bar, monitor)
  27. end
  28. function drawGraph(x, y, height, width, color_bar, monitor)
  29.     drawLine(x, y-height+1, width, height, color_bar, monitor)
  30. end
  31. function putTime(x,y,monitor,bool,color)
  32.     monitor.setBackgroundColor(color)
  33.     monitor.setCursorPos(x,y)
  34.     time = textutils.formatTime(os.time(), bool)
  35.     if os.time()<10.000 then monitor.write("0"..time) else monitor.write(time) end
  36.     monitor.setBackgroundColor(colors.black)
  37. end
  38. function clearBox(x,y,h,l,monitor,color)
  39.     monitor.setBackgroundColor(color)
  40.     for i = y, y + h - 1 do
  41.         monitor.setCursorPos(x,i)
  42.         monitor.write(string.rep(" ", l))
  43.     end
  44.     monitor.setBackgroundColor(colors.black)
  45. end
  46. function empty(monitor)
  47.     monitor.setBackgroundColor(colors.black)
  48.     monitor.clear()
  49.     monitor.setCursorPos(1,1)
  50. end
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement