| OLD | NEW |
| 1 -- just a helper function to dump the parameters, for debugging | 1 -- just a helper function to dump the parameters, for debugging |
| 2 function tostr(t) | 2 function tostr(t) |
| 3 local str = "" | 3 local str = "" |
| 4 for k, v in next, t do | 4 for k, v in next, t do |
| 5 if #str > 0 then | 5 if #str > 0 then |
| 6 str = str .. ", " | 6 str = str .. ", " |
| 7 end | 7 end |
| 8 if type(k) == "number" then | 8 if type(k) == "number" then |
| 9 str = str .. "[" .. k .. "] = " | 9 str = str .. "[" .. k .. "] = " |
| 10 else | 10 else |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 function setcanvas(c) | 24 function setcanvas(c) |
| 25 canvas = c | 25 canvas = c |
| 26 end | 26 end |
| 27 | 27 |
| 28 -- called with the parameters to each canvas.draw call | 28 -- called with the parameters to each canvas.draw call |
| 29 function accumulate(t) | 29 function accumulate(t) |
| 30 local n = total[t.verb] or 0 | 30 local n = total[t.verb] or 0 |
| 31 total[t.verb] = n + 1 | 31 total[t.verb] = n + 1 |
| 32 | 32 |
| 33 if t.verb == "drawRect" then | 33 if false and t.verb == "drawRect" then |
| 34 local m = canvas:getTotalMatrix() | 34 local m = canvas:getTotalMatrix() |
| 35 print("... ", tostr(m), "\n") | 35 print("... ", tostr(m), "\n") |
| 36 end | 36 end |
| 37 | 37 |
| 38 -- enable to dump all of the parameters we were sent | 38 -- enable to dump all of the parameters we were sent |
| 39 if false then | 39 if false then |
| 40 -- dump the params in t, specifically showing the verb first, which we | 40 -- dump the params in t, specifically showing the verb first, which we |
| 41 -- then nil out so it doesn't appear in tostr() | 41 -- then nil out so it doesn't appear in tostr() |
| 42 io.write(t.verb, " ") | 42 io.write(t.verb, " ") |
| 43 t.verb = nil | 43 t.verb = nil |
| 44 io.write(tostr(t), "\n") | 44 io.write(tostr(t), "\n") |
| 45 end | 45 end |
| 46 end | 46 end |
| 47 | 47 |
| 48 -- lua_pictures will call this function after all of the files have been | 48 -- lua_pictures will call this function after all of the files have been |
| 49 -- "accumulated" | 49 -- "accumulated" |
| 50 function summarize() | 50 function summarize() |
| 51 io.write("\n", tostr(total), "\n") | 51 io.write("\n", tostr(total), "\n") |
| 52 end | 52 end |
| 53 | 53 |
| OLD | NEW |