Chromium Code Reviews| Index: tools/lua/count_dashes.lua |
| diff --git a/tools/lua/count_dashes.lua b/tools/lua/count_dashes.lua |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..70df97103bb02e34d66610fea4b2179b7d657d2c |
| --- /dev/null |
| +++ b/tools/lua/count_dashes.lua |
| @@ -0,0 +1,58 @@ |
| +-- |
| +-- Copyright 2016 Google Inc. |
| +-- |
| +-- Use of this source code is governed by a BSD-style license that can be |
| +-- found in the LICENSE file. |
| +-- |
| + |
| +-- Dashed path scraping script. |
| +-- This script is designed to count the total number of dashes in a path |
| + |
| +dashes = 0 |
| + |
| +pathPieces = {} |
| + |
| +function sk_scrape_startcanvas(c, fileName) |
| +end |
| + |
| +function sk_scrape_endcanvas(c, fileName) |
| +end |
| + |
| +function sk_scrape_accumulate(t) |
| + local paint = t.paint |
| + if paint then |
| + local pe = paint:getPathEffect() |
| + if pe then |
| + local dash = pe:asADash() |
|
reed1
2016/08/01 19:36:29
possibly check for drawPath before creating the da
Harry Stern
2016/08/01 20:58:23
I'll just do them at the same time, there's no rea
|
| + if dash then |
| + if t.verb == "drawPath" then |
| + dashes = dashes + 1 |
| + pathPieces[dashes] = 0 |
| + |
| + local path = t.path |
| + local fillpath = paint:getFillPath(path) |
| + local verbs = fillpath:getVerbs() |
| + for _, verb in ipairs(verbs) do |
| + if verb == "move" or verb == "close" then |
|
reed1
2016/08/01 19:36:29
why do you look for close?
Harry Stern
2016/08/01 20:58:23
(Mike and I discussed this and he told me that we
|
| + pathPieces[dashes] = pathPieces[dashes] + 1 |
| + end |
| + end |
| + end |
| + end |
| + end |
| + end |
| +end |
| + |
| +function sk_scrape_summarize() |
| + local pieces5 = 0; |
| + local pieces10 = 0; |
| + for _, p in ipairs(pathPieces) do |
| + if p < 5 then |
| + pieces5 = pieces5 + 1 |
| + end |
| + if p > 5 and p < 10 then |
| + pieces10 = pieces10 + 1 |
| + end |
| + end |
| + io.write(string.format("%d %d %d\n", dashes, pieces5, pieces10)) |
| +end |