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

Side by Side 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, 4 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 unified diff | Download patch | Annotate | Revision Log
« src/utils/SkLua.cpp ('K') | « src/utils/SkLua.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1
21 function sk_scrape_startcanvas(c, fileName) end 2 function sk_scrape_startcanvas(c, fileName) end
22 3
23 function sk_scrape_endcanvas(c, fileName) end 4 function sk_scrape_endcanvas(c, fileName) end
24 5
6 count3 = 0
7 count3sym = 0
8
25 function sk_scrape_accumulate(t) 9 function sk_scrape_accumulate(t)
26 local p = t.paint 10 local p = t.paint
27 if p then 11 if p then
28 local s = p:getShader() 12 local s = p:getShader()
29 if s then 13 if s then
30 local g = s:asAGradient() 14 local g = s:asAGradient()
31 if g then 15 if g then
32 io.write(g.type, " gradient with ", g.colorCount, " colors\n") 16 --io.write(g.type, " gradient with ", g.colorCount, " colors\n")
33 else 17
34 local b = s:asABitmap() 18 if g.colorCount == 3 then
35 if b then 19 count3 = count3 + 1
36 io.write("bitmap ", b.genID, " width=", b.width, " height=", b.height, "\n") 20
37 end 21 if (g.midPos >= 0.499 and g.midPos <= 0.501) then
22 count3sym = count3sym + 1
23 end
24 end
38 end 25 end
39 end 26 end
40 end 27 end
41 end 28 end
42 29
43 function sk_scrape_summarize() end 30 function sk_scrape_summarize()
31 io.write("Number of 3 color gradients: ", count3, "\n");
32 io.write("Number of 3 color symmetric gradients: ", count3sym, "\n");
33 end
44 34
OLDNEW
« 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