Advertisement
CaptainSpaceCat

DrawUtils

Jun 9th, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. local termW, termH = term.getSize()
  2. function drawRelevantImage(img, xPos, yPos)
  3.         for i, v in pairs(img) do
  4.                 for k, e in pairs(v) do
  5.                         if i + yPos - 1 >= 1 and i + yPos - 1 <= termH and k + xPos - 1 >= 1 and k + xPos - 1 <= termW then
  6.                                 term.setCursorPos(k + xPos - 1, i + yPos - 1)
  7.                                 term.setBackgroundColor(e)
  8.                                 term.write(" ")
  9.                         end
  10.                 end
  11.         end
  12. end
  13.  
  14. function drawRelevantImage(img, xPos, yPos)
  15.     local termW, termH = term.getSize()
  16.     if yPos > 0 then yTest = false else yTest = true end
  17.     if yPos + #img <= termH then yTest2 = false else yTest2 = true end
  18.     if xPos > 0 then xTest = false else xTest = true end
  19.     if xPos + #img[1] <= termW then xTest2 = false else xTest2 = true end
  20.         for i = yTest and 1 - yPos or 1, yTest2 and termH - yPos or #img do
  21.                 for k = xTest and 1 - xPos or 1, xTest2 and termW - xPos or #img[1] do
  22.                         term.setCursorPos(k + xPos - 1, i + yPos - 1)
  23.                         term.setBackgroundColor(img[i][k])
  24.                         term.write(" ")
  25.                 end
  26.         end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement