Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-07-13 11:44:13 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-07-13 11:44:13 -0700
commitc0fe0407380f51c83178991f5f3719eab5452559 (patch)
treef12bd723c50b6a1a37a097748669c998f1b6871a /src/radial.js
parent5465a0741a075de714053e7196adf8492272877c (diff)
Add special transform for building 4, mapsheet 1
Diffstat (limited to 'src/radial.js')
-rw-r--r--src/radial.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/radial.js b/src/radial.js
index 6ad04b0..547c0ea 100644
--- a/src/radial.js
+++ b/src/radial.js
@@ -624,14 +624,28 @@ sheets = msGrps.map(msG => {
buildings: [...buildings].map(bld => {
const bldId = bld.getAttributeNS(null, 'class');
const bldDef = document.querySelector(`defs #${bldId}`);
+ // Map-specific footprint definition override
+ const footprint = bld.querySelector('.footprint') ? bld.querySelectorAll('.footprint g') : bldDef.querySelectorAll('.footprint g');
- const grid = [...bldDef.querySelectorAll('.footprint g')].reduce((acc, coordEl) => {
+ const grid = [...footprint].reduce((acc, coordEl) => {
acc = generateRadialCoords(acc, toRad(coordEl.dataset), toRect(coordEl.dataset), coordEl.dataset.offset);
return acc;
}, new Map());
const { q: dq, r: dr, s: ds } = toRad(bld.dataset);
- const position = bld.dataset.rotate ? rotate180({ q: +dq, r: +dr, s: +ds }) : ({ q, r, s }) => ({ q: q + +dq, r: r + +dr, s: s + +ds });
+ let position // = bld.dataset.rotate ? rotate180({ q: +dq, r: +dr, s: +ds }) : ({ q, r, s }) => ({ q: q + +dq, r: r + +dr, s: s + +ds });
+
+ if (bld.dataset.rotate)
+ position = rotate180({ q: +dq, r: +dr, s: +ds });
+ else if (bld.dataset.transform)
+ position = ({ q, r, s }) => ({
+ q: q + +dq,
+ r: r + +dr,
+ s: s + +ds,
+ transform: (x, y) => `translate(${x + horzSpacing}, ${y})`
+ })
+ else
+ position = ({ q, r, s }) => ({ q: q + +dq, r: r + +dr, s: s + +ds });
return {
type: bld.getAttributeNS(null, 'class'),