Advertisement
Marlingaming

Image Size Drawer

Apr 5th, 2022 (edited)
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. local tArg = {...}
  2.  
  3. local Path = tArg[1]
  4. local X = tArg[2]
  5. local Y = tArg[3]
  6. local Width = tArg[4]
  7. local Height = tArg[5]
  8.  
  9. function Resize()
  10. local TileSize = {1,1}
  11. local file = fs.open(Path,"r")
  12. local Content = file.readLine()
  13. local W = string.len(Content)
  14. TileSize[1] = Width/W
  15. local H = 1
  16. repeat
  17. Content = file.readLine()
  18. if Content ~= nil then H = H + 1 end
  19. until Content == nil
  20. TileSize[2] = Height/H
  21. file.close()
  22. local Doc = fs.open(Path,"r")
  23. local x = X
  24. local y = Y
  25. for i = 1, W * H do
  26. local X1 = x
  27. local Y1 = y
  28. local TileColor = Doc.read()
  29. for I = 1, TileSize[1] * TileSize[2] do
  30. paintutils.drawPixel(X1,Y1,TileColor)
  31. if X1 < TileSize[1] then
  32. X1 = X1 + 1
  33. else
  34. X1 = x
  35. Y1 = Y1 + 1
  36. end
  37. end
  38. if x < X + Width then
  39. x = x + TileSize[1]
  40. else
  41. x = X
  42. y = y + TileSize[2]
  43. end
  44. end
  45. Doc.close()
  46. end
  47.  
  48. Resize()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement