summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framebuf.lua13
-rw-r--r--john.lua4
2 files changed, 8 insertions, 9 deletions
diff --git a/framebuf.lua b/framebuf.lua
index 4f7ca3b..a19b7ee 100644
--- a/framebuf.lua
+++ b/framebuf.lua
@@ -166,14 +166,15 @@ local function get_char(fb, x, y)
return string.char(char), fg, bg
end
-function M.resolution()
- local w, h = term.getSize()
+function M.resolution(mon)
+ local w, h = mon.getSize()
return w * 2, h * 3
end
function M:present(offsx, offsy)
+ print("PrESENT")
offsx, offsy = offsx or 0, offsy or 0
- local w, h = term.getSize()
+ local w, h = mon.getSize()
local pw, ph = M.resolution()
local cols = {}
local chars = {}
@@ -191,11 +192,11 @@ function M:present(offsx, offsy)
print("","2")
local palette, map = median_cut(cols, 16)
for i, color in ipairs(palette) do
- term.setPaletteColor(2^(i - 1), color)
+ mon.setPaletteColor(2^(i - 1), color)
end
print("","3")
for i = 1, w * h, w do
- term.setCursorPos(1, (i - 1) / w)
+ mon.setCursorPos(1, (i - 1) / w)
local blit_char, blit_fg, blit_bg = {}, {}, {}
for i = i, i + w - 1 do
local char, fg, bg = unpack(chars[i])
@@ -203,7 +204,7 @@ function M:present(offsx, offsy)
table.insert(blit_fg, fg and hex_digits[map[fg]] or "1")
table.insert(blit_bg, bg and hex_digits[map[bg]] or "1")
end
- term.blit(
+ mon.blit(
table.concat(blit_char),
table.concat(blit_fg),
table.concat(blit_bg))
diff --git a/john.lua b/john.lua
index b083539..bdbae96 100644
--- a/john.lua
+++ b/john.lua
@@ -22,9 +22,7 @@ for ix,iname in ipairs(monitors) do
local mon = peripheral.wrap(iname)
mon.clear()
mon.setTextScale(0.5)
- local t = term.redirect(mon)
- local _, bee = pcall(function() fb:present(xoffs,0) end)
- term.redirect(t)
+ local _, bee = pcall(function() fb:present(mon,xoffs,0) end)
xoffs = xoffs + (mon.getSize())*2 + 8
print(bee)
end