diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-04-23 01:44:54 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-07-07 18:39:22 +0200 |
commit | bb449ea7ce9224284c2b60698cf0b0c7d70f9c71 (patch) | |
tree | 63569033b59d2180660bcebca71a98e4dede9ccf /tools/genhex.js | |
parent | 4936b1e7ff063e4d5d888d467f553d87a4a49abf (diff) | |
download | time-of-crisis-bb449ea7ce9224284c2b60698cf0b0c7d70f9c71.tar.gz |
Asset scripts and start of client.
Diffstat (limited to 'tools/genhex.js')
-rw-r--r-- | tools/genhex.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tools/genhex.js b/tools/genhex.js new file mode 100644 index 0000000..c0e8812 --- /dev/null +++ b/tools/genhex.js @@ -0,0 +1,63 @@ +// hexagonal counters with embedded image and outline + +const fs = require('fs') + +function print_hex(output, input, hi, lo, bd) { + let image = fs.readFileSync(input).toString('base64') + let svg = [] + + let img_w = 50 + let img_h = 58 // 57.735 + + let svg_w = img_w + 4 + let svg_h = img_h + 6 + + svg.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${svg_w}" height="${svg_h}">`) + + let iw = img_w / 2 + let ih = iw / Math.sqrt(3) + let iy = (svg_h - ih * 4) / 2 + + let ow = img_w / 2 + 2 + let oh = ow / Math.sqrt(3) + let oy = (svg_h - oh * 4) / 2 + + svg.push('<clipPath id="ic">') + svg.push(`<path d="M 1 ${iy} m 0 ${3*ih} v -${2*ih} l ${iw} -${ih} l ${iw} ${ih} v ${2*ih} l -${iw} ${ih} z"/>`) + svg.push('</clipPath>') + + svg.push('<clipPath id="oc">') + svg.push(`<path d="M 0 ${oy} m 0 ${oh*3} v -${oh*2} l ${ow} -${oh} l ${ow} ${oh} z"/>`) + svg.push('</clipPath>') + + svg.push(`<path fill="${bd}" d="M 0 ${oy} m 0 ${3*oh} v -${2*oh} l ${ow} -${oh} l ${ow} ${oh} v ${2*oh} l -${ow} ${oh} z"/>`) + + svg.push(`<image x="2" y="3" width="${img_w}" height="${img_h}" clip-path="url(#ic)" href="data:image/png;base64,${image}"/>`) + + svg.push(`<path fill="none" stroke="${lo}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`) + svg.push(` d="M 2 ${iy} m ${2*iw} ${ih} v ${ih*2} l -${iw} ${ih} l -${iw} -${ih}"/>`) + svg.push(`<path fill="none" stroke="${hi}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" clip-path="url(#oc)"`) + svg.push(` d="M 2 ${iy} m 0 ${ih*3} v -${ih*2} l ${iw} -${ih} l ${iw} ${ih}"/>`) + + svg.push('</svg>') + + fs.writeFileSync(output, svg.join("\n") + "\n") +} + +print_hex("images/castra.svg", "images/castra.png", "#ffffff", "#b2b2b2", "#434343") +print_hex("images/quaestor.svg", "images/quaestor.png", "#ffffff", "#b2b2b2", "#434343") + +print_hex("images/mob.svg", "images/mob.png", "#eaebc7", "#888968", "#323214") +print_hex("images/mob_x2.svg", "images/mob_x2.png", "#eaebc7", "#888968", "#323214") + +print_hex("images/blue_breakaway.svg", "images/blue_breakaway.png", "#d5ffff", "#6e96b6", "#113854") +print_hex("images/blue_seat_of_power.svg", "images/blue_seat_of_power.png", "#d5ffff", "#6e96b6", "#113854") + +print_hex("images/green_breakaway.svg", "images/green_breakaway.png", "#ace48f", "#568837", "#033600") +print_hex("images/green_seat_of_power.svg", "images/green_seat_of_power.png", "#ace48f", "#568837", "#033600") + +print_hex("images/red_breakaway.svg", "images/red_breakaway.png", "#ff5455", "#c00000", "#680000") +print_hex("images/red_seat_of_power.svg", "images/red_seat_of_power.png", "#ff5455", "#c00000", "#680000") + +print_hex("images/yellow_breakaway.svg", "images/yellow_breakaway.png", "#fffe92", "#c3a634", "#553a00") +print_hex("images/yellow_seat_of_power.svg", "images/yellow_seat_of_power.png", "#fffe92", "#c3a634", "#553a00") |