diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-10-25 11:58:58 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-10-26 00:00:01 +0200 |
commit | 5d81b4294bd8f9b20ac8a396a185f6cf9550c00f (patch) | |
tree | 1fd4e5fd1bbab268f3421cef825d6504b39d5370 /tools/genlayout.js | |
parent | 7122c8101e49300b7e29266a939f355e9eb8ffd3 (diff) | |
download | 1989-dawn-of-freedom-5d81b4294bd8f9b20ac8a396a185f6cf9550c00f.tar.gz |
Update client.
Fixed some spelling errors in space data table.
Create tools directory and add Makefile.
Add layout.svg with boxes drawn on top of locations.
Add genlayout.js to create list of box locations.
Add gencolors.js to create beveled marker border colors.
Major rewrite of play.js and play.css with official assets.
Diffstat (limited to 'tools/genlayout.js')
-rw-r--r-- | tools/genlayout.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/genlayout.js b/tools/genlayout.js new file mode 100644 index 0000000..37f419d --- /dev/null +++ b/tools/genlayout.js @@ -0,0 +1,37 @@ +const fs = require("fs") + +let boxes = [] +let mode, name, x, y, w, h + +function flush() { + if (mode === 'rect') { + boxes[name] = [ x |0, y |0, w |0, h |0 ] + } + x = y = w = h = 0 + name = null +} + +for (let line of fs.readFileSync("tools/layout.svg", "utf-8").split("\n")) { + line = line.trim() + if (line.startsWith("<rect")) { + flush() + mode = "rect" + x = y = w = h = 0 + } else if (line.startsWith('x="')) + x = Math.round(Number(line.split('"')[1])) + else if (line.startsWith('y="')) + y = Math.round(Number(line.split('"')[1])) + else if (line.startsWith('width="')) + w = Math.round(Number(line.split('"')[1])) + else if (line.startsWith('height="')) + h = Math.round(Number(line.split('"')[1])) + else if (line.startsWith('inkscape:label="')) + name = line.split('"')[1] +} + +flush() + +console.log("var LAYOUT = {") +for (let key of Object.keys(boxes).sort()) + console.log("\t\"" + key + "\": " + JSON.stringify(boxes[key]) + ",") +console.log("}") |