aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/lua
diff options
context:
space:
mode:
authorGravatar fmenozzi <fmenozzi@google.com>2016-07-18 13:33:37 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-18 13:33:37 -0700
commitd876a4b549998addbef76c1985f605b8213d86b2 (patch)
treeac2432a3f5e138356dac547df2067ddf81f0e6c7 /tools/lua
parent01a2ff8a325e17221b139968e337413df0c2e60c (diff)
Add bounds info
Diffstat (limited to 'tools/lua')
-rw-r--r--tools/lua/gradients.lua29
-rwxr-xr-xtools/lua/gradients.py4
2 files changed, 24 insertions, 9 deletions
diff --git a/tools/lua/gradients.lua b/tools/lua/gradients.lua
index 833b8b9ca1..71e8c30d17 100644
--- a/tools/lua/gradients.lua
+++ b/tools/lua/gradients.lua
@@ -14,7 +14,13 @@ function LuaDoubleNearlyEqual(a, b)
return math.abs(a-b) <= LuaDoubleNearlyZero
end
-verbs = {}
+function bounds(rect)
+ local width = rect.right - rect.left
+ local height = rect.bottom - rect.top
+
+ return width, height
+end
+
gradients = {}
i = 1
@@ -26,16 +32,21 @@ function sk_scrape_accumulate(t)
if s then
local g = s:asAGradient()
if g then
- if verbs[t.verb] then
- verbs[t.verb] = verbs[t.verb] + 1
- else
- verbs[t.verb] = 1
- end
-
gradients[i] = {}
gradients[i].filename = filename
+ local width, height = -1, -1
+ if t.rect then
+ width, height = bounds(t.rect)
+ elseif t.rrect then
+ width, height = bounds(t.rrect:rect())
+ elseif t.path then
+ width, height = bounds(t.path:getBounds())
+ end
+ gradients[i].boundsWidth = width
+ gradients[i].boundsHeight = height
+
gradients[i].colorCount = g.colorCount
gradients[i].type = g.type
gradients[i].tile = g.tile
@@ -79,7 +90,7 @@ function sk_scrape_summarize()
end
end
- io.write(string.format("%s %d %s %s %d %d %s %s\n",
+ io.write(string.format("%s %d %s %s %d %d %s %d %d %s\n",
v.filename,
v.colorCount,
v.type,
@@ -87,6 +98,8 @@ function sk_scrape_summarize()
tonumber(v.isEvenlySpaced and 1 or 0),
v.numHardStops,
v.verb,
+ v.boundsWidth,
+ v.boundsHeight,
pos))
end
end
diff --git a/tools/lua/gradients.py b/tools/lua/gradients.py
index 65ced5e854..580781731b 100755
--- a/tools/lua/gradients.py
+++ b/tools/lua/gradients.py
@@ -19,6 +19,8 @@ def create_database(inpath, outpath):
EvenlySpaced INTEGER,
HardStopCount INTEGER,
Verb TEXT,
+ BoundsWidth INTEGER,
+ BoundsHeight INTEGER,
Positions TEXT
)''');
c.execute("DELETE FROM gradients");
@@ -29,7 +31,7 @@ def create_database(inpath, outpath):
gradients.append(line.split());
c.executemany(
- "INSERT INTO gradients VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
+ "INSERT INTO gradients VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
gradients);
conn.commit();