Create graphics.lua

This commit is contained in:
Ale2610 2015-07-31 20:29:29 +02:00
parent 5a41cad6e4
commit 82d629d347

37
src/apis/graphics.lua Normal file
View file

@ -0,0 +1,37 @@
function pixel(x, y, color)
local ox, oy = term.getCursorPos()
term.setCursorPos(x, y)
term.setBackgroundColor(color)
term.write(" ")
term.setCursorPos(ox, oy)
end
function line(x, y, x2, y2, color)
local ox, oy = term.getCursorPos()
if x == x2 then
term.setBackgroundColor(color)
for _y = y, y2 do
term.setCursorPos(x, _y)
term.write(" ")
end
elseif y == y2 then
term.setBackgroundColor(color)
for _x = x, x2 do
term.setCursorPos(_x, y)
term.write(" ")
end
else
error("diagonal/other lines not supported")
end
term.setCursorPos(ox, oy)
end
function box(x, y, x2, y2, color)
local ox, oy = term.getCursorPos()
term.setBackgroundColor(color)
for _y = y, y2 do
term.setCursorPos(x, _y)
term.write(string.rep(" ", (x2 - x) + 1))
end
term.setCursorPos(ox, oy)
end