diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-09-30 00:47:39 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-01 16:11:22 +0200 |
commit | bbcc4798c959efe9a0056da85224409c418dec9d (patch) | |
tree | 5e611d8cadc40f6aef36528b76da5b11668f3441 /tools | |
parent | 6ecebe1bd199e836cc178ba3bd5234e9ae3d5bfa (diff) | |
download | waterloo-campaign-1815-bbcc4798c959efe9a0056da85224409c418dec9d.tar.gz |
Add village names as HTML text.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/labels.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/labels.js b/tools/labels.js new file mode 100644 index 0000000..c739825 --- /dev/null +++ b/tools/labels.js @@ -0,0 +1,31 @@ +const data = require('../data.js') + +const yoff = 1555 +const xoff = 36 +const hex_dx = 58.67 +const hex_dy = 68 +const hex_r = 56 >> 1 + +const CAPS = [ 1204, 1217, 1737, 2911, 3002, 3925 ] + +var hex_x = [] +var hex_y = [] + +for (let row = 0; row < data.map.rows; ++row) { + for (let col = 0; col < data.map.cols; ++col) { + let hex_id = 1000 + 100 * row + col + hex_x[hex_id] = Math.floor(xoff + hex_dx * (col + (row & 1) * 0.5 + 0.5)) + hex_y[hex_id] = Math.floor(yoff - hex_dy * 3 / 4 * row + hex_dy/2) + } +} + +for (let hex in data.map.names) { + hex = hex | 0 + let name = data.map.names[hex] + let x = hex_x[hex] - 35 + let y = hex_y[hex] + if (CAPS.includes(hex)) + console.log(`<div class="label caps" style="left:${x}px;top:${y}px">${name}</div>`) + else + console.log(`<div class="label" style="left:${x}px;top:${y}px">${name}</div>`) +} |