jig487

imageDrawer

Aug 27th, 2021 (edited)
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. local tArgs = {...}
  2.  
  3. local fileName = tArgs[1]
  4.  
  5. local mon = peripheral.find("monitor")
  6. local ar = peripheral.find("arController")
  7. local oldTerm = term.redirect(mon)    
  8. mon.setTextScale(0.5)
  9. mon.setCursorPos(1,1)
  10. mon.clear()
  11. term.setCursorPos(1,1)
  12. term.clear()
  13. ar.clear()
  14.  
  15.  
  16. local f, err = fs.open(fileName, "r")
  17. assert(f, err)
  18. local texData = textutils.unserialize(f.readAll())
  19. f.close()
  20.  
  21. local W = tArgs[2]--fileData.size.X
  22. local H = tArgs[3]--fileData.size.y
  23.  
  24. local pixelSize = tArgs[4]
  25.  
  26. print(W,H)
  27.  
  28. for y = 1, H do
  29.     for x = 1, W do
  30.         local col = texData[y * W + x]
  31.         if col == nil then
  32.             break
  33.         end
  34.         --print(string.format("%x", col))
  35.         ar.fill(x * pixelSize, y * pixelSize, (x+1) * pixelSize, (y+1) * pixelSize, col)
  36.         --os.sleep(0.1)
  37.     end
  38. end
Add Comment
Please, Sign In to add comment