Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local image = false
- function ParseNFT(lines)
- local pixels = {}
- for y, line in ipairs(lines) do
- local bgNext, fgNext = false, false
- local currBG, currFG = nil,nil
- local writePosition = 1
- for x = 1, #line do
- if not pixels[writePosition] then
- pixels[writePosition] = {}
- end
- local nextChar = string.sub(line, x, x)
- if nextChar:byte() == 30 then
- bgNext = true
- elseif nextChar:byte() == 31 then
- fgNext = true
- elseif bgNext then
- currBG = getColourOf(nextChar)
- if currBG == nil then
- currBG = colours.transparent
- end
- bgNext = false
- elseif fgNext then
- currFG = getColourOf(nextChar)
- fgNext = false
- else
- if nextChar ~= " " and currFG == nil then
- currFG = colours.white
- end
- pixels[writePosition][y] = {BackgroundColour = currBG, TextColour = currFG, Character = nextChar}
- writePosition = writePosition + 1
- end
- end
- end
- return pixels
- end
- function loadImage(imgfile)
- local file = fs.open(imgfile,"r")
- local _layers = textutils.unserialise(file.readAll())
- file.close()
- local layers = {}
- for i, l in ipairs(_layers) do
- local daPixels = ParseNFT(l.Pixels)
- print(daPixels[1][1].BackgroundColour)
- end
- end
- loadImage("tests/kate")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement