diff options
author | ubq323 <ubq323@ubq323.website> | 2024-04-01 03:31:20 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-04-01 03:31:20 +0100 |
commit | d262b443e0675cba334ec146adbeb2806c7c48b9 (patch) | |
tree | c383a0cfd28f045cb846d7356ccc066392962aff | |
parent | 1f471149968dd51518213c3e2f3a3618daabff8d (diff) |
launch john
-rw-r--r-- | framebuf.lua | 13 | ||||
-rw-r--r-- | john.lua | 4 |
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)) @@ -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 |