Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- if #tArgs < 1 then
- error("Usage: view <image filename>")
- end
- if not fs.exists(tArgs[1]) then
- error("Not an image file")
- end
- image = paintutils.loadImage(tArgs[1])
- local w, h = term.getSize()
- local imgW = 0
- local imgH = 0
- local imgWMax = 0
- for i, v in pairs(image) do
- imgH = imgH + 1
- imgW = 0
- for k, e in pairs(v) do
- imgW = imgW + 1
- if imgW < imgWMax then
- imgWMax = imgW
- end
- end
- end
- imgW = imgWMax
- term.setBackgroundColor(colors.black)
- term.clear()
- paintutils.drawImage(image, w / 2 - imgW / 2, h / 2 - imgH / 2 + 1)
- term.setCursorPos(1, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement