cc-stuff/btccslideshow.lua

48 lines
1.1 KiB
Lua
Raw Normal View History

2024-01-21 18:46:33 +03:00
local args = { ... }
local ccpi = require("ccpi")
local bigterm = require("bigterm")
local conf_path = "/bigterm.json"
if args[1] == "-c" then
table.remove(args, 1)
conf_path = table.remove(args, 1)
end
local screen = bigterm.fromFile(conf_path)
local time = 10
if args[1] == "-t" then
table.remove(args, 1)
time = tonumber(table.remove(args, 1))
end
local files = fs.list(args[1])
while true do
local img, err = ccpi.load(fs.combine(args[1], files[math.random(1, #files)]))
if not img then
printError(err)
return
else
local ys = {}
for y = 1, img.h do table.insert(ys, y) end
for i = 1, math.floor((#ys) / 2), 2 do
local a, b = i, (#ys - 1) - i + 1
ys[a], ys[b] = ys[b], ys[a]
end
for i, y in ipairs(ys) do
screen.setCursorPos(1, y)
screen.blit(img.lines[y].s, img.lines[y].fg, img.lines[y].bg)
if (i % 10) == 0 then
os.sleep(0)
end
end
for i = 1, 16 do
screen.setPaletteColor(bit.blshift(1, i - 1), img.palette[i])
end
end
os.sleep(time)
end