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:
parent
d2a1a00dc4
commit
aab0cd34cd
|
@ -233,14 +233,32 @@ local function drawCanvasPixel(x, y)
|
||||||
end
|
end
|
||||||
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
|
Converts each colour in a single line of the canvas and draws it
|
||||||
returns: nil
|
returns: nil
|
||||||
]]
|
]]
|
||||||
local function drawCanvasLine(y)
|
local function drawCanvasLine(y)
|
||||||
|
local text, fg, bg = "", "", ""
|
||||||
for x = 1, w - 2 do
|
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
|
end
|
||||||
|
|
||||||
|
term.setCursorPos(1, y)
|
||||||
|
term.blit(text, fg, bg)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|
Loading…
Reference in New Issue