OLD | NEW |
1 function sk_scrape_startcanvas(c, fileName) end | 1 filename = "" |
2 function sk_scrape_endcanvas(c, fileName) end | 2 |
| 3 function sk_scrape_startcanvas(c, fileName) |
| 4 filename = fileName |
| 5 end |
| 6 |
| 7 function sk_scrape_endcanvas(c, fileName) |
| 8 |
| 9 end |
3 | 10 |
4 LuaDoubleNearlyZero = 1.0 / bit32.lshift(1.0, 12) | 11 LuaDoubleNearlyZero = 1.0 / bit32.lshift(1.0, 12) |
5 | 12 |
6 function LuaDoubleNearlyEqual(a, b) | 13 function LuaDoubleNearlyEqual(a, b) |
7 return math.abs(a-b) <= LuaDoubleNearlyZero | 14 return math.abs(a-b) <= LuaDoubleNearlyZero |
8 end | 15 end |
9 | 16 |
10 verbs = {} | 17 verbs = {} |
11 gradients = {} | 18 gradients = {} |
12 | 19 |
13 i = 1 | 20 i = 1 |
14 | 21 |
15 function sk_scrape_accumulate(t) | 22 function sk_scrape_accumulate(t) |
16 local p = t.paint | 23 local p = t.paint |
17 if p then | 24 if p then |
18 local s = p:getShader() | 25 local s = p:getShader() |
19 if s then | 26 if s then |
20 local g = s:asAGradient() | 27 local g = s:asAGradient() |
21 if g then | 28 if g then |
22 if verbs[t.verb] then | 29 if verbs[t.verb] then |
23 verbs[t.verb] = verbs[t.verb] + 1 | 30 verbs[t.verb] = verbs[t.verb] + 1 |
24 else | 31 else |
25 verbs[t.verb] = 1 | 32 verbs[t.verb] = 1 |
26 end | 33 end |
27 | 34 |
28 gradients[i] = {} | 35 gradients[i] = {} |
29 | 36 |
| 37 gradients[i].filename = filename |
| 38 |
30 gradients[i].colorCount = g.colorCount | 39 gradients[i].colorCount = g.colorCount |
31 gradients[i].type = g.type | 40 gradients[i].type = g.type |
32 gradients[i].tile = g.tile | 41 gradients[i].tile = g.tile |
33 | 42 |
34 isEvenlySpaced = true | 43 isEvenlySpaced = true |
35 for j = 1, g.colorCount, 1 do | 44 for j = 1, g.colorCount, 1 do |
36 if not LuaDoubleNearlyEqual(g.positions[j], (j-1)/(g.colorCo
unt-1)) then | 45 if not LuaDoubleNearlyEqual(g.positions[j], (j-1)/(g.colorCo
unt-1)) then |
37 isEvenlySpaced = false | 46 isEvenlySpaced = false |
38 end | 47 end |
39 end | 48 end |
(...skipping 23 matching lines...) Expand all Loading... |
63 function sk_scrape_summarize() | 72 function sk_scrape_summarize() |
64 for k, v in pairs(gradients) do | 73 for k, v in pairs(gradients) do |
65 local pos = "" | 74 local pos = "" |
66 for j = 1, v.colorCount , 1 do | 75 for j = 1, v.colorCount , 1 do |
67 pos = pos .. v.positions[j] | 76 pos = pos .. v.positions[j] |
68 if j ~= v.colorCount then | 77 if j ~= v.colorCount then |
69 pos = pos .. "," | 78 pos = pos .. "," |
70 end | 79 end |
71 end | 80 end |
72 | 81 |
73 io.write(string.format("%d %s %s %d %d %s %s\n", | 82 io.write(string.format("%s %d %s %s %d %d %s %s\n", |
| 83 v.filename, |
74 v.colorCount, | 84 v.colorCount, |
75 v.type, | 85 v.type, |
76 v.tile, | 86 v.tile, |
77 tonumber(v.isEvenlySpaced and 1 or 0), | 87 tonumber(v.isEvenlySpaced and 1 or 0), |
78 v.numHardStops, | 88 v.numHardStops, |
79 v.verb, | 89 v.verb, |
80 pos)) | 90 pos)) |
81 end | 91 end |
82 end | 92 end |
83 | 93 |
OLD | NEW |