Use term.blit on original paint render

This makes it super speedy, meaning an initial refresh doesn't take ages
to load.
This commit is contained in:
SquidDev 2020-11-20 15:06:47 +00:00
parent d2a1a00dc4
commit aab0cd34cd
1 changed files with 19 additions and 1 deletions

View File

@ -233,14 +233,32 @@ local function drawCanvasPixel(x, y)
end
end
local color_hex_lookup = {}
for i = 0, 15 do
color_hex_lookup[2 ^ i] = string.format("%x", i)
end
--[[
Converts each colour in a single line of the canvas and draws it
returns: nil
]]
local function drawCanvasLine(y)
local text, fg, bg = "", "", ""
for x = 1, w - 2 do
drawCanvasPixel(x, y)
local pixel = getCanvasPixel(x, y)
if pixel then
text = text .. " "
fg = fg .. "0"
bg = bg .. color_hex_lookup[pixel or canvasColour]
else
text = text .. "\127"
fg = fg .. color_hex_lookup[canvasColour]
bg = bg .. color_hex_lookup[colours.grey]
end
end
term.setCursorPos(1, y)
term.blit(text, fg, bg)
end
--[[