2013-05-21 03:24:37 +00:00
|
|
|
-- just a helper function to dump the parameters, for debugging
|
2013-05-16 04:20:23 +00:00
|
|
|
function tostr(t)
|
|
|
|
local str = ""
|
|
|
|
for k, v in next, t do
|
2013-05-21 03:24:37 +00:00
|
|
|
if #str > 0 then
|
|
|
|
str = str .. ", "
|
|
|
|
end
|
|
|
|
if type(k) == "number" then
|
|
|
|
str = str .. "[" .. k .. "] = "
|
|
|
|
else
|
|
|
|
str = str .. tostring(k) .. " = "
|
|
|
|
end
|
2013-05-16 04:20:23 +00:00
|
|
|
if type(v) == "table" then
|
2013-05-21 03:24:37 +00:00
|
|
|
str = str .. "{ " .. tostr(v) .. " }"
|
2013-05-16 04:20:23 +00:00
|
|
|
else
|
2013-05-21 03:24:37 +00:00
|
|
|
str = str .. tostring(v)
|
2013-05-16 04:20:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return str
|
|
|
|
end
|
|
|
|
|
2013-05-21 12:20:39 +00:00
|
|
|
total = {}
|
|
|
|
|
|
|
|
function setcanvas(c)
|
|
|
|
canvas = c
|
|
|
|
end
|
2013-05-16 04:20:23 +00:00
|
|
|
|
2013-05-21 03:24:37 +00:00
|
|
|
-- called with the parameters to each canvas.draw call
|
2013-05-16 04:20:23 +00:00
|
|
|
function accumulate(t)
|
2013-05-21 12:20:39 +00:00
|
|
|
local n = total[t.verb] or 0
|
|
|
|
total[t.verb] = n + 1
|
|
|
|
|
2013-05-21 14:19:53 +00:00
|
|
|
if false and t.verb == "drawRect" then
|
2013-05-21 12:20:39 +00:00
|
|
|
local m = canvas:getTotalMatrix()
|
|
|
|
print("... ", tostr(m), "\n")
|
|
|
|
end
|
2013-05-16 04:20:23 +00:00
|
|
|
|
2013-05-21 03:24:37 +00:00
|
|
|
-- enable to dump all of the parameters we were sent
|
|
|
|
if false then
|
|
|
|
-- dump the params in t, specifically showing the verb first, which we
|
|
|
|
-- then nil out so it doesn't appear in tostr()
|
|
|
|
io.write(t.verb, " ")
|
|
|
|
t.verb = nil
|
|
|
|
io.write(tostr(t), "\n")
|
|
|
|
end
|
2013-05-15 19:34:20 +00:00
|
|
|
end
|
2013-05-16 04:20:23 +00:00
|
|
|
|
2013-05-21 03:24:37 +00:00
|
|
|
-- lua_pictures will call this function after all of the files have been
|
|
|
|
-- "accumulated"
|
2013-05-15 19:34:20 +00:00
|
|
|
function summarize()
|
2013-05-21 12:20:39 +00:00
|
|
|
io.write("\n", tostr(total), "\n")
|
2013-05-16 04:20:23 +00:00
|
|
|
end
|
|
|
|
|