Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local downHeight = 80
- local screen = peripheral.wrap(args[1])
- screen.setTextScale(0.5)
- screen.width, screen.height = screen.getSize()
- screen.width = screen.width-1
- screen.height = screen.height-1
- local zc = string.byte("0")
- local ac = string.byte("a")
- local cindex = {}
- cindex[zc] = colors.white
- cindex[zc+1] = colors.orange
- cindex[zc+2] = colors.magenta
- cindex[zc+3] = colors.lightBlue
- cindex[zc+4] = colors.yellow
- cindex[zc+5] = colors.lime
- cindex[zc+6] = colors.pink
- cindex[zc+7] = colors.gray
- cindex[zc+8] = colors.lightGray
- cindex[zc+9] = colors.cyan
- cindex[ac] = colors.purple
- cindex[ac+1] = colors.blue
- cindex[ac+2] = colors.brown
- cindex[ac+3] = colors.green
- cindex[ac+4] = colors.red
- cindex[ac+5] = colors.black
- local file = fs.open("/disk/images/"..args[2], "r")
- local image = {}
- image.width = tonumber(file.readLine())
- image.height = tonumber(file.readLine())
- image.data = file.readLine()
- file.close()
- function draw(sx, sy, iy)
- for j = 0, image.height-iy-1 do
- for i = 0, image.width-1 do
- local pixel = string.byte(image.data, (j+iy)*image.width+i+1)
- local color = cindex[pixel]
- paintutils.drawPixel(i+sx+2, j+sy+2, color)
- end
- end
- end
- local pane = #args >= 3 and args[3] or "down"
- local sx = (screen.width-1-image.width)/2
- local sy = nil
- local iy = nil
- if pane == "down" then
- sy = 0
- iy = image.height - downHeight
- else
- sy = screen.height - image.height + downHeight
- iy = 0
- end
- term.redirect(screen)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- draw(sx, sy, iy)
- term.restore()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement