Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local fs = require("filesystem")
- local gpu = component.gpu
- local shell = require("shell")
- local unicode = require("unicode")
- local w, h = 30, 15
- local iw, ih = w*2, h*4
- local ow, oh = gpu.getResolution()
- local brailleindex = {{0x1,0x8},{0x2,0x10},{0x4,0x20},{0x40,0x80}}
- local idfk = 0
- local btn = {[false] = 0, [true] = 1}
- local frames = {}
- local framepath = shell.resolve("./frames")
- gpu.setResolution(w, h)
- local frame = 1
- for file in fs.list(framepath) do
- frames[frame] = file
- frame = frame + 1
- end
- table.sort(frames)
- for frame,file in ipairs(frames) do
- local framefile = fs.open(framepath.."/"..file)
- frames[frame] = framefile:read(math.huge)
- framefile:close()
- --print(frame,file)
- end
- print(frames[1])
- local framecount = frame
- function generatePattern()
- local outputstr = ""
- for y=0, h-1 do
- for x=0, w-1 do
- local c = 0
- for sy=0, 3 do
- for sx=0, 1 do
- local i = brailleindex[sy+1][sx+1]
- local tx, ty = x * 2 + sx, y * 4 + sy
- local pixelindex = math.floor(((tx % iw) + (ty * ih)) / 8) + 1
- local p = (string.byte(frames[idfk+1],pixelindex)>>((tx-(ty%2*4)-1)%8))%2
- --print(pixelindex,p)
- c = c + p * i
- end
- end
- outputstr = outputstr .. unicode.char(0x2800+c)
- end
- end
- return outputstr
- end
- io.write("\n")
- while true do
- io.write(generatePattern().."\n")
- idfk = idfk + 1
- idfk = idfk % (framecount-1)
- if event.pull(0.05, "interrupted") == "interrupted" then
- gpu.setResolution(ow, oh)
- return
- end
- --os.sleep(1/15)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement