Advertisement
infiniteblock

Untitled

Apr 14th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. local bigfont = require("bigfont")
  2.  
  3. local gfx = {}
  4.  
  5. function gfx.drawHeader(t, text)
  6. t.setTextColour(colours.white)
  7. bigfont.writeOn(t, 1, text, nil, 2)
  8. end
  9.  
  10. function gfx.drawFooter(t, text)
  11. local w, h = t.getSize()
  12. t.setTextColour(colours.grey)
  13. gfx.writeCentred(t, w, text, h)
  14. end
  15.  
  16. function gfx.writeCentred(t, w, text, y)
  17. t.setCursorPos(math.ceil((w - #text) / 2), y)
  18. t.write(text)
  19. end
  20.  
  21. function gfx.colourToBlit(col)
  22. return string.format("%x", math.log(col, 2))
  23. end
  24.  
  25. function gfx.drawLoading(t)
  26. local w, h = t.getSize()
  27.  
  28. local centerY = math.ceil(h / 2)
  29. t.setTextColour(colours.lightGrey)
  30. gfx.writeCentred(t, w, "Loading...", centerY)
  31.  
  32. return centerY
  33. end
  34.  
  35. function gfx.clearLoading(t, centerY)
  36. t.setCursorPos(1, centerY)
  37. t.clearLine(0)
  38. end
  39.  
  40. function gfx.drawBox(t, x, y, w, h)
  41. t.setTextColour(colours.grey)
  42. t.setCursorPos(x, y)
  43. t.write("\156" .. ("\140"):rep(w - 2) .. "\148")
  44.  
  45. for i = y + 1, y + h - 1 do
  46. t.setCursorPos(x, i)
  47. t.write("\149" .. (" "):rep(w - 2) .. "\149")
  48. end
  49.  
  50. t.setCursorPos(x, y + h)
  51. t.write(("\131"):rep(w - 1) .. "\129")
  52. end
  53.  
  54. return gfx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement