From feae2da9bdc11437415b684d9d872b7b262c1a6f Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 15 Jul 2023 20:14:59 +0200 Subject: Tools. --- tools/genlayout.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tools/genlayout.js (limited to 'tools/genlayout.js') diff --git a/tools/genlayout.js b/tools/genlayout.js new file mode 100644 index 0000000..2191d90 --- /dev/null +++ b/tools/genlayout.js @@ -0,0 +1,59 @@ +const fs = require("fs") + +const { round, floor, ceil } = Math + +let boxes = {} +let mode, name, x, y, w, h, cx, cy, rx, ry +let scale = 0.75 + +function flush() { + if (mode === 'rect') { + boxes[name] = [ x * scale |0, y * scale |0, w * scale |0, h * scale |0 ] + } + if (mode === 'circle') { + x = cx - rx + y = cy - ry + w = rx * 2 + h = ry * 2 + boxes[name] = [ x * scale |0, y * scale |0, w * scale |0, h * scale |0 ] + } + x = y = w = h = cx = cy = rx = ry = 0 + name = null +} + +for (let line of fs.readFileSync("tools/layout.svg", "utf-8").split("\n")) { + line = line.trim() + if (line.startsWith("