Web Dev Solutions

Catalin Mititiuc

From c0fe0407380f51c83178991f5f3719eab5452559 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Sat, 13 Jul 2024 11:44:13 -0700 Subject: Add special transform for building 4, mapsheet 1 --- public/assets/images/map4.svg | 2 -- public/assets/images/mapsheets.svg | 11 ++++++++++- public/assets/images/scenario_template.svg | 7 +++++++ src/radial.js | 18 ++++++++++++++++-- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/public/assets/images/map4.svg b/public/assets/images/map4.svg index ec57ad4..1462a04 100644 --- a/public/assets/images/map4.svg +++ b/public/assets/images/map4.svg @@ -73,6 +73,4 @@ - - diff --git a/public/assets/images/mapsheets.svg b/public/assets/images/mapsheets.svg index 52c024c..3f62c5f 100644 --- a/public/assets/images/mapsheets.svg +++ b/public/assets/images/mapsheets.svg @@ -48,6 +48,7 @@ + @@ -66,6 +67,7 @@ + @@ -81,6 +83,7 @@ + @@ -96,6 +99,7 @@ + @@ -111,6 +115,7 @@ + @@ -126,6 +131,7 @@ + @@ -270,8 +276,11 @@ - + + + + diff --git a/public/assets/images/scenario_template.svg b/public/assets/images/scenario_template.svg index 01fb328..5480a8c 100644 --- a/public/assets/images/scenario_template.svg +++ b/public/assets/images/scenario_template.svg @@ -3,6 +3,13 @@ + + + + + + + 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'), -- cgit v1.2.3