Home | History | Annotate | Download | only in lua
      1 function tostr(t)
      2     local str = ""
      3     for k, v in next, t do
      4         if #str > 0 then
      5             str = str .. ", "
      6         end
      7         if type(k) == "number" then
      8             str = str .. "[" .. k .. "] = "
      9         else
     10             str = str .. tostring(k) .. " = "
     11         end
     12         if type(v) == "table" then
     13             str = str .. "{ " .. tostr(v) .. " }"
     14         else
     15             str = str .. tostring(v)
     16         end
     17     end
     18     return str
     19 end
     20 
     21 local canvas        -- holds the current canvas (from startcanvas())
     22 
     23 --[[
     24     startcanvas() is called at the start of each picture file, passing the
     25     canvas that we will be drawing into, and the name of the file.
     26     
     27     Following this call, there will be some number of calls to accumulate(t)
     28     where t is a table of parameters that were passed to that draw-op.
     29     
     30         t.verb is a string holding the name of the draw-op (e.g. "drawRect")
     31     
     32     when a given picture is done, we call endcanvas(canvas, fileName)
     33 ]]
     34 function sk_scrape_startcanvas(c, fileName)
     35     canvas = c
     36 end
     37 
     38 --[[
     39     Called when the current canvas is done drawing.
     40 ]]
     41 function sk_scrape_endcanvas(c, fileName)
     42     canvas = nil
     43 end
     44 
     45 --[[
     46     Called with the parameters to each canvas.draw call, where canvas is the
     47     current canvas as set by startcanvas()
     48 ]]
     49 
     50 local gCF_Count = 0
     51 local gIF_Count = 0
     52 local gBOTH_Count = 0
     53 
     54 function sk_scrape_accumulate(t)
     55     if not t.paint then
     56         return
     57     end
     58 
     59     local colorFilter = t.paint:getColorFilter()
     60     local imageFilter = t.paint:getImageFilter()
     61 
     62     if colorFilter then
     63         gCF_Count = gCF_Count + 1
     64     end
     65     if imageFilter then
     66         gIF_Count = gIF_Count + 1
     67     end
     68     if colorFilter and imageFilter then
     69         gBOTH_Count = gBOTH_Count + 1
     70     end
     71 end
     72 
     73 --[[
     74     lua_pictures will call this function after all of the pictures have been
     75     "accumulated".
     76 ]]
     77 function sk_scrape_summarize()
     78     io.write("colorfilters ", gCF_Count, ", imagefilters ", gIF_Count, ", both_filters ", gBOTH_Count, "\n")
     79 
     80 --[[
     81     io.write("\n\nFirst glyph spread\n\n")
     82     for k, v in next, gFirstGlyphs do
     83         io.write("glyph, ", k, ",count, ", v, "\n")
     84     end
     85 ]]
     86 end
     87 
     88 function test_summary()
     89     io.write("just testing test_summary\n")
     90 end
     91 
     92