Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 -- | |
| 2 -- Copyright 2016 Google Inc. | |
| 3 -- | |
| 4 -- Use of this source code is governed by a BSD-style license that can be | |
| 5 -- found in the LICENSE file. | |
| 6 -- | |
| 7 | |
| 8 -- Dashed path scraping script. | |
| 9 -- This script is designed to count the total number of dashes in a path | |
| 10 | |
| 11 dashes = 0 | |
| 12 | |
| 13 pathPieces = {} | |
| 14 | |
| 15 function sk_scrape_startcanvas(c, fileName) | |
| 16 end | |
| 17 | |
| 18 function sk_scrape_endcanvas(c, fileName) | |
| 19 end | |
| 20 | |
| 21 function sk_scrape_accumulate(t) | |
| 22 local paint = t.paint | |
| 23 if paint then | |
| 24 local pe = paint:getPathEffect() | |
| 25 if pe then | |
| 26 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
| |
| 27 if dash then | |
| 28 if t.verb == "drawPath" then | |
| 29 dashes = dashes + 1 | |
| 30 pathPieces[dashes] = 0 | |
| 31 | |
| 32 local path = t.path | |
| 33 local fillpath = paint:getFillPath(path) | |
| 34 local verbs = fillpath:getVerbs() | |
| 35 for _, verb in ipairs(verbs) do | |
| 36 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
| |
| 37 pathPieces[dashes] = pathPieces[dashes] + 1 | |
| 38 end | |
| 39 end | |
| 40 end | |
| 41 end | |
| 42 end | |
| 43 end | |
| 44 end | |
| 45 | |
| 46 function sk_scrape_summarize() | |
| 47 local pieces5 = 0; | |
| 48 local pieces10 = 0; | |
| 49 for _, p in ipairs(pathPieces) do | |
| 50 if p < 5 then | |
| 51 pieces5 = pieces5 + 1 | |
| 52 end | |
| 53 if p > 5 and p < 10 then | |
| 54 pieces10 = pieces10 + 1 | |
| 55 end | |
| 56 end | |
| 57 io.write(string.format("%d %d %d\n", dashes, pieces5, pieces10)) | |
| 58 end | |
| OLD | NEW |