diff options
author | chai <chaifix@163.com> | 2018-05-21 16:02:00 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-05-21 16:02:00 +0800 |
commit | fa234f9663b992cf50bcf865a1cde6845b42193c (patch) | |
tree | 34ecd41b60ef48c960a79a4077e5e0c8536102fd /src/script/embed/debug.lua.h | |
parent | 51ba9cb2a6b0b9395a2912eadeb954c95e4c1d3c (diff) |
修改audio模块
Diffstat (limited to 'src/script/embed/debug.lua.h')
-rw-r--r-- | src/script/embed/debug.lua.h | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/src/script/embed/debug.lua.h b/src/script/embed/debug.lua.h deleted file mode 100644 index 79c95ba..0000000 --- a/src/script/embed/debug.lua.h +++ /dev/null @@ -1,132 +0,0 @@ -/* debug.lua */ -static const char* debug_lua = R"( ---[[ - for debug purpose - +-------------------+ - |debug msg old | - |... | - |... | - |... | - |debug msg new | - +-------------------+ -]] - -jin.debug = jin.debug or {} - --- render panel -local panel = nil - -local debug = false - --- debug msg buffer -local buffer = {} - --- configure -local bsize = 10 -local fsize = 15 -local lheight = 18 -local alpha = 220 -local margin = 10 - --- refresh buffer or not -local refresh = true - -function jin.debug.init() - debug = true - panel = jin.graphics.Canvas(jin.graphics.size()) -end - --- set buffer size -function jin.debug.size(c) - bsize = c -end - -function jin.debug.print(msg) - if not debug then return end - - msg = tostring(msg) - local tp = type(msg) - if tp ~= "string" and tp ~= "number" then - msg = string.format("print failed, expect string or number but get a %s", tp) - end - - -- remove the first one (old msg) - if #buffer >= bsize then - table.remove(buffer, 1) - end - - buffer[#buffer + 1] = msg - refresh = true -end - --- clear debug buffer -function jin.debug.clear() - buffer = {} -end - -local function getStrHeight(str, lheight) - local h = lheight - if #str == 0 then - h = 0 - end - for i = 1, #str do - local c = string.sub(str, i, i) - if c == '\n' then - h = h + lheight - end - end - return h -end - -local function getBgQuad() - local width, height = 0, 0 - for i = 1, #buffer do - local w, h = jin.graphics.box( buffer[i], fsize, 1, lheight) - height = height + h - if width < w then - width = w - end - end - return width, height -end - --- render to screen -function jin.debug.render() - if not debug then return end - - if refresh then - - jin.graphics.bind(panel) - - jin.graphics.clear(0, 0, 0, 0) - - jin.graphics.study() - - local ww, wh = jin.graphics.size() - local bgw, bgh = getBgQuad() - jin.graphics.color(0, 0, 0, alpha) - jin.graphics.rect("fill", 0, wh - bgh - margin, bgw + margin, bgh + margin) - - jin.graphics.color() - local y = wh - for i = #buffer, 1, -1 do - local msg = buffer[i] - local h = getStrHeight(msg, lheight) - y = y - h - jin.graphics.write(msg, margin / 2, y - margin/ 2, fsize, 1, lheight) - end - - jin.graphics.bind() - - refresh = false - end - - jin.graphics.color() - jin.graphics.draw(panel, 0, 0) -end - -function jin.debug.status() - return debug -end - -)";
\ No newline at end of file |