mirror of
https://github.com/Kiritow/OpenComputerScripts.git
synced 2024-03-22 13:10:46 +08:00
Add color support
This commit is contained in:
parent
1b1d674e68
commit
9c4081a0df
|
@ -86,7 +86,9 @@ local function printMap(base,mask)
|
||||||
if(base[i][j]>=0) then
|
if(base[i][j]>=0) then
|
||||||
gpu:set(i+1,j+1,tostring(base[i][j]))
|
gpu:set(i+1,j+1,tostring(base[i][j]))
|
||||||
else
|
else
|
||||||
|
gpu:pushfg(0xFF0000)
|
||||||
gpu:set(i+1,j+1,"X")
|
gpu:set(i+1,j+1,"X")
|
||||||
|
gpu:popfg()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
50
kgui.lua
50
kgui.lua
|
@ -16,6 +16,46 @@ local function GPUGet(t,line,col)
|
||||||
return t.gpu.get(col,line)
|
return t.gpu.get(col,line)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function GPUSetColorFG(t,rgb)
|
||||||
|
t.gpu.setForeground(rgb)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GPUSetColorBG(t,rgb)
|
||||||
|
t.gpu.setBackground(rgb)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GPUGetColorFG(t)
|
||||||
|
return t.gpu.getForeground()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GPUGetColorBG(t)
|
||||||
|
return t.gpu.getBackground()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GPUPushFG(t,rgb)
|
||||||
|
t.fgstk[t.fgstk.n+1]=t:getfg()
|
||||||
|
t.fgstk.n=t.fgstk.n+1
|
||||||
|
t:setfg(rgb)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GPUPopFG(t)
|
||||||
|
t:setfg(t.fgstk[t.fgstk.n])
|
||||||
|
t.fgstk[t.fgstk.n]=nil
|
||||||
|
t.fgstk.n=t.fgstk.n-1
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GPUPushBG(t,rgb)
|
||||||
|
t.bgstk[t.bgstk.n+1]=t:getbg()
|
||||||
|
t.bgstk.n=t.bgstk.n+1
|
||||||
|
t:setbg(rgb)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GPUPopBG(t)
|
||||||
|
t:setbg(t.bgstk[t.bgstk.n])
|
||||||
|
t.bgstk[t.bgstk.n]=nil
|
||||||
|
t.bgstk.n=t.bgstk.n-1
|
||||||
|
end
|
||||||
|
|
||||||
-- API
|
-- API
|
||||||
function GetGPU()
|
function GetGPU()
|
||||||
if(component.gpu==nil) then
|
if(component.gpu==nil) then
|
||||||
|
@ -26,6 +66,16 @@ function GetGPU()
|
||||||
t.clear=GPUClear
|
t.clear=GPUClear
|
||||||
t.set=GPUSet
|
t.set=GPUSet
|
||||||
t.get=GPUGet
|
t.get=GPUGet
|
||||||
|
t.setfg=GPUSetColorFG
|
||||||
|
t.getfg=GPUGetColorFG
|
||||||
|
t.setbg=GPUSetColorBG
|
||||||
|
t.getbg=GPUGetColorBG
|
||||||
|
t.fgstk={n=0}
|
||||||
|
t.bgstk={n=0}
|
||||||
|
t.pushfg=GPUPushFG
|
||||||
|
t.popfg=GPUPopFG
|
||||||
|
t.pushbg=GPUPushBG
|
||||||
|
t.popbg=GPUPopBG
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user