mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame^] | 1 | function tostr(t) |
| 2 | local str = "" |
| 3 | for k, v in next, t do |
| 4 | str = str .. tostring(k) .. " " |
| 5 | if type(v) == "table" then |
| 6 | str = str .. "{ " .. tostr(v) .. "} " |
| 7 | else |
| 8 | str = str .. tostring(v) .. " " |
| 9 | end |
| 10 | end |
| 11 | return str |
| 12 | end |
| 13 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 14 | canvas = {} |
| 15 | total = 0 |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame^] | 16 | |
| 17 | function accumulate(t) |
| 18 | local verb = t.verb |
| 19 | t.verb = nil |
| 20 | |
| 21 | total = total + 1 |
| 22 | local n = canvas[verb] or 0 |
| 23 | n = n + 1 |
| 24 | canvas[verb] = n |
| 25 | |
| 26 | io.write(verb, " ") |
| 27 | io.write(tostr(t), "\n") |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 28 | end |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame^] | 29 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 30 | function summarize() |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame^] | 31 | io.write("total ", total, "\n", tostr(canvas), "\n") |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 32 | end |
| 33 | |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame^] | 34 | --[[ |
| 35 | function drawsomething() |
| 36 | local s = skia_newsurface(100, 100) |
| 37 | local c = s:getcanvas(); |
| 38 | c:setColor(1, 0, 0, 1) |
| 39 | c:drawRect(10, 10, 50, 50) |
| 40 | s:saveImage("image.png") |
| 41 | end |
| 42 | --]] |
| 43 | |