aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/lua/scrape.lua
diff options
context:
space:
mode:
authorGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-21 03:24:37 +0000
committerGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-21 03:24:37 +0000
commit0e59b796e596cd51af4ded378f2881459fd288e4 (patch)
tree78669bf5f2d06acf2ade46fa1fe471b484544dbd /tools/lua/scrape.lua
parentcef454e7b8e065096783c0f7922594bacaa39e92 (diff)
allow multiple lua files to be used in lua_pictures
begin "stdlib" for skia in lua add comments to scrape.lua git-svn-id: http://skia.googlecode.com/svn/trunk@9206 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/lua/scrape.lua')
-rw-r--r--tools/lua/scrape.lua45
1 files changed, 24 insertions, 21 deletions
diff --git a/tools/lua/scrape.lua b/tools/lua/scrape.lua
index 839d3fe868..de0be08ddb 100644
--- a/tools/lua/scrape.lua
+++ b/tools/lua/scrape.lua
@@ -1,11 +1,19 @@
+-- just a helper function to dump the parameters, for debugging
function tostr(t)
local str = ""
for k, v in next, t do
- str = str .. tostring(k) .. " "
+ if #str > 0 then
+ str = str .. ", "
+ end
+ if type(k) == "number" then
+ str = str .. "[" .. k .. "] = "
+ else
+ str = str .. tostring(k) .. " = "
+ end
if type(v) == "table" then
- str = str .. "{ " .. tostr(v) .. "} "
+ str = str .. "{ " .. tostr(v) .. " }"
else
- str = str .. tostring(v) .. " "
+ str = str .. tostring(v)
end
end
return str
@@ -14,30 +22,25 @@ end
canvas = {}
total = 0
+-- called with the parameters to each canvas.draw call
function accumulate(t)
- local verb = t.verb
- t.verb = nil
-
total = total + 1
- local n = canvas[verb] or 0
- n = n + 1
- canvas[verb] = n
+ local n = canvas[t.verb] or 0
+ canvas[t.verb] = n + 1
- io.write(verb, " ")
- io.write(tostr(t), "\n")
+ -- 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
end
+-- lua_pictures will call this function after all of the files have been
+-- "accumulated"
function summarize()
io.write("total ", total, "\n", tostr(canvas), "\n")
end
---[[
-function drawsomething()
- local s = skia_newsurface(100, 100)
- local c = s:getcanvas();
- c:setColor(1, 0, 0, 1)
- c:drawRect(10, 10, 50, 50)
- s:saveImage("image.png")
-end
---]]
-