-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpb_gfxrnd.lua
executable file
·60 lines (51 loc) · 1.78 KB
/
pb_gfxrnd.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
return {init=function(box,module,api,share,_,load_flags)
local function check_graphics_mode(terminal)
if terminal.getGraphicsMode() ~= 1 then
if not share.set_term_mode then
api.module_error(module,"Terminal graphics mode must be \"1\"",3,load_flags.supress)
else terminal.setGraphicsMode(1) end
end
end
local function gfxrnd_renderer(self)
check_graphics_mode(box.term)
self.term.drawPixels(
self.x_offset + 1,
self.y_offset + 1,
self.canvas,
self.width,self.height
)
end
local function gfxrnd_updater()
local w,h = box.term.getSize(
box.term.getGraphicsMode and box.term.getGraphicsMode() or 1
)
box.term_width,box.term_height = w,h
box.width, box.height = w,h
api.restore(box,box.background,true,true)
end
return {
render = gfxrnd_renderer
},{
verified_load=function()
if box.term.drawPixels == nil then
api.module_error(module,"Target terminal doesnt have GFX mode",3,load_flags.supress)
end
local w,h = box.term.getSize(1)
box.term_width,box.term_height = w,h
box.width, box.height = w,h
if box.modules["PB_MODULE:rndswp"] then
box.__rndswp__renderer["gfx"] = {
drawer = gfxrnd_renderer,
update = gfxrnd_updater
}
end
gfxrnd_updater()
end
}
end,
id = "PB_MODULE:gfxrnd",
name = "PB_GFXRender",
author = "9551",
contact = "https://devvie.cc/contact",
report_msg = "\n__name: module error, report issues at\n-> __contact"
}