Marlingaming

Image Drawer

Sep 21st, 2021 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. --this program is used to draw Images from given files to the given cords
  2. --X, Y, File
  3. term.clear()
  4. local tArg = {...}
  5. local X = tArg[1]
  6. local Y = tArg[2]
  7. local TargetFile = tArg[3]
  8. local i = 2
  9. local Dimensions = {0,0}
  10. local Colors = {colors.white,colors.gray,colors.black,colors.green,colors.blue,colors.purple,colors.red,colors.orange,colors.yellow}
  11. local x = 1
  12. local y = 1
  13. local h = fs.open(TargetFile,"r")
  14.  
  15. local DimensionLine = h.readLine(1)
  16. Dimensions[1] = string.sub(DimensionLine,1,1)
  17. Dimensions[2] = string.sub(DimensionLine,3,3)
  18. Dimensions[1] = tonumber(Dimensions[1])
  19. Dimensions[2] = tonumber(Dimensions[2])
  20.  
  21.  
  22.  
  23.  
  24. local PixLines = h.readLine(2)
  25. for i = 1, (Dimensions[1] * Dimensions[2]) do
  26. local Pix = string.sub(PixLines,x,x)
  27. paintutils.drawPixel(((X-1)+x),((Y-1)+y),Colors[tonumber(Pix)])
  28. if x < Dimensions[1] then
  29. x = x + 1
  30. else
  31. x = 1
  32. y = y + 1
  33. PixLines = h.readLine(y+1)
  34. end
  35. end
  36.  
  37. h.close()
Add Comment
Please, Sign In to add comment