Added 3-color gradient scraper for detecting symmetrical gradients.
Made changes to lua to scrape info about 3 color gradients
BUG=
R=reed@google.com
Author: dierk@google.com
Review URL: https://chromiumcodereview.appspot.com/21571002
git-svn-id: http://skia.googlecode.com/svn/trunk@10490 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/lua/gradients.lua b/tools/lua/gradients.lua
index 3ae08d5..b2d8cf7 100644
--- a/tools/lua/gradients.lua
+++ b/tools/lua/gradients.lua
@@ -1,27 +1,11 @@
-function tostr(t)
- local str = ""
- for k, v in next, t do
- 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) .. " }"
- else
- str = str .. tostring(v)
- end
- end
- return str
-end
function sk_scrape_startcanvas(c, fileName) end
function sk_scrape_endcanvas(c, fileName) end
+count3 = 0
+count3sym = 0
+
function sk_scrape_accumulate(t)
local p = t.paint
if p then
@@ -29,16 +13,22 @@
if s then
local g = s:asAGradient()
if g then
- io.write(g.type, " gradient with ", g.colorCount, " colors\n")
- else
- local b = s:asABitmap()
- if b then
- io.write("bitmap ", b.genID, " width=", b.width, " height=", b.height, "\n")
- end
+ --io.write(g.type, " gradient with ", g.colorCount, " colors\n")
+
+ if g.colorCount == 3 then
+ count3 = count3 + 1
+
+ if (g.midPos >= 0.499 and g.midPos <= 0.501) then
+ count3sym = count3sym + 1
+ end
+ end
end
end
end
end
-function sk_scrape_summarize() end
+function sk_scrape_summarize()
+ io.write("Number of 3 color gradients: ", count3, "\n");
+ io.write("Number of 3 color symmetric gradients: ", count3sym, "\n");
+end