summaryrefslogtreecommitdiff
path: root/tools/parse-layout.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/parse-layout.js')
-rw-r--r--tools/parse-layout.js14
1 files changed, 5 insertions, 9 deletions
diff --git a/tools/parse-layout.js b/tools/parse-layout.js
index 5ee91c7..dba68af 100644
--- a/tools/parse-layout.js
+++ b/tools/parse-layout.js
@@ -4,6 +4,7 @@ let points = {}
let rects = {}
let edges = {}
let mode, name, x, y, w, h, cx, cy, rx, ry, x2, y2
+let labels = []
function add_point(x, y) {
if (name in points)
@@ -155,19 +156,14 @@ for (let line of fs.readFileSync("tools/layout.svg", "utf-8").split("\n")) {
name = line.split('"')[1]
else if (line.startsWith('d="'))
parse_path_data(line.split('"')[1].split(/[ ,]/))
+ if (line.includes("</tspan>")) {
+ let name = line.replace(/^[^>]*>/, "").replace(/<\/tspan.*/, "")
+ labels.push({x, y, name})
+ }
}
flush()
-let labels = []
-
-// names.txt is layout.svg cleaned up by svgo and filtered to only include text nodes
-for (let line of fs.readFileSync("tools/names.txt", "utf-8").split("\n")) {
- let m = line.match(/<tspan x="([\d.]*)" y="([\d.]*)">([^<]*)</)
- if (m)
- labels.push({x: Number(m[1]), y: Number(m[2]), name: m[3]})
-}
-
function find_closest_node(list, x, y) {
let nd = Infinity, nn = null