| OLD | NEW |
| 1 -- just a helper function to dump the parameters, for debugging | |
| 2 function tostr(t) | 1 function tostr(t) |
| 3 local str = "" | 2 local str = "" |
| 4 for k, v in next, t do | 3 for k, v in next, t do |
| 5 if #str > 0 then | 4 if #str > 0 then |
| 6 str = str .. ", " | 5 str = str .. ", " |
| 7 end | 6 end |
| 8 if type(k) == "number" then | 7 if type(k) == "number" then |
| 9 str = str .. "[" .. k .. "] = " | 8 str = str .. "[" .. k .. "] = " |
| 10 else | 9 else |
| 11 str = str .. tostring(k) .. " = " | 10 str = str .. tostring(k) .. " = " |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 end | 44 end |
| 46 | 45 |
| 47 --[[ | 46 --[[ |
| 48 Called with the parameters to each canvas.draw call, where canvas is the | 47 Called with the parameters to each canvas.draw call, where canvas is the |
| 49 current canvas as set by startcanvas() | 48 current canvas as set by startcanvas() |
| 50 ]] | 49 ]] |
| 51 function sk_scrape_accumulate(t) | 50 function sk_scrape_accumulate(t) |
| 52 local n = total[t.verb] or 0 | 51 local n = total[t.verb] or 0 |
| 53 total[t.verb] = n + 1 | 52 total[t.verb] = n + 1 |
| 54 | 53 |
| 55 if false and t.verb == "drawRect" then | 54 if false and t.verb == "drawRect" and t.paint:isAntiAlias() then |
| 56 local m = canvas:getTotalMatrix() | 55 local r = t.rect; |
| 57 print("... ", tostr(m), "\n") | 56 local p = t.paint; |
| 57 local c = p:getColor(); |
| 58 print("drawRect ", tostr(r), tostr(c), "\n") |
| 58 end | 59 end |
| 59 | 60 |
| 60 if false and t.verb == "drawPath" then | 61 if false and t.verb == "drawPath" then |
| 61 local pred, r1, r2, d1, d2 = t.path:isNestedRects() | 62 local pred, r1, r2, d1, d2 = t.path:isNestedRects() |
| 62 | 63 |
| 63 if pred then | 64 if pred then |
| 64 print("drawRect_Nested", tostr(r1), tostr(r2), d1, d2) | 65 print("drawRect_Nested", tostr(r1), tostr(r2), d1, d2) |
| 65 else | 66 else |
| 66 print("drawPath", "isEmpty", tostring(t.path:isEmpty()), | 67 print("drawPath", "isEmpty", tostring(t.path:isEmpty()), |
| 67 "isRect", tostring(t.path:isRect()), tostr(t.path:getBounds(
))) | 68 "isRect", tostring(t.path:isRect()), tostr(t.path:getBounds(
))) |
| 68 end | 69 end |
| 69 end | 70 end |
| 70 | |
| 71 -- enable to dump all of the parameters we were sent | |
| 72 if false then | |
| 73 -- dump the params in t, specifically showing the verb first, which we | |
| 74 -- then nil out so it doesn't appear in tostr() | |
| 75 io.write(t.verb, " ") | |
| 76 t.verb = nil | |
| 77 io.write(tostr(t), "\n") | |
| 78 end | |
| 79 end | 71 end |
| 80 | 72 |
| 81 --[[ | 73 --[[ |
| 82 lua_pictures will call this function after all of the pictures have been | 74 lua_pictures will call this function after all of the pictures have been |
| 83 "accumulated". | 75 "accumulated". |
| 84 ]] | 76 ]] |
| 85 function sk_scrape_summarize() | 77 function sk_scrape_summarize() |
| 86 io.write("\n{ ", tostr(total), " }\n") | 78 io.write("\n{ ", tostr(total), " }\n") |
| 87 end | 79 end |
| 88 | 80 |
| OLD | NEW |