Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: tools/lua/gradients.lua

Issue 21571002: Added 3-color gradient scraper for detecting symmetrical gradients. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Small revisions for clarity and imprecision. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/utils/SkLua.cpp ('K') | « src/utils/SkLua.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lua/gradients.lua
diff --git a/tools/lua/gradients.lua b/tools/lua/gradients.lua
index 3ae08d50dba01a72a7355b35b6efef8bcb6d0708..b2d8cf773490ed8bac61bd791088209fd6ad7981 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 @@ function sk_scrape_accumulate(t)
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
« src/utils/SkLua.cpp ('K') | « src/utils/SkLua.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698